shell32: Don't use GetProcAddress for GetOpenFileName[AW].

This commit is contained in:
Alex Henrie 2022-12-01 20:16:00 -07:00 committed by Alexandre Julliard
parent a6218a8145
commit a1ffd507e4
3 changed files with 4 additions and 40 deletions

View file

@ -1,7 +1,7 @@
MODULE = shell32.dll
IMPORTLIB = shell32
IMPORTS = uuid shlwapi user32 gdi32 advapi32
DELAYIMPORTS = ole32 oleaut32 shdocvw version comctl32 gdiplus
DELAYIMPORTS = ole32 oleaut32 shdocvw version comctl32 comdlg32 gdiplus
C_SRCS = \
appbar.c \

View file

@ -271,8 +271,6 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
case IDC_RUNDLG_BROWSE :
{
HMODULE hComdlg = NULL ;
LPFNOFN ofnProc = NULL ;
WCHAR szFName[1024] = {0};
WCHAR filter_exe[256], filter_all[256], filter[MAX_PATH], szCaption[MAX_PATH];
OPENFILENAMEW ofn;
@ -292,15 +290,7 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
ofn.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
ofn.lpstrInitialDir = prfdp->lpstrDirectory;
if (NULL == (hComdlg = LoadLibraryExW (L"comdlg32.dll", NULL, 0)) ||
NULL == (ofnProc = (LPFNOFN)GetProcAddress (hComdlg, "GetOpenFileNameW")))
{
ERR("Couldn't get GetOpenFileName function entry (lib=%p, proc=%p)\n", hComdlg, ofnProc);
ShellMessageBoxW(shell32_hInstance, hwnd, MAKEINTRESOURCEW(IDS_RUNDLG_BROWSE_ERROR), NULL, MB_OK | MB_ICONERROR);
return TRUE ;
}
if (ofnProc(&ofn))
if (GetOpenFileNameW(&ofn))
{
SetFocus (GetDlgItem (hwnd, IDOK)) ;
SetWindowTextW (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), szFName) ;
@ -308,8 +298,6 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
SetFocus (GetDlgItem (hwnd, IDOK)) ;
}
FreeLibrary (hComdlg) ;
return TRUE ;
}
}

View file

@ -188,8 +188,6 @@ static BOOL GetFileNameFromBrowseA(
LPCSTR lpstrFilter,
LPCSTR lpstrTitle)
{
HMODULE hmodule;
BOOL (WINAPI *pGetOpenFileNameA)(LPOPENFILENAMEA);
OPENFILENAMEA ofn;
BOOL ret;
@ -197,15 +195,6 @@ static BOOL GetFileNameFromBrowseA(
hwndOwner, lpstrFile, nMaxFile, lpstrInitialDir, lpstrDefExt,
lpstrFilter, lpstrTitle);
hmodule = LoadLibraryA("comdlg32.dll");
if(!hmodule) return FALSE;
pGetOpenFileNameA = (void *)GetProcAddress(hmodule, "GetOpenFileNameA");
if(!pGetOpenFileNameA)
{
FreeLibrary(hmodule);
return FALSE;
}
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
@ -217,9 +206,8 @@ static BOOL GetFileNameFromBrowseA(
ofn.lpstrTitle = lpstrTitle;
ofn.lpstrDefExt = lpstrDefExt;
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
ret = pGetOpenFileNameA(&ofn);
ret = GetOpenFileNameA(&ofn);
FreeLibrary(hmodule);
return ret;
}
@ -235,8 +223,6 @@ static BOOL GetFileNameFromBrowseW(
LPCWSTR lpstrFilter,
LPCWSTR lpstrTitle)
{
HMODULE hmodule;
BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW);
OPENFILENAMEW ofn;
BOOL ret;
@ -244,15 +230,6 @@ static BOOL GetFileNameFromBrowseW(
hwndOwner, debugstr_w(lpstrFile), nMaxFile, debugstr_w(lpstrInitialDir), debugstr_w(lpstrDefExt),
debugstr_w(lpstrFilter), debugstr_w(lpstrTitle));
hmodule = LoadLibraryA("comdlg32.dll");
if(!hmodule) return FALSE;
pGetOpenFileNameW = (void *)GetProcAddress(hmodule, "GetOpenFileNameW");
if(!pGetOpenFileNameW)
{
FreeLibrary(hmodule);
return FALSE;
}
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
@ -264,9 +241,8 @@ static BOOL GetFileNameFromBrowseW(
ofn.lpstrTitle = lpstrTitle;
ofn.lpstrDefExt = lpstrDefExt;
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
ret = pGetOpenFileNameW(&ofn);
ret = GetOpenFileNameW(&ofn);
FreeLibrary(hmodule);
return ret;
}