3 Launcher stub for tlmgr gui (with hidden console window)
5 //////////////////////////////////////////////////
7 This version has been replaced with a version which triggers a UAC
8 prompt when appropriate. See Master/source/tlmgr-gui_UAC.zip.
10 //////////////////////////////////////////////////
12 Originally written in 2011 by Tomasz M. Trzeciak, Public Domain
14 compiling with gcc (size optimized):
15 echo 1 ICON "tlmgr-gui.ico">tlmgr-gui.rc
16 windres tlmgr-gui.rc tlmgr-gui-rc.o
17 gcc -Os -s -mwindows -o tlmgr-gui.exe tlmgr-gui-rc.o tlmgr-gui.c
19 compiling with tcc (ver. 0.9.25), extra small size
20 windres tlmgr-gui.rc tlmgr-gui-rc.o
21 tcc -o tlmgr-gui.exe tlmgr-gui-rc.o tlmgr-gui.c
27 static char msgbuf[4*MAX_PATH];
29 _snprintf( msgbuf, 4*MAX_PATH, __VA_ARGS__ ); \
30 MessageBox( NULL, msgbuf, "ERROR!", MB_ICONERROR | MB_SETFOREGROUND );\
34 static char cmdln[2*MAX_PATH];
36 int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShowint ) {
38 // get file name of this executable
40 static char selfdir[MAX_PATH];
42 DWORD nchars = GetModuleFileName(NULL, selfdir, MAX_PATH);
43 if ( !nchars || (nchars == MAX_PATH) ) DIE( "cannot get own path" );
45 // make command to execute
47 if ( s = strrchr(selfdir, '\\') ) *s = '\0'; // remove file name part
48 strcat( cmdln, "\"" );
49 strcat( cmdln, selfdir );
50 strcat( cmdln, "\\tlmgr.bat\" -gui" );
52 // create child process
55 PROCESS_INFORMATION pi;
56 ZeroMemory( &si, sizeof(si) );
58 si.dwFlags = STARTF_USESHOWWINDOW;
59 si.wShowWindow = SW_HIDE ;
60 ZeroMemory( &pi, sizeof(pi) );
63 NULL, // module name (uses command line if NULL)
64 cmdln, // command line
65 NULL, // process security atrributes
66 NULL, // thread security atrributes
67 TRUE, // handle inheritance
68 0, // creation flags, e.g. CREATE_NEW_CONSOLE, CREATE_NO_WINDOW, DETACHED_PROCESS
69 NULL, // pointer to environment block (uses parent if NULL)
70 NULL, // starting directory (uses parent if NULL)
71 &si, // STARTUPINFO structure
72 &pi ) // PROCESS_INFORMATION structure
73 ) DIE( "command execution failed: %s", cmdln );