Use GetModuleHandleW to avoid *A functions where possible.

This commit is contained in:
Martin v. Löwis 2012-01-14 17:54:09 +01:00
parent d61fdc17d3
commit 50590f111b
3 changed files with 8 additions and 8 deletions

View File

@ -1155,7 +1155,7 @@ check_GetFinalPathNameByHandle()
/* only recheck */ /* only recheck */
if (!has_GetFinalPathNameByHandle) if (!has_GetFinalPathNameByHandle)
{ {
hKernel32 = GetModuleHandle("KERNEL32"); hKernel32 = GetModuleHandleW(L"KERNEL32");
*(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32, *(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32,
"GetFinalPathNameByHandleA"); "GetFinalPathNameByHandleA");
*(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32, *(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32,
@ -6526,7 +6526,7 @@ check_CreateSymbolicLinkW()
/* only recheck */ /* only recheck */
if (has_CreateSymbolicLinkW) if (has_CreateSymbolicLinkW)
return has_CreateSymbolicLinkW; return has_CreateSymbolicLinkW;
hKernel32 = GetModuleHandle("KERNEL32"); hKernel32 = GetModuleHandleW(L"KERNEL32");
*(FARPROC*)&Py_CreateSymbolicLinkW = GetProcAddress(hKernel32, *(FARPROC*)&Py_CreateSymbolicLinkW = GetProcAddress(hKernel32,
"CreateSymbolicLinkW"); "CreateSymbolicLinkW");
if (Py_CreateSymbolicLinkW) if (Py_CreateSymbolicLinkW)
@ -9365,7 +9365,7 @@ win32_urandom(PyObject *self, PyObject *args)
/* Obtain handle to the DLL containing CryptoAPI /* Obtain handle to the DLL containing CryptoAPI
This should not fail */ This should not fail */
hAdvAPI32 = GetModuleHandle("advapi32.dll"); hAdvAPI32 = GetModuleHandleW(L"advapi32.dll");
if(hAdvAPI32 == NULL) if(hAdvAPI32 == NULL)
return win32_error("GetModuleHandle", NULL); return win32_error("GetModuleHandle", NULL);

View File

@ -118,7 +118,7 @@ BOOL CallModuleDllMain(char *modName, DWORD dwReason)
BOOL (WINAPI * pfndllmain)(HINSTANCE, DWORD, LPVOID); BOOL (WINAPI * pfndllmain)(HINSTANCE, DWORD, LPVOID);
char funcName[255]; char funcName[255];
HMODULE hmod = GetModuleHandle(NULL); HMODULE hmod = GetModuleHandleW(NULL);
strcpy(funcName, "_DllMain"); strcpy(funcName, "_DllMain");
strcat(funcName, modName); strcat(funcName, modName);
strcat(funcName, "@12"); // stdcall convention. strcat(funcName, "@12"); // stdcall convention.

View File

@ -1066,7 +1066,7 @@ PyDeleteKeyEx(PyObject *self, PyObject *args, PyObject *kwargs)
/* Only available on 64bit platforms, so we must load it /* Only available on 64bit platforms, so we must load it
dynamically. */ dynamically. */
hMod = GetModuleHandle("advapi32.dll"); hMod = GetModuleHandleW(L"advapi32.dll");
if (hMod) if (hMod)
pfn = (RDKEFunc)GetProcAddress(hMod, pfn = (RDKEFunc)GetProcAddress(hMod,
"RegDeleteKeyExW"); "RegDeleteKeyExW");
@ -1590,7 +1590,7 @@ PyDisableReflectionKey(PyObject *self, PyObject *args)
/* Only available on 64bit platforms, so we must load it /* Only available on 64bit platforms, so we must load it
dynamically.*/ dynamically.*/
hMod = GetModuleHandle("advapi32.dll"); hMod = GetModuleHandleW(L"advapi32.dll");
if (hMod) if (hMod)
pfn = (RDRKFunc)GetProcAddress(hMod, pfn = (RDRKFunc)GetProcAddress(hMod,
"RegDisableReflectionKey"); "RegDisableReflectionKey");
@ -1626,7 +1626,7 @@ PyEnableReflectionKey(PyObject *self, PyObject *args)
/* Only available on 64bit platforms, so we must load it /* Only available on 64bit platforms, so we must load it
dynamically.*/ dynamically.*/
hMod = GetModuleHandle("advapi32.dll"); hMod = GetModuleHandleW(L"advapi32.dll");
if (hMod) if (hMod)
pfn = (RERKFunc)GetProcAddress(hMod, pfn = (RERKFunc)GetProcAddress(hMod,
"RegEnableReflectionKey"); "RegEnableReflectionKey");
@ -1663,7 +1663,7 @@ PyQueryReflectionKey(PyObject *self, PyObject *args)
/* Only available on 64bit platforms, so we must load it /* Only available on 64bit platforms, so we must load it
dynamically.*/ dynamically.*/
hMod = GetModuleHandle("advapi32.dll"); hMod = GetModuleHandleW(L"advapi32.dll");
if (hMod) if (hMod)
pfn = (RQRKFunc)GetProcAddress(hMod, pfn = (RQRKFunc)GetProcAddress(hMod,
"RegQueryReflectionKey"); "RegQueryReflectionKey");