diff --git a/metapath/src/Dialogs.c b/metapath/src/Dialogs.c index d5bcb47209..5f66f41d20 100644 --- a/metapath/src/Dialogs.c +++ b/metapath/src/Dialogs.c @@ -364,7 +364,8 @@ INT_PTR CALLBACK GotoDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) } } - if ((fp = GetProcAddress(GetModuleHandle(L"User32"), "GetComboBoxInfo")) != NULL) { + // since Windows Vista + if ((fp = GetProcAddress(GetModuleHandle(L"user32.dll"), "GetComboBoxInfo")) != NULL) { COMBOBOXINFO cbi; cbi.cbSize = sizeof(COMBOBOXINFO); if (fp(GetDlgItem(hwnd, IDC_GOTO), &cbi)) { diff --git a/metapath/src/Helpers.c b/metapath/src/Helpers.c index 3385008bb0..ca52b9336a 100644 --- a/metapath/src/Helpers.c +++ b/metapath/src/Helpers.c @@ -161,60 +161,17 @@ DWORD WINAPI GetModuleFileNameExW(HANDLE, HMODULE, LPTSTR, DWORD); BOOL WINAPI EnumProcessModules(HANDLE, HMODULE *, DWORD, LPDWORD); BOOL ExeNameFromWnd(HWND hwnd, LPWSTR szExeName, int cchExeName) { - //HMODULE hPSAPI; DWORD dwProcessId; HANDLE hProcess; HMODULE hModule; DWORD cbNeeded = 0; - //FARPROC fpCreateToolhelp32Snapshot; - //FARPROC fpProcess32First; - //FARPROC fpProcess32Next; - //HANDLE hProcessList; - //PROCESSENTRY32 pe; - //BOOL bMoreEntries; - //BOOL bFoundMatching = FALSE; - - /*if (IsWindowsNT()) { - if (hPSAPI = LoadLibrary(L"PSAPI")) {*/ + GetWindowThreadProcessId(hwnd, &dwProcessId); hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcessId); - /*GetProcAddress(hPSAPI, "EnumProcessModules")*/ EnumProcessModules(hProcess, &hModule, sizeof(HMODULE), &cbNeeded); - /*GetProcAddress(hPSAPI, "GetModuleFileNameExW")*/ GetModuleFileNameExW(hProcess, hModule, szExeName, cchExeName); CloseHandle(hProcess); - //FreeLibrary(hPSAPI); return TRUE; - /*} else { - return FALSE; - } - } else { - fpCreateToolhelp32Snapshot = GetProcAddress(GetModuleHandle(L"Kernel32"), "CreateToolhelp32Snapshot"); - fpProcess32First = GetProcAddress(GetModuleHandle(L"Kernel32"), "Process32First"); - fpProcess32Next = GetProcAddress(GetModuleHandle(L"Kernel32"), "Process32Next"); - - if (fpCreateToolhelp32Snapshot) { - GetWindowThreadProcessId(hwnd, &dwProcessId); - hProcessList = (HANDLE)fpCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - pe.dwSize = sizeof(PROCESSENTRY32); - bMoreEntries = fpProcess32First(hProcessList, &pe); - - while (bMoreEntries) { - if (pe.th32ProcessID == dwProcessId) { - bMoreEntries = FALSE; - bFoundMatching = TRUE; - lstrcpyn(szExeName, pe.szExeFile, cchExeName); - } else { - bMoreEntries = fpProcess32Next(hProcessList, &pe); - } - } - CloseHandle(hProcessList); - return (bFoundMatching); - } else { - return FALSE; - } - } - */ } ////============================================================================= @@ -494,10 +451,8 @@ void DeleteBitmapButton(HWND hwnd, int nCtlId) { // SetWindowTransparentMode() // void SetWindowTransparentMode(HWND hwnd, BOOL bTransparentMode) { - FARPROC fp; - if (bTransparentMode) { - if ((fp = GetProcAddress(GetModuleHandle(L"User32"), "SetLayeredWindowAttributes")) != NULL) { + if (IsWin2KAndAbove()) { int iAlphaPercent; BYTE bAlpha; SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); @@ -509,7 +464,7 @@ void SetWindowTransparentMode(HWND hwnd, BOOL bTransparentMode) { } bAlpha = (BYTE)(iAlphaPercent * 255 / 100); - fp(hwnd, 0, bAlpha, LWA_ALPHA); + SetLayeredWindowAttributes(hwnd, 0, bAlpha, LWA_ALPHA); } } else { SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED); diff --git a/src/Edit.c b/src/Edit.c index 5025334554..7a1568d2aa 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -3871,7 +3871,6 @@ typedef struct _SORTLINE { WCHAR *pwszSortEntry; } SORTLINE; -static FARPROC pfnStrCmpLogicalW; typedef int (__stdcall *FNSTRCMP)(LPCWSTR, LPCWSTR); int CmpStd(const void *s1, const void *s2) { @@ -3885,9 +3884,9 @@ int CmpStdRev(const void *s1, const void *s2) { } int CmpLogical(const void *s1, const void *s2) { - int cmp = (int)pfnStrCmpLogicalW(((SORTLINE *)s1)->pwszSortEntry, ((SORTLINE *)s2)->pwszSortEntry); + int cmp = (int)StrCmpLogicalW(((SORTLINE *)s1)->pwszSortEntry, ((SORTLINE *)s2)->pwszSortEntry); if (cmp == 0) { - cmp = (int)pfnStrCmpLogicalW(((SORTLINE *)s1)->pwszLine, ((SORTLINE *)s2)->pwszLine); + cmp = (int)StrCmpLogicalW(((SORTLINE *)s1)->pwszLine, ((SORTLINE *)s2)->pwszLine); } if (cmp) { return cmp; @@ -3898,9 +3897,9 @@ int CmpLogical(const void *s1, const void *s2) { } int CmpLogicalRev(const void *s1, const void *s2) { - int cmp = -1 * (int)pfnStrCmpLogicalW(((SORTLINE *)s1)->pwszSortEntry, ((SORTLINE *)s2)->pwszSortEntry); + int cmp = -1 * (int)StrCmpLogicalW(((SORTLINE *)s1)->pwszSortEntry, ((SORTLINE *)s2)->pwszSortEntry); if (cmp == 0) { - cmp = -1 * (int)pfnStrCmpLogicalW(((SORTLINE *)s1)->pwszLine, ((SORTLINE *)s2)->pwszLine); + cmp = -1 * (int)StrCmpLogicalW(((SORTLINE *)s1)->pwszLine, ((SORTLINE *)s2)->pwszLine); } if (cmp) { return cmp; @@ -3941,7 +3940,6 @@ void EditSortLines(HWND hwnd, int iSortFlags) { BOOL bLastDup = FALSE; FNSTRCMP pfnStrCmp; - pfnStrCmpLogicalW = GetProcAddress(GetModuleHandle(L"shlwapi"), "StrCmpLogicalW"); pfnStrCmp = (iSortFlags & SORT_NOCASE) ? StrCmpIW : StrCmpW; iCurPos = (int)SendMessage(hwnd, SCI_GETCURRENTPOS, 0, 0); @@ -4054,7 +4052,7 @@ void EditSortLines(HWND hwnd, int iSortFlags) { } if (iSortFlags & SORT_DESCENDING) { - if ((iSortFlags & SORT_LOGICAL) && pfnStrCmpLogicalW) { + if ((iSortFlags & SORT_LOGICAL) && IsWinXPAndAbove()) { qsort(pLines, iLineCount, sizeof(SORTLINE), CmpLogicalRev); } else { qsort(pLines, iLineCount, sizeof(SORTLINE), CmpStdRev); @@ -4071,7 +4069,7 @@ void EditSortLines(HWND hwnd, int iSortFlags) { pLines[j].pwszSortEntry = sLine.pwszSortEntry; } } else { - if ((iSortFlags & SORT_LOGICAL) && pfnStrCmpLogicalW) { + if ((iSortFlags & SORT_LOGICAL) && IsWinXPAndAbove()) { qsort(pLines, iLineCount, sizeof(SORTLINE), CmpLogical); } else { qsort(pLines, iLineCount, sizeof(SORTLINE), CmpStd); @@ -6135,7 +6133,7 @@ INT_PTR CALLBACK EditSortDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lPa CheckDlgButton(hwnd, 106, BST_CHECKED); } - if (GetProcAddress(GetModuleHandle(L"shlwapi"), "StrCmpLogicalW")) { + if (IsWinXPAndAbove()) { if (*piSortFlags & SORT_LOGICAL) { CheckDlgButton(hwnd, 107, BST_CHECKED); } diff --git a/src/Helpers.c b/src/Helpers.c index 7f28f3e6a1..bfd8cb5f75 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -183,8 +183,9 @@ HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR AppID) { return S_OK; } + // since Windows 7 pfnSetCurrentProcessExplicitAppUserModelID = - GetProcAddress(GetModuleHandleA("shell32.dll"), "SetCurrentProcessExplicitAppUserModelID"); + GetProcAddress(GetModuleHandle(L"shell32.dll"), "SetCurrentProcessExplicitAppUserModelID"); if (pfnSetCurrentProcessExplicitAppUserModelID) { return (HRESULT)pfnSetCurrentProcessExplicitAppUserModelID(AppID); @@ -455,8 +456,7 @@ BOOL SetWindowTitle(HWND hwnd, UINT uIDAppName, BOOL bIsElevated, UINT uIDUntitl // void SetWindowTransparentMode(HWND hwnd, BOOL bTransparentMode) { if (bTransparentMode) { - FARPROC fp; - if ((fp = GetProcAddress(GetModuleHandle(L"User32"), "SetLayeredWindowAttributes")) != NULL) { + if (IsWin2KAndAbove()) { int iAlphaPercent; BYTE bAlpha; SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); @@ -468,7 +468,7 @@ void SetWindowTransparentMode(HWND hwnd, BOOL bTransparentMode) { } bAlpha = (BYTE)(iAlphaPercent * 255 / 100); - fp(hwnd, 0, bAlpha, LWA_ALPHA); + SetLayeredWindowAttributes(hwnd, 0, bAlpha, LWA_ALPHA); } } else { SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED); diff --git a/src/Notepad2.c b/src/Notepad2.c index 9bf03e7de6..1f328d8813 100644 --- a/src/Notepad2.c +++ b/src/Notepad2.c @@ -5245,10 +5245,7 @@ void LoadSettings(void) { bAlwaysOnTop = IniSectionGetBool(pIniSection, L"AlwaysOnTop", 0); bMinimizeToTray = IniSectionGetBool(pIniSection, L"MinimizeToTray", 0); bTransparentMode = IniSectionGetBool(pIniSection, L"TransparentMode", 0); - - // Check if SetLayeredWindowAttributes() is available - bTransparentModeAvailable = - (GetProcAddress(GetModuleHandle(L"User32"), "SetLayeredWindowAttributes") != NULL); + bTransparentModeAvailable = IsWin2KAndAbove(); IniSectionGetString(pIniSection, L"ToolbarButtons", L"", tchToolbarButtons, COUNTOF(tchToolbarButtons));