win32_exec.h (461B)
1 #pragma once 2 3 #include <windows.h> 4 #include <shellapi.h> 5 6 #include "log.h" 7 8 #pragma warning( push ) 9 #pragma warning( disable : 4302 ) 10 #pragma warning( disable : 4311 ) 11 12 inline void exec_and_quit( const char * path, char * command_line = NULL ) { 13 int ok = int( ShellExecute( NULL, "runas", path, command_line, NULL, SW_SHOWDEFAULT ) ); 14 if( ok == SE_ERR_ACCESSDENIED ) 15 return; 16 if( ok <= 32 ) 17 FATAL( "ShellExecute" ); 18 19 exit( 0 ); 20 } 21 22 #pragma warning( pop )