/* ** Entry point. In Release builds, the entry point is Main() since the CRT is not used. ** */ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) { // Prevent system error message boxes. UINT oldMode = SetErrorMode(0); SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); WCHAR* args = GetCommandLineArguments(); HINSTANCE skinInstallerDll = LoadSkinInstallerLibrary(); if (skinInstallerDll) { auto skinInstallerMain = (SkinInstallerMainFunc)GetProcAddress(skinInstallerDll, MAKEINTRESOURCEA(1)); if (skinInstallerMain) { return skinInstallerMain(args); } } WCHAR message[128]; wsprintf( message, L"SkinInstaller.dll load error %ld.", GetLastError()); MessageBox(nullptr, message, L"Skin Installer", MB_OK | MB_ICONERROR); return 1; }
/* ** Entry point. In Release builds, the entry point is Main() since the CRT is not used. ** */ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); //_CrtSetBreakAlloc(000); // Prevent system error message boxes. UINT oldMode = SetErrorMode(0); SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); HINSTANCE instance = (HINSTANCE)&__ImageBase; WCHAR* args = GetCommandLineArguments(); HRSRC iconResource = FindResource(instance, MAKEINTRESOURCE(1), RT_ICON); if (iconResource) { HINSTANCE rmDll = LoadRainmeterLibrary(); if (rmDll) { auto rainmeterMain = (RainmeterMainFunc)GetProcAddress(rmDll, MAKEINTRESOURCEA(1)); if (rainmeterMain) { return rainmeterMain(args); } } WCHAR message[128]; wsprintf( message, L"Rainmeter.dll load error %ld.", GetLastError()); MessageBox(nullptr, message, L"Rainmeter", MB_OK | MB_ICONERROR); } else { // Stub prodecure. If icon resources have been removed, try to launch the actual Rainmeter.exe. HKEY hKey; const REGSAM desiredSam = KEY_QUERY_VALUE | KEY_WOW64_32KEY; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Rainmeter", 0, desiredSam, &hKey) == ERROR_SUCCESS) { const DWORD size = MAX_PATH; WCHAR buffer[size]; DWORD type = 0; if (RegQueryValueEx(hKey, nullptr , nullptr, &type, (LPBYTE)buffer, (LPDWORD)&size) == ERROR_SUCCESS && type == REG_SZ) { SetCurrentDirectory(buffer); lstrcat(buffer, L"\\Rainmeter.exe"); ShellExecute(nullptr, L"open", buffer, args, nullptr, SW_SHOWNORMAL); } RegCloseKey(hKey); } return 0; } return 1; }
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) { #define WIDTH 1 #define LENGTH 260 char command[LENGTH]; if(GetCommandLineArguments(lpCmdLine,(char**)&command,WIDTH,LENGTH) < 1) return 0; char* lpMultiByteStr=command; if(command[0] != '\0') { while(*lpMultiByteStr != ':') { lpMultiByteStr++; if(*lpMultiByteStr == '\0') break; } if(*lpMultiByteStr != '\0') { *lpMultiByteStr = '\0'; lpMultiByteStr++; } if(*lpMultiByteStr == '\0' || lstrcmpi(command,"/ProcessID")!=0) lpMultiByteStr=command; } WCHAR WideCharStr[41]; CLSID clsid; if(MultiByteToWideChar(CP_ACP,0,lpMultiByteStr,lstrlen(lpMultiByteStr)+1,WideCharStr,41) !=0 && CLSIDFromString(WideCharStr,&clsid) >= 0 && CoInitializeEx(NULL,COINIT_MULTITHREADED) >=0 ) { CoRegisterSurrogateEx(clsid,NULL); CoUninitialize(); TerminateProcess(GetCurrentProcess(),0); } return 0; }