(5th) Janitorial dlls/advapi32/registry.c W->A cleanup
Dmitry Timoshkov
dmitry at baikal.ru
Mon Mar 10 02:04:36 CST 2003
"Tony Lambregts" <tony_lambregts at telusplanet.net> wrote:
> -IMPORTS = kernel32 ntdll
> +IMPORTS = kernel32 ntdll user32
I'm not sure Alexandre will like it. Until for now, creation of the circular
dependencies were prohibitted. Probably it's better to use swprintf from ntdll,
or a set of calls strcpyW/ntdll._ultow/strcatW.
> -LONG WINAPI RegSaveKeyW( HKEY hkey, LPCWSTR file, LPSECURITY_ATTRIBUTES sa )
> +LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
> {
> - LPSTR fileA = HEAP_strdupWtoA( GetProcessHeap(), 0, file );
> - DWORD ret = RegSaveKeyA( hkey, fileA, sa );
> - if (fileA) HeapFree( GetProcessHeap(), 0, fileA );
> - return ret;
> +
> + UNICODE_STRING *fileW = &NtCurrentTeb()->StaticUnicodeString;
> + STRING fileA;
> +
> + if (!file || !*file)
> + {
> + SetLastError(ERROR_PATH_NOT_FOUND);
> + return FALSE;
As Alexandre has already pointed out, registry APIs are supposed to not change
last error value.
> + }
> +
> + RtlInitAnsiString(&fileA, file);
> + RtlAnsiStringToUnicodeString(fileW, &fileA, FALSE);
> + if (fileW) return RegSaveKeyW(hkey, fileW->Buffer, sa);
> + return FALSE;
fileW is always not NULL, so, there is no need to check it. What you really
need to check is a return value of RtlAnsiStringToUnicodeString.
--
Dmitry.
More information about the wine-devel
mailing list