This commit is contained in:
Birunthan Mohanathas
2012-06-11 16:15:03 +03:00
parent 2cfbab6314
commit dc07162956
29 changed files with 58 additions and 311 deletions

View File

@ -721,6 +721,8 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
{
InitalizeLitestep();
m_Instance = GetModuleHandle(L"Rainmeter");
WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH];
GetModuleFileName(m_Instance, buffer, MAX_LINE_LENGTH);
@ -773,8 +775,6 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
return 1;
}
m_Instance = GetModuleHandle(L"Rainmeter");
WNDCLASS wc = {0};
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.hInstance = m_Instance;
@ -1215,13 +1215,30 @@ void CRainmeter::CreateComponentFolders(bool defaultIniLocation)
path = m_SettingsPath;
path += L"Rainmeter.exe";
if (_waccess(path.c_str(), 0) == -1)
const WCHAR* pathSz = path.c_str();
if (_waccess(pathSz, 0) == -1)
{
// Create a hidden dummy Rainmeter.exe into SettingsPath for old addon
// Create a hidden stub Rainmeter.exe into SettingsPath for old addon
// using relative path to Rainmeter.exe
std::wstring from = m_Path + L"Launcher.exe";
std::wstring from = m_Path + L"Rainmeter.exe";
CSystem::CopyFiles(from, path);
SetFileAttributes(path.c_str(), FILE_ATTRIBUTE_HIDDEN);
// Get rid of all resources from the stub executable
HANDLE stub = BeginUpdateResource(pathSz, TRUE);
// Add the manifest of Rainmeter.dll to the stub
HRSRC manifest = FindResource(m_Instance, MAKEINTRESOURCE(2), RT_MANIFEST);
DWORD manifestSize = SizeofResource(m_Instance, manifest);
HGLOBAL manifestLoad = LoadResource(m_Instance, manifest);
void* manifestLoadData = LockResource(manifestLoad);
if (manifestLoadData)
{
LANGID langID = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
UpdateResource(stub, RT_MANIFEST, MAKEINTRESOURCE(1), langID, manifestLoadData, manifestSize);
}
EndUpdateResource(stub, FALSE);
SetFileAttributes(pathSz, FILE_ATTRIBUTE_HIDDEN);
}
}
}