1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-27 17:00:59 +01:00

Moved QueryVersion API to separate file

This commit is contained in:
Valentin Radu 2021-11-05 03:59:01 +02:00
parent 3d09b046cf
commit 9d3d916645
5 changed files with 45 additions and 33 deletions

View File

@ -213,7 +213,11 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_window.c" />
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_window.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_WindowHelpers.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@ -287,6 +291,7 @@
<ClInclude Include="HideExplorerSearchBar.h" />
<ClInclude Include="hooking.h" />
<ClInclude Include="ep_private.h" />
<ClInclude Include="queryversion.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="SettingsMonitor.h" />
<ClInclude Include="StartMenu.h" />

View File

@ -105,6 +105,9 @@
<ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_utility.h">
<Filter>Header Files\sws</Filter>
</ClInclude>
<ClInclude Include="queryversion.h">
<Filter>Header Files\internal</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ExplorerPatcher.rc">

View File

@ -0,0 +1,35 @@
#ifndef _H_QUERYVERSION_H_
#define _H_QUERYVERSION_H_
#include <Windows.h>
#pragma comment(lib, "Version.lib")
inline void QueryVersionInfo(HMODULE hModule, WORD Resource, DWORD* dwLeftMost, DWORD* dwSecondLeft, DWORD* dwSecondRight, DWORD* dwRightMost)
{
HRSRC hResInfo;
DWORD dwSize;
HGLOBAL hResData;
LPVOID pRes, pResCopy;
UINT uLen;
VS_FIXEDFILEINFO* lpFfi;
hResInfo = FindResource(hModule, MAKEINTRESOURCE(Resource), RT_VERSION);
dwSize = SizeofResource(hModule, hResInfo);
hResData = LoadResource(hModule, hResInfo);
pRes = LockResource(hResData);
pResCopy = LocalAlloc(LMEM_FIXED, dwSize);
CopyMemory(pResCopy, pRes, dwSize);
FreeResource(hResData);
VerQueryValue(pResCopy, TEXT("\\"), (LPVOID*)&lpFfi, &uLen);
DWORD dwFileVersionMS = lpFfi->dwFileVersionMS;
DWORD dwFileVersionLS = lpFfi->dwFileVersionLS;
*dwLeftMost = HIWORD(dwFileVersionMS);
*dwSecondLeft = LOWORD(dwFileVersionMS);
*dwSecondRight = HIWORD(dwFileVersionLS);
*dwRightMost = LOWORD(dwFileVersionLS);
LocalFree(pResCopy);
}
#endif

View File

@ -387,36 +387,6 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight, BOO
return point;
}
void QueryVersionInfo(HMODULE hModule, WORD Resource, DWORD* dwLeftMost, DWORD* dwSecondLeft, DWORD* dwSecondRight, DWORD* dwRightMost)
{
HRSRC hResInfo;
DWORD dwSize;
HGLOBAL hResData;
LPVOID pRes, pResCopy;
UINT uLen;
VS_FIXEDFILEINFO* lpFfi;
hResInfo = FindResource(hModule, MAKEINTRESOURCE(Resource), RT_VERSION);
dwSize = SizeofResource(hModule, hResInfo);
hResData = LoadResource(hModule, hResInfo);
pRes = LockResource(hResData);
pResCopy = LocalAlloc(LMEM_FIXED, dwSize);
CopyMemory(pResCopy, pRes, dwSize);
FreeResource(hResData);
VerQueryValue(pResCopy, TEXT("\\"), (LPVOID*)&lpFfi, &uLen);
DWORD dwFileVersionMS = lpFfi->dwFileVersionMS;
DWORD dwFileVersionLS = lpFfi->dwFileVersionLS;
*dwLeftMost = HIWORD(dwFileVersionMS);
*dwSecondLeft = LOWORD(dwFileVersionMS);
*dwSecondRight = HIWORD(dwFileVersionLS);
*dwRightMost = LOWORD(dwFileVersionLS);
LocalFree(pResCopy);
}
void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize)
{
void* ok = NULL;

View File

@ -14,6 +14,7 @@
#pragma comment(lib, "Rstrtmgr.lib")
#define _LIBVALINET_INCLUDE_UNIVERSAL
#include <valinet/universal/toast/toast.h>
#include "queryversion.h"
#define APPID L"Microsoft.Windows.Explorer"
#define REGPATH "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ExplorerPatcher"
@ -104,8 +105,6 @@ __declspec(dllexport) CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hIns
POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight, BOOL bAdjust);
void QueryVersionInfo(HMODULE hModule, WORD Resource, DWORD*, DWORD*, DWORD*, DWORD*);
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))