1
0
Fork 0

Style changes.

This commit is contained in:
GLindor 2016-02-21 19:46:51 -05:00
parent 964e0731f3
commit efd85800d1
1 changed files with 22 additions and 22 deletions

View File

@ -174,33 +174,33 @@ static bool BrowseFileOpen(HWND owner, const wchar_t* filter, const wchar_t* def
static BOOL RegisterShellExtension(const wchar_t* key, const wchar_t* command)
{
HKEY hKey;
BOOL result = TRUE;
BOOL result = TRUE;
if(RegCreateKeyW(HKEY_CLASSES_ROOT, key, &hKey) != ERROR_SUCCESS)
{
MessageBoxW(0, L"RegCreateKeyA failed!", L"Running as Admin?", MB_ICONERROR);
return !result;
}
if (RegSetValueExW(hKey, 0, 0, REG_EXPAND_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS)
{
MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR);
result = !result;
}
if(RegSetValueExW(hKey, 0, 0, REG_EXPAND_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS)
{
MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR);
result = !result;
}
RegCloseKey(hKey);
return result;
return result;
}
static void AddIcon(const wchar_t* key, const wchar_t* command)
{
HKEY pKey;
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, key, 0, KEY_ALL_ACCESS, &pKey) != ERROR_SUCCESS)
MessageBoxW(0, L"RegOpenKeyExW Failed!", L"Running as Admin?", MB_ICONERROR);
HKEY pKey;
if(RegOpenKeyExW(HKEY_CLASSES_ROOT, key, 0, KEY_ALL_ACCESS, &pKey) != ERROR_SUCCESS)
MessageBoxW(0, L"RegOpenKeyExW Failed!", L"Running as Admin?", MB_ICONERROR);
if (RegSetValueExW(pKey, L"Icon", 0, REG_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS)
MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR);
if(RegSetValueExW(pKey, L"Icon", 0, REG_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS)
MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR);
RegCloseKey(pKey);
return;
RegCloseKey(pKey);
return;
}
static void CreateUnicodeFile(const wchar_t* file)
@ -369,14 +369,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
}
if(MessageBoxW(0, L"Do you want to register a shell extension?", L"Question", MB_YESNO | MB_ICONQUESTION) == IDYES)
{
wchar_t szLauncherCommand[MAX_PATH] = L"";
wchar_t szIconCommand[MAX_PATH] = L"";
wchar_t szLauncherCommand[MAX_PATH] = L"";
wchar_t szIconCommand[MAX_PATH] = L"";
swprintf_s(szLauncherCommand, _countof(szLauncherCommand), L"\"%s\" \"%%1\"", szModulePath);
swprintf_s(szIconCommand, _countof(szIconCommand), L"\"%s\",0", szModulePath);
if (RegisterShellExtension(SHELLEXT_EXE_KEY, szLauncherCommand))
AddIcon(SHELLEXT_ICON_EXE_KEY, szIconCommand);
if (RegisterShellExtension(SHELLEXT_DLL_KEY, szLauncherCommand))
AddIcon(SHELLEXT_ICON_DLL_KEY, szIconCommand);
swprintf_s(szIconCommand, _countof(szIconCommand), L"\"%s\",0", szModulePath);
if(RegisterShellExtension(SHELLEXT_EXE_KEY, szLauncherCommand))
AddIcon(SHELLEXT_ICON_EXE_KEY, szIconCommand);
if(RegisterShellExtension(SHELLEXT_DLL_KEY, szLauncherCommand))
AddIcon(SHELLEXT_ICON_DLL_KEY, szIconCommand);
}
if(bDoneSomething)
MessageBoxW(0, L"New configuration written!", L"Done!", MB_ICONINFORMATION);