mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-27 17:00:59 +01:00
GUI loads UI file from DLL folder, if available
This commit is contained in:
parent
fa13354597
commit
74b6bb34b4
@ -1,5 +1,7 @@
|
||||
#include "GUI.h"
|
||||
|
||||
void* GUI_FileMapping = NULL;
|
||||
DWORD GUI_FileSize = 0;
|
||||
BOOL g_darkModeEnabled = FALSE;
|
||||
static void(*RefreshImmersiveColorPolicyState)() = NULL;
|
||||
static int(*SetPreferredAppMode)(int bAllowDark) = NULL;
|
||||
@ -93,28 +95,39 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
||||
|
||||
RECT rc;
|
||||
GetClientRect(hwnd, &rc);
|
||||
HRSRC hRscr = FindResource(
|
||||
hModule,
|
||||
MAKEINTRESOURCE(IDR_REGISTRY1),
|
||||
RT_RCDATA
|
||||
);
|
||||
if (!hRscr)
|
||||
|
||||
PVOID pRscr = NULL;
|
||||
DWORD cbRscr = 0;
|
||||
if (GUI_FileMapping && GUI_FileSize)
|
||||
{
|
||||
return FALSE;
|
||||
pRscr = GUI_FileMapping;
|
||||
cbRscr = GUI_FileSize;
|
||||
}
|
||||
HGLOBAL hgRscr = LoadResource(
|
||||
hModule,
|
||||
hRscr
|
||||
);
|
||||
if (!hgRscr)
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
HRSRC hRscr = FindResource(
|
||||
hModule,
|
||||
MAKEINTRESOURCE(IDR_REGISTRY1),
|
||||
RT_RCDATA
|
||||
);
|
||||
if (!hRscr)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
HGLOBAL hgRscr = LoadResource(
|
||||
hModule,
|
||||
hRscr
|
||||
);
|
||||
if (!hgRscr)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
pRscr = LockResource(hgRscr);
|
||||
cbRscr = SizeofResource(
|
||||
hModule,
|
||||
hRscr
|
||||
);
|
||||
}
|
||||
PVOID pRscr = LockResource(hgRscr);
|
||||
DWORD cbRscr = SizeofResource(
|
||||
hModule,
|
||||
hRscr
|
||||
);
|
||||
|
||||
LOGFONT logFont;
|
||||
memset(&logFont, 0, sizeof(logFont));
|
||||
@ -1412,6 +1425,41 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
wchar_t wszPath[MAX_PATH];
|
||||
ZeroMemory(
|
||||
wszPath,
|
||||
(MAX_PATH) * sizeof(char)
|
||||
);
|
||||
GetModuleFileNameW(hModule, wszPath, MAX_PATH);
|
||||
PathRemoveFileSpecW(wszPath);
|
||||
wcscat_s(
|
||||
wszPath,
|
||||
MAX_PATH,
|
||||
L"\\settings.reg"
|
||||
);
|
||||
wprintf(L"%s\n", wszPath);
|
||||
if (FileExistsW(wszPath))
|
||||
{
|
||||
HANDLE hFile = CreateFileW(
|
||||
wszPath,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
0
|
||||
);
|
||||
if (hFile)
|
||||
{
|
||||
HANDLE hFileMapping = CreateFileMappingW(hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
|
||||
if (hFileMapping)
|
||||
{
|
||||
GUI_FileMapping = MapViewOfFile(hFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
||||
GUI_FileSize = GetFileSize(hFile, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("Started \"GUI\" thread.\n");
|
||||
|
||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
@ -1434,7 +1482,6 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin
|
||||
_this.dwStatusbarY = 0;
|
||||
_this.hIcon = NULL;
|
||||
|
||||
wchar_t wszPath[MAX_PATH];
|
||||
ZeroMemory(
|
||||
wszPath,
|
||||
(MAX_PATH) * sizeof(wchar_t)
|
||||
|
@ -99,6 +99,18 @@ const IActivationFactoryAA XamlExtensionsFactory = {
|
||||
};
|
||||
#pragma endregion
|
||||
|
||||
int FileExistsW(wchar_t* file)
|
||||
{
|
||||
WIN32_FIND_DATAW FindFileData;
|
||||
HANDLE handle = FindFirstFileW(file, &FindFileData);
|
||||
int found = handle != INVALID_HANDLE_VALUE;
|
||||
if (found)
|
||||
{
|
||||
FindClose(handle);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void printf_guid(GUID guid)
|
||||
{
|
||||
printf("Guid = {%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}\n",
|
||||
|
@ -75,6 +75,8 @@ typedef struct _IActivationFactoryAA
|
||||
extern const IActivationFactoryAA XamlExtensionsFactory;
|
||||
#pragma endregion
|
||||
|
||||
int FileExistsW(wchar_t* file);
|
||||
|
||||
// https://stackoverflow.com/questions/1672677/print-a-guid-variable
|
||||
void printf_guid(GUID guid);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user