"James Hawkins" truiken@gmail.com writes:
- ret = MsiSourceListGetInfoW(product, usersid, dwContext, dwOptions,
property, value, pcchValue);
- if (ret == ERROR_SUCCESS)
WideCharToMultiByte(CP_ACP, 0, value, -1, szValue, *pcchValue, NULL, NULL);
The handling of pcchValue is wrong, you need a separate variable for the W size, and you need to set *pcchValue to the correct A size.
On 6/28/07, Alexandre Julliard julliard@winehq.org wrote:
"James Hawkins" truiken@gmail.com writes:
- ret = MsiSourceListGetInfoW(product, usersid, dwContext, dwOptions,
property, value, pcchValue);
- if (ret == ERROR_SUCCESS)
WideCharToMultiByte(CP_ACP, 0, value, -1, szValue, *pcchValue, NULL, NULL);
The handling of pcchValue is wrong, you need a separate variable for the W size, and you need to set *pcchValue to the correct A size.
To quote msdn for convenience:
"pcchValue: A pointer to a variable that specifies the number of TCHAR in the szValue buffer. When the function returns, this parameter is set to the size of the requested value whether or not the function copies the value into the specified buffer. The size is returned as the number of TCHAR in the requested value, not including the terminating null character."
By this definition, for any particular property requested, the size returned should be exactly the same for both the A and W call. This eliminates the need for a W size variable, and in fact, setting the returned A size by manipulating the returned W size (the usual divide by sizeof WCHAR) would be wrong. Have I messed up somewhere in my logic?
"James Hawkins" truiken@gmail.com writes:
By this definition, for any particular property requested, the size returned should be exactly the same for both the A and W call. This eliminates the need for a W size variable, and in fact, setting the returned A size by manipulating the returned W size (the usual divide by sizeof WCHAR) would be wrong. Have I messed up somewhere in my logic?
For the A size TCHARs are bytes, not logical characters, so there isn't a 1:1 equivalence with the W size. The only way to return the correct size is to convert with WideCharToMultiByte and return the resulting length. That's how all A functions work.
On 6/28/07, Alexandre Julliard julliard@winehq.org wrote:
"James Hawkins" truiken@gmail.com writes:
By this definition, for any particular property requested, the size returned should be exactly the same for both the A and W call. This eliminates the need for a W size variable, and in fact, setting the returned A size by manipulating the returned W size (the usual divide by sizeof WCHAR) would be wrong. Have I messed up somewhere in my logic?
For the A size TCHARs are bytes, not logical characters, so there isn't a 1:1 equivalence with the W size. The only way to return the correct size is to convert with WideCharToMultiByte and return the resulting length. That's how all A functions work.
Ok, thanks for clearing this up for me. I'll fix it and resend.