Use GetModuleHandleW ()

Also fix an unwanted ref-count increment on a module HANDLE
This commit is contained in:
Luca Bacci 2022-12-30 16:42:02 +01:00 committed by Jehan
parent f7be0cf68e
commit ed1e4236ba
6 changed files with 15 additions and 14 deletions

View File

@ -221,7 +221,7 @@ gui_unique_win32_init (Gimp *gimp)
/* register window class for proxy window */
memset (&wc, 0, sizeof (wc));
wc.hInstance = GetModuleHandle (NULL);
wc.hInstance = GetModuleHandleW (NULL);
wc.lpfnWndProc = gui_unique_win32_message_handler;
wc.lpszClassName = GIMP_UNIQUE_WIN32_WINDOW_CLASS;

View File

@ -613,7 +613,7 @@ main (int argc,
t_SetDllDirectoryA p_SetDllDirectoryA;
p_SetDllDirectoryA =
(t_SetDllDirectoryA) GetProcAddress (GetModuleHandle ("kernel32.dll"),
(t_SetDllDirectoryA) GetProcAddress (GetModuleHandleW (L"kernel32.dll"),
"SetDllDirectoryA");
if (p_SetDllDirectoryA)
(*p_SetDllDirectoryA) ("");
@ -647,7 +647,7 @@ main (int argc,
t_SetProcessDEPPolicy p_SetProcessDEPPolicy;
p_SetProcessDEPPolicy =
(t_SetProcessDEPPolicy) GetProcAddress (GetModuleHandle ("kernel32.dll"),
(t_SetProcessDEPPolicy) GetProcAddress (GetModuleHandleW (L"kernel32.dll"),
"SetProcessDEPPolicy");
if (p_SetProcessDEPPolicy)
(*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
@ -660,7 +660,7 @@ main (int argc,
t_SetCurrentProcessExplicitAppUserModelID p_SetCurrentProcessExplicitAppUserModelID;
p_SetCurrentProcessExplicitAppUserModelID =
(t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandle ("shell32.dll"),
(t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandleW (L"shell32.dll"),
"SetCurrentProcessExplicitAppUserModelID");
if (p_SetCurrentProcessExplicitAppUserModelID)
(*p_SetCurrentProcessExplicitAppUserModelID) (L"gimp.GimpApplication");

View File

@ -200,7 +200,7 @@ gimp_main (GType plug_in_type,
typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName);
t_SetDllDirectoryA p_SetDllDirectoryA;
p_SetDllDirectoryA = (t_SetDllDirectoryA) GetProcAddress (GetModuleHandle ("kernel32.dll"),
p_SetDllDirectoryA = (t_SetDllDirectoryA) GetProcAddress (GetModuleHandleW (L"kernel32.dll"),
"SetDllDirectoryA");
if (p_SetDllDirectoryA)
(*p_SetDllDirectoryA) ("");
@ -269,7 +269,7 @@ gimp_main (GType plug_in_type,
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
t_SetProcessDEPPolicy p_SetProcessDEPPolicy;
p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"),
p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandleW (L"kernel32.dll"),
"SetProcessDEPPolicy");
if (p_SetProcessDEPPolicy)
(*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
@ -281,7 +281,7 @@ gimp_main (GType plug_in_type,
typedef HRESULT (WINAPI *t_SetCurrentProcessExplicitAppUserModelID) (PCWSTR lpPathName);
t_SetCurrentProcessExplicitAppUserModelID p_SetCurrentProcessExplicitAppUserModelID;
p_SetCurrentProcessExplicitAppUserModelID = (t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandle ("shell32.dll"),
p_SetCurrentProcessExplicitAppUserModelID = (t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandleW (L"shell32.dll"),
"SetCurrentProcessExplicitAppUserModelID");
if (p_SetCurrentProcessExplicitAppUserModelID)
(*p_SetCurrentProcessExplicitAppUserModelID) (L"gimp.GimpApplication");

View File

@ -204,9 +204,10 @@ gimp_input_device_store_init (GimpInputDeviceStore *store)
gtk_list_store_set_column_types (GTK_LIST_STORE (store),
G_N_ELEMENTS (types), types);
if (!GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
(LPCTSTR) &gimp_input_device_store_init,
&thismodule))
if (!GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCTSTR) &gimp_input_device_store_init,
&thismodule))
return;
if ((store->window = create_aux_window (store)) == NULL)

View File

@ -790,7 +790,7 @@ doCaptureMagnificationAPI (HWND selectedHwnd,
/* Create the host window that will store the mag child window */
hwndHost = CreateWindowEx (0x08000000 | 0x080000 | 0x80 | 0x20, APP_NAME, NULL, 0x80000000,
0, 0, 0, 0, NULL, NULL, GetModuleHandle (NULL), NULL);
0, 0, 0, 0, NULL, NULL, GetModuleHandleW (NULL), NULL);
if (!hwndHost)
{
@ -808,7 +808,7 @@ doCaptureMagnificationAPI (HWND selectedHwnd,
hwndMag = CreateWindow (WC_MAGNIFIER, TEXT ("MagnifierWindow"),
magStyles,
0, 0, round4Rect.right - round4Rect.left, round4Rect.bottom - round4Rect.top,
hwndHost, NULL, GetModuleHandle (NULL), NULL);
hwndHost, NULL, GetModuleHandleW (NULL), NULL);
/* Set the callback function that will be called by the api to get the pixels */
if (!MagSetImageScalingCallback (hwndMag, (MagImageScalingCallback)doCaptureMagnificationAPI_callback))

View File

@ -346,9 +346,9 @@ twainMain (void)
pTW_SESSION twSession = initializeTwain();
/* Since we are not using our own WinMain anymore where we
could get hInst we get it here using GetModuleHandle. */
could get hInst we get it here using GetModuleHandleW. */
if (!hInst)
hInst = GetModuleHandle(NULL);
hInst = GetModuleHandleW(NULL);
/* Perform instance initialization */
if (!InitApplication(hInst))