00211 {
00212
UINT cbLen;
00213
UINT cbSrc = (
UINT)GlobalSize(*phCommands);
00214
LPVOID pstr;
00215 HGLOBAL hTemp;
00216
BOOL fHandleValueChanged =
FALSE;
00217
00218
USERGLOBALLOCK(*phCommands, pstr);
00219
00220
if (cbSrc && pstr !=
NULL) {
00221
BOOL fIsUnicodeText;
00222
#ifdef ISTEXTUNICODE_WORKS
00223
int flags;
00224
00225 flags = (IS_TEXT_UNICODE_UNICODE_MASK |
00226 IS_TEXT_UNICODE_REVERSE_MASK |
00227 (IS_TEXT_UNICODE_NOT_UNICODE_MASK &
00228 (~IS_TEXT_UNICODE_ILLEGAL_CHARS)) |
00229 IS_TEXT_UNICODE_NOT_ASCII_MASK);
00230 fIsUnicodeText =
RtlIsTextUnicode(pstr, cbSrc - 2, &flags);
00231
#else
00232
fIsUnicodeText = ((cbSrc >=
sizeof(WCHAR)) && (((LPSTR)pstr)[1] ==
'\0'));
00233
#endif
00234
if (!fIsUnicodeText && fNeedUnicode) {
00235 LPWSTR pwsz;
00236
00237
00238
00239 cbLen =
strlen(pstr) + 1;
00240 cbSrc =
min(cbSrc, cbLen);
00241 pwsz =
UserLocalAlloc(HEAP_ZERO_MEMORY, cbSrc *
sizeof(WCHAR));
00242
if (pwsz !=
NULL) {
00243
if (
NT_SUCCESS(
RtlMultiByteToUnicodeN(
00244 pwsz,
00245 cbSrc *
sizeof(WCHAR),
00246 NULL,
00247 (PCHAR)pstr,
00248 cbSrc))) {
00249
USERGLOBALUNLOCK(*phCommands);
00250
if ((hTemp = GlobalReAlloc(
00251 *phCommands,
00252 cbSrc *
sizeof(WCHAR),
00253 GMEM_MOVEABLE)) !=
NULL) {
00254 fHandleValueChanged = (hTemp != *phCommands);
00255 *phCommands = hTemp;
00256
USERGLOBALLOCK(*phCommands, pstr);
00257 pwsz[cbSrc - 1] =
L'\0';
00258 wcscpy(pstr, pwsz);
00259 }
00260 }
00261
UserLocalFree(pwsz);
00262 }
00263 }
else if (fIsUnicodeText && !fNeedUnicode) {
00264 LPSTR psz;
00265
00266
00267
00268 cbLen = (wcslen(pstr) + 1) *
sizeof(WCHAR);
00269 cbSrc =
min(cbSrc, cbLen);
00270 psz =
UserLocalAlloc(HEAP_ZERO_MEMORY, cbSrc);
00271
if (psz !=
NULL) {
00272
if (
NT_SUCCESS(
RtlUnicodeToMultiByteN(
00273 psz,
00274 cbSrc,
00275 NULL,
00276 (PWSTR)pstr,
00277 cbSrc))) {
00278
USERGLOBALUNLOCK(*phCommands);
00279
if ((hTemp = GlobalReAlloc(
00280 *phCommands,
00281 cbSrc /
sizeof(WCHAR),
00282 GMEM_MOVEABLE)) !=
NULL) {
00283 fHandleValueChanged = (hTemp != *phCommands);
00284 *phCommands = hTemp;
00285
USERGLOBALLOCK(*phCommands, pstr);
00286 UserAssert(pstr);
00287 psz[cbSrc - 1] =
'\0';
00288 strcpy(pstr, psz);
00289 }
00290 }
00291
UserLocalFree(psz);
00292 }
00293 }
00294
USERGLOBALUNLOCK(*phCommands);
00295 }
00296
return(fHandleValueChanged);
00297 }