(3rd) Janitorial dlls/advapi32/registry.c W->A cleanup
Tony Lambregts
tony_lambregts at telusplanet.net
Thu Mar 6 11:23:16 CST 2003
With Dmitry's suggested change and Vincent's advice (doh!) This time with Patch (double doh!)
Change Log: Janitorial. Get rid of W->A calls
Files Changed: dlls/advapi32/registry.c
--
Tony Lambregts
-------------- next part --------------
Index: registry.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/registry.c,v
retrieving revision 1.50
diff -u -r1.50 registry.c
--- registry.c 20 Jan 2003 23:23:12 -0000 1.50
+++ registry.c 6 Mar 2003 17:07:38 -0000
@@ -1536,39 +1536,44 @@
/******************************************************************************
- * RegSaveKeyA [ADVAPI32.@]
+ * RegSaveKeyW [ADVAPI32.@]
*
* PARAMS
* hkey [I] Handle of key where save begins
* lpFile [I] Address of filename to save to
* sa [I] Address of security structure
*/
-LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
+LONG WINAPI RegSaveKeyW( HKEY hkey, LPCWSTR file, LPSECURITY_ATTRIBUTES sa )
{
- char buffer[1024];
+ WCHAR buffer[1024];
int count = 0;
- LPSTR name;
- DWORD ret, err;
+ LPWSTR nameW;
+ char *nameA;
+ DWORD ret, err, len;
HANDLE handle;
- TRACE( "(%p,%s,%p)\n", hkey, debugstr_a(file), sa );
+ TRACE( "(%p,%s,%p)\n", hkey, debugstr_w(file), sa );
if (!file || !*file) return ERROR_INVALID_PARAMETER;
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
err = GetLastError();
- GetFullPathNameA( file, sizeof(buffer), buffer, &name );
+ GetFullPathNameW( file, sizeof(buffer), buffer, &nameW );
+ len = WideCharToMultiByte(CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
+ nameA = HeapAlloc(GetProcessHeap(), 0, len);
+ WideCharToMultiByte(CP_ACP, 0, nameW, -1, nameA, len, NULL, NULL);
+
for (;;)
{
- sprintf( name, "reg%04x.tmp", count++ );
- handle = CreateFileA( buffer, GENERIC_WRITE, 0, NULL,
+ sprintf( nameA, "reg%04x.tmp", count++ );
+ handle = CreateFileW( buffer, GENERIC_WRITE, 0, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
if (handle != INVALID_HANDLE_VALUE) break;
if ((ret = GetLastError()) != ERROR_ALREADY_EXISTS) goto done;
/* Something gone haywire ? Please report if this happens abnormally */
if (count >= 100)
- MESSAGE("Wow, we are already fiddling with a temp file %s with an ordinal as high as %d !\nYou might want to delete all corresponding temp files in that directory.\n", buffer, count);
+ MESSAGE("Wow, we are already fiddling with a temp file %s with an ordinal as high as %d !\nYou might want to delete all corresponding temp files in that directory.\n", debugstr_w(buffer), count);
}
SERVER_START_REQ( save_registry )
@@ -1582,29 +1587,31 @@
CloseHandle( handle );
if (!ret)
{
- if (!MoveFileExA( buffer, file, MOVEFILE_REPLACE_EXISTING ))
+ if (!MoveFileExW( buffer, file, MOVEFILE_REPLACE_EXISTING ))
{
- ERR( "Failed to move %s to %s\n", buffer, file );
+ ERR( "Failed to move %s to %s\n", debugstr_w(buffer),
+ debugstr_w(file) );
ret = GetLastError();
}
}
- if (ret) DeleteFileA( buffer );
+ if (ret) DeleteFileW( buffer );
done:
+ HeapFree( GetProcessHeap(), 0, nameA );
SetLastError( err ); /* restore last error code */
return ret;
}
/******************************************************************************
- * RegSaveKeyW [ADVAPI32.@]
+ * RegSaveKeyA [ADVAPI32.@]
*/
-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;
+ WCHAR fileW[MAX_PATH];
+
+ MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
+ return RegSaveKeyW( hkey, fileW, sa );
}
@@ -1819,7 +1826,7 @@
if (!lpMachineName || !*lpMachineName) {
/* Use the local machine name */
- return RegOpenKeyA( hKey, "", phkResult );
+ return RegOpenKeyW( hKey, NULL, phkResult );
}
FIXME("Cannot connect to %s\n",debugstr_w(lpMachineName));
More information about the wine-patches
mailing list