@@ -80,7 +80,7 @@ int runner()
80
80
catch (std::runtime_error& err)
81
81
{
82
82
std::string err_what = err.what ();
83
- MessageBoxW (NULL , std::wstring (err_what.begin (), err_what.end ()).c_str (), L" Error " , MB_OK | MB_ICONERROR);
83
+ MessageBoxW (nullptr , std::wstring (err_what.begin (), err_what.end ()).c_str (), GET_RESOURCE_STRING (IDS_ERROR). c_str () , MB_OK | MB_ICONERROR | MB_SETFOREGROUND );
84
84
result = -1 ;
85
85
}
86
86
Trace::UnregisterProvider ();
@@ -92,8 +92,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
92
92
WCHAR username[UNLEN + 1 ];
93
93
DWORD username_length = UNLEN + 1 ;
94
94
GetUserNameW (username, &username_length);
95
- auto runner_mutex = CreateMutexW (NULL , TRUE , (std::wstring (L" Local\\ PowerToyRunMutex" ) + username).c_str ());
96
- if (runner_mutex == NULL || GetLastError () == ERROR_ALREADY_EXISTS)
95
+ auto runner_mutex = CreateMutexW (nullptr , TRUE , (std::wstring (L" Local\\ PowerToyRunMutex" ) + username).c_str ());
96
+ if (runner_mutex == nullptr || GetLastError () == ERROR_ALREADY_EXISTS)
97
97
{
98
98
// The app is already running
99
99
return 0 ;
@@ -124,7 +124,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
124
124
catch (std::runtime_error& err)
125
125
{
126
126
std::string err_what = err.what ();
127
- MessageBoxW (NULL , std::wstring (err_what.begin (), err_what.end ()).c_str (), GET_RESOURCE_STRING (IDS_ERROR).c_str (), MB_OK | MB_ICONERROR);
127
+ MessageBoxW (nullptr , std::wstring (err_what.begin (), err_what.end ()).c_str (), GET_RESOURCE_STRING (IDS_ERROR).c_str (), MB_OK | MB_ICONERROR);
128
128
result = -1 ;
129
129
}
130
130
ReleaseMutex (runner_mutex);
@@ -135,7 +135,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
135
135
{
136
136
auto text = is_process_elevated () ? GET_RESOURCE_STRING (IDS_COULDNOT_RESTART_NONELEVATED) :
137
137
GET_RESOURCE_STRING (IDS_COULDNOT_RESTART_ELEVATED);
138
- MessageBoxW (NULL , text.c_str (), GET_RESOURCE_STRING (IDS_ERROR).c_str (), MB_OK | MB_ICONERROR);
138
+ MessageBoxW (nullptr , text.c_str (), GET_RESOURCE_STRING (IDS_ERROR).c_str (), MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
139
+
140
+ restart_same_elevation ();
139
141
result = -1 ;
140
142
}
141
143
}
0 commit comments