int _winstart(void) { char *szCmd; STARTUPINFO startinfo; __set_app_type(__GUI_APP); _controlfp(0x10000, 0x30000); szCmd = GetCommandLine(); if (szCmd) { while (' ' == *szCmd) szCmd++; if ('\"' == *szCmd) { while (*++szCmd) if ('\"' == *szCmd) { szCmd++; break; } } else { while (*szCmd && ' ' != *szCmd) szCmd++; } while (' ' == *szCmd) szCmd++; } GetStartupInfo(&startinfo); exit(WinMain(GetModuleHandle(NULL), NULL, szCmd, (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? startinfo.wShowWindow : SW_SHOWDEFAULT)); }
int main(int argc, char** argv) { if (argc>1) return WinMain(0,0,argv[1],0); else return WinMain(0,0,0,0); }
int main(int argc, char *argv[]) { ZeroMemory(buff,sizeof(buff)/sizeof(char)); printf("%s\n",argv[0]); WinMain(NULL,NULL,argv[0],SW_SHOWNORMAL); printf("%s\n",argv[0]); return 0; }
/*ARGSUSED*/ int main (int __UNUSED_PARAM(flags), char ** __UNUSED_PARAM(cmdline), char ** __UNUSED_PARAM(inst)) { return (int) WinMain (__mingw_winmain_hInstance, NULL, __mingw_winmain_lpCmdLine, __mingw_winmain_nShowCmd); }
void __cdecl WinMainCRTStartup() { STARTUPINFO si; unsigned char *cl; int res; // check and init fpu if required, // exit if required, but not available if (_FPinit && (_FPinit() == 0)) ExitProcess(-2); // call c initialisers if (_initterm(__xi_a, __xi_z, 1)) ExitProcess(-3); // call c++ initialisers _initterm(__xc_a, __xc_z, 0); cl = GetCommandLine(); if (cl == NULL) cl = ""; // parse command line { unsigned char delim = ' '; // skip any leading whitespaces (just in case) while (*cl && *cl <= delim) ++cl; // skip one parameter, which should be the application filename for ( ; *cl > delim; ++cl) { if (*cl == '"') delim ^= ' '; } // skip any whitespaces before first command line argument while (*cl && *cl <= delim) ++cl; } // get startup info on how to show si.dwFlags = 0; GetStartupInfo(&si); // -WCRT- tag __asm { test eax, 0x0a0d0a0d sub eax, 0x54524357 sub eax, 0x0a0d0a0d } // call WinMain res = WinMain( (HINSTANCE)GetModuleHandle(NULL), NULL, (LPSTR)cl, (si.dwFlags & STARTF_USESHOWWINDOW) ? si.wShowWindow : SW_SHOWDEFAULT ); exit(res); }
//----------------------------------------------------------------- // Windows Functions //----------------------------------------------------------------- int _tmain() { // Enable run-time memory leak check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif WinMain(GetModuleHandle(0), 0, 0, SW_SHOW); }
int _tmain(int argc, char* argv[]){ UNREFERENCED_PARAMETER(argc); UNREFERENCED_PARAMETER(argv); //Logger::log("Starting the program"); //Run winmain function WinMain((HINSTANCE)GetModuleHandle(NULL), 0, 0, SW_SHOW); }
int _runwinmain(int argc, char **argv) { char *szCmd = NULL; char *p = GetCommandLine(); if (argc > 1) szCmd = strstr(p, argv[1]); if (NULL == szCmd) szCmd = ""; else if (szCmd > p && szCmd[-1] == '\"') --szCmd; return WinMain(GetModuleHandle(NULL), NULL, szCmd, SW_SHOWDEFAULT); }
int main (int argc, char *argv[], char *environ[]) { char *szCmd; STARTUPINFO startinfo; int nRet; /* Get the command line passed to the process. */ szCmd = GetCommandLineA (); GetStartupInfoA (&startinfo); /* Strip off the name of the application and any leading * whitespace. */ if (szCmd) { while (ISSPACE (*szCmd)) { szCmd++; } /* On my system I always get the app name enclosed * in quotes... */ if (*szCmd == '\"') { do { szCmd++; } while (*szCmd != '\"' && *szCmd != '\0'); if (*szCmd == '\"') { szCmd++; } } else { /* If no quotes then assume first token is program * name. */ while (!ISSPACE (*szCmd) && *szCmd != '\0') { szCmd++; } } while (ISSPACE (*szCmd)) { szCmd++; } } nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd, (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? startinfo.wShowWindow : SW_SHOWDEFAULT); return nRet; }
int __stdcall ___lscrtl_startup(HINSTANCE hInst, DWORD fdwReason, LPVOID lpvReserved) { int flags; int rv; unsigned exceptBlock[2]; char quote; char *cmd; asm mov [flags],edx; quote = 0; ___lsdllinit(flags, _dorundown, exceptBlock); if (!(flags & DLL) || fdwReason == DLL_PROCESS_ATTACH) { if (flags & DLL) { if (!dllexists) dllexists++; else { MessageBox(0,"NonShared data segment required","Error",0); return 1; } } } __srproc(INITSTART, INITEND); if (flags & DLL) { rv = DllEntryPoint(hInst, fdwReason, lpvReserved) + 1; } else if (flags & GUI) { cmd = _oscmd; while ((!quote || *cmd != ' ') && *cmd) { if (*cmd == '"') quote ^= *cmd; cmd++; } while (*cmd && *cmd == ' ') cmd++; rv = WinMain(hInst, 0, cmd, 10) + 1; } else { rv = main(_argc, _argv, _environ) + 1; } if ((flags & DLL) && fdwReason == DLL_PROCESS_DETACH) { __srproc(EXITSTART, EXITEND); } rv--; if (!(flags & DLL)) { _exit(rv); ExitProcess(rv); // needed to satisfy the debugger } return rv; }
/* run_code() - branch over to WinMain(). */ int run_code(int *argc, char **argv[]) { if(*argc > 1) goto usage; FreeConsole(); WinMain(GetModuleHandle(NULL), NULL, **argv, SW_SHOWNORMAL); return 0; usage: fprintf(stdout, "Usage: %s", *argv[0]); return 1; }
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow) { HWND hwnd; MSG messages; WNDCLASSEX wincl; char szClassName[21]; wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; wincl.style = CS_DBLCLKS; wincl.cbSize = sizeof (WNDCLASSEX); wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; if (!RegisterClassEx (&wincl)) return 0; hwnd = CreateWindowEx ( 0, szClassName, "Jodete", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 75, 75, HWND_DESKTOP, NULL, hThisInstance, NULL ); ShowWindow (hwnd, nCmdShow); while (GetMessage (&messages, NULL, 0, 0)) { TranslateMessage(&messages); DispatchMessage(&messages); } WinMain (hThisInstance, hPrevInstance, lpszArgument, nCmdShow); return messages.wParam; }
int main() { // Get command line, go over program name char *pCommandLine = GetCommandLine(); if (*pCommandLine == '"') { pCommandLine++; while (*pCommandLine && *pCommandLine != '"') pCommandLine++; if (*pCommandLine == '"') pCommandLine++; } else while (*pCommandLine && *pCommandLine != ' ') pCommandLine++; while (*pCommandLine == ' ') pCommandLine++; // Call return WinMain(GetModuleHandle(NULL), 0, pCommandLine, 0); }
int main() { welcome(); #ifdef ANY_WHERE_STEPDBG printf("注意:启用了全局调试开关.\n"); #endif #ifdef __WIN32__ HINSTANCE hInstance = GetModuleHandle(NULL); WinMain(hInstance, NULL, NULL, SW_SHOW); #endif // system("pause"); return 0; }
int main(int ac,char **av) { /* call user hook routine before anything*/ if(MwUserInit(ac, av) < 0) exit(1); if(MwOpen() < 0) exit(1); /* call windows main program entry point*/ WinMain(NULL, NULL, NULL, SW_SHOW); MwClose(); return 0; }
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { switch ( ul_reason_for_call ) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: WinMain( hInst, 0, "", SW_SHOW ); break; case DLL_PROCESS_DETACH: case DLL_THREAD_DETACH: break; } return TRUE; }
int main(int ac,char *av[]) { char buf[256]; int i; HINSTANCE inst; inst=(HINSTANCE)GetModuleHandle(NULL); buf[0]=0; for(i=1; i<ac; i++) { strcat_s(buf, 256, av[i]); strcat_s(buf, 256, " "); } return WinMain(inst,NULL,buf,SW_SHOWNORMAL); }
int _tmain(int argc, TCHAR *argv[]) { int i; TCHAR param[256]; if (argc > 1) { _tcscpy(param, argv[1]); for (i = 2; i < argc; i++) { _tcscat(param, _T(" ")); _tcscat(param, argv[i]); } } else param[0] = '\0'; return WinMain(GetModuleHandle(NULL), NULL, param, SW_NORMAL); }
int main(int ac,char *av[]) { int i; char buf[4096]; buf[0]=0; for(i=1; i<ac; i++) { strcat(buf,"\""); strcat(buf,av[i]); strcat(buf,"\""); } HINSTANCE inst; inst=(HINSTANCE)GetModuleHandle(NULL); return WinMain(inst,NULL,buf,SW_SHOWNORMAL); //return WinMain(inst,NULL,buf,SW_SHOWMAXIMIZED); }
/* Allow apps which don't have a main work, as long as they define WinMain */ int main () { HMODULE x = GetModuleHandleA(0); char *s = GetCommandLineA (); STARTUPINFO si; /* GetCommandLineA returns the entire command line including the program name, but WinMain is defined to accept the command line without the program name. */ while (*s != ' ' && *s != '\0') ++s; while (*s == ' ') ++s; GetStartupInfo (&si); return WinMain (x, 0, s, ((si.dwFlags & STARTF_USESHOWWINDOW) != 0 ? si.wShowWindow : SW_SHOWNORMAL)); }
int main( int argc, char *argv [] ) { HINSTANCE hInstance; LPSTR lpszCmdParam; int i, len = 0; _ARGC = argc; _ARGV = (char **)argv; if (!(hInstance = MAIN_WinelibInit( &argc, argv ))) return 0; /* Alloc szCmdParam */ for (i = 1; i < argc; i++) len += strlen(argv[i]) + 1; lpszCmdParam = (LPSTR) xmalloc(len + 1); /* Concatenate arguments */ if (argc > 1) strcpy(lpszCmdParam, argv[1]); else lpszCmdParam[0] = '\0'; for (i = 2; i < argc; i++) strcat(strcat(lpszCmdParam, " "), argv[i]); return WinMain (hInstance, /* hInstance */ 0, /* hPrevInstance */ lpszCmdParam, /* lpszCmdParam */ SW_NORMAL); /* nCmdShow */ }
//----------------------------------------------------------------- // Entry Point Functions //----------------------------------------------------------------- //used if console subsystem void main() { WinMain(0,0,0,0); }
int main(int argc, char *argv) { return WinMain(NULL, NULL, NULL, 0); }
extern "C" int WinMainCRTStartup() { ExitProcess(WinMain(NULL, NULL, NULL, SW_SHOWDEFAULT)); }
int main(int argc, char *argv[]) { WinMain(NULL, NULL, NULL, SW_SHOW ); return 0; }
//----------------------------------------------------------------- // Windows Functions //----------------------------------------------------------------- int _tmain() { WinMain(GetModuleHandle(0), 0, 0, SW_SHOW); }
int QtWinMainCRTStartup() { #ifdef __MSVCRT__ __set_app_type (__GUI_APP); #endif SetUnhandledExceptionFilter (_gnu_exception_handler); /* * Initialize floating point unit. */ _fpreset (); /* Supplied by the runtime library. */ /* * Sets the default file mode. * If _CRT_fmode is set, also set mode for stdin, stdout * and stderr, as well * NOTE: DLLs don't do this because that would be rude! */ _mingw32_init_fmode (); /* Adust references to dllimported data that have non-zero offsets. */ _pei386_runtime_relocator (); char *szCmd; STARTUPINFO startinfo; int nRet; /* Get the command line passed to the process. */ szCmd = GetCommandLineA (); GetStartupInfo (&startinfo); /* Strip off the name of the application and any leading * whitespace. */ if (szCmd) { while (ISSPACE (*szCmd)) { szCmd++; } /* On my system I always get the app name enclosed * in quotes... */ if (*szCmd == '\"') { do { szCmd++; } while (*szCmd != '\"' && *szCmd != '\0'); if (*szCmd == '\"') { szCmd++; } } else { /* If no quotes then assume first token is program * name. */ while (!ISSPACE (*szCmd) && *szCmd != '\0') { szCmd++; } } while (ISSPACE (*szCmd)) { szCmd++; } } nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd, (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? startinfo.wShowWindow : SW_SHOWDEFAULT); /* * Perform exit processing for the C library. This means * flushing output and calling 'atexit' registered functions. */ _cexit (); ExitProcess (nRet); return 0; }
/* * routine in DLL to do initialization (in this case, C++ constructors) */ extern void __cdecl _initterm(_PVFV *, _PVFV *); #ifdef _WINMAIN_ #ifdef WPRFLAG int wWinMainCRTStartup( #else /* WPRFLAG */ int WinMainCRTStartup( #endif /* WPRFLAG */ #else /* _WINMAIN_ */ #ifdef WPRFLAG int wmainCRTStartup( #else /* WPRFLAG */ int mainCRTStartup( #endif /* WPRFLAG */ #endif /* _WINMAIN_ */ void ) { int argc = 0; /* three standard arguments to main */ _TSCHAR **argv = NULL; _TSCHAR **envp = NULL; int argret = 0; #ifdef _WINMAIN_ _TUCHAR *lpszCommandLine; STARTUPINFO StartupInfo; #endif /* _WINMAIN_ */ #ifdef WPRFLAG int envp_count = 0; #endif //_startupinfo startinfo; /* * Determine if this is a managed application */ //managedapp = check_managed_app(); /* * Set __app_type properly */ #ifdef _WINMAIN_ //__set_app_type(_GUI_APP); #else /* _WINMAIN_ */ //__set_app_type(_CONSOLE_APP); #endif /* _WINMAIN_ */ #ifdef _WINMAIN_ #ifdef WPRFLAG dbgmsg("wWinMainCRTStartup()"); #else dbgmsg("WinMainCRTStartup()"); #endif #else #ifdef WPRFLAG dbgmsg("wmainCRTStartup()"); #else dbgmsg("mainCRTStartup()"); #endif #endif /* * Mark this module as an EXE file so that atexit/_onexit * will do the right thing when called, including for C++ * d-tors. */ __onexitbegin = __onexitend = (_PVFV *)(-1); dbgmsg("OK1b"); /* * Propogate the _fmode and _commode variables to the DLL * (crash in crtdll.dll...?) */ //*_IMP___FMODE = _fmode; dbgmsg("OK1c"); //*_IMP___COMMODE = _commode; dbgmsg("OK1d"); #ifdef _M_IX86 /* * Set the local copy of the Pentium FDIV adjustment flag * (not supported by crtdll.dll) */ //_adjust_fdiv = * _imp___adjust_fdiv; #endif /* _M_IX86 */ dbgmsg("OK2"); /* * Run the RTC initialization code for this DLL */ #ifdef _RTC _RTC_Initialize(); #endif /* _RTC */ /* * Call _setargv(), which will trigger a call to __setargv() if * SETARGV.OBJ is linked with the EXE. If SETARGV.OBJ is not * linked with the EXE, a dummy _setargv() will be called. */ #ifdef WPRFLAG //_wsetargv(); #else /* WPRFLAG */ //_setargv(); #endif /* WPRFLAG */ /* * If the user has supplied a _matherr routine then set * __pusermatherr to point to it. */ // if ( !__defaultmatherr ) // __setusermatherr(_matherr); #ifdef _M_IX86 //_setdefaultprecision(); #endif /* _M_IX86 */ /* * Do runtime startup initializers. * * Note: the only possible entry we'll be executing here is for * __lconv_init, pulled in from charmax.obj only if the EXE was * compiled with -J. All other .CRT$XI* initializers are only * run as part of the CRT itself, and so for the CRT DLL model * are not found in the EXE. For that reason, we call _initterm, * not _initterm_e, because __lconv_init will never return failure, * and _initterm_e is not exported from the CRT DLL. * * Note further that, when using the CRT DLL, executing the * .CRT$XI* initializers is only done for an EXE, not for a DLL * using the CRT DLL. That is to make sure the -J setting for * the EXE is not overriden by that of any DLL. */ //_initterm( __xi_a, __xi_z ); #ifdef _RTC atexit(_RTC_Terminate); #endif /* _RTC */ /* * Get the arguments for the call to main. Note this must be * done explicitly, rather than as part of the dll's * initialization, to implement optional expansion of wild * card chars in filename args */ dbgmsg("OK3"); //startinfo.newmode = 0; #ifdef WPRFLAG _wcmdln = GetCommandLineW(); argv = (_TSCHAR**)CommandLineToArgvW(_wcmdln, &argc); if (argv == NULL) FatalAppExitA(0, "This application requires Windows NT."); _wpgmptr = (wchar_t*)argv[0]; __wargv = (wchar_t**)argv; __argc = argc; _wenviron[0] = GetEnvironmentStringsW(); while ((_wenviron[envp_count][0] != 0) & (envp_count < MAX_WENVIRON_COUNT)) { _wenviron[envp_count+1] = _wenviron[envp_count]+ wcslen(_wenviron[envp_count])+1; envp_count++; } if ((argv == NULL) | (envp_count >= MAX_WENVIRON_COUNT)) argret = -1; if (argret < 0) _amsg_exit(_RT_SPACEARG); _wenviron[envp_count] = NULL; envp = (_TSCHAR**)_wenviron; #else /* WPRFLAG */ argret = __GetMainArgs(&argc, &argv, &envp, 0, NULL /*&startinfo*/); if (argv == NULL) _amsg_exit(_RT_SPACEARG); __argc = argc; __argv = argv; _environ = envp; _pgmptr = argv[0]; #endif dbgmsg("OK4"); /* * do C++ constructors (initializers) specific to this EXE */ //_initterm( __xc_a, __xc_z ); #ifdef _WINMAIN_ /* * Skip past program name (first token in command line). * Check for and handle quoted program name. */ #ifdef WPRFLAG /* OS may not support "W" flavors */ if (_wcmdln == NULL) FatalAppExitA(0, "This application requires Windows NT."); lpszCommandLine = (wchar_t *)_wcmdln; #else /* WPRFLAG */ lpszCommandLine = (unsigned char *)_acmdln; #endif /* WPRFLAG */ if ( *lpszCommandLine == DQUOTECHAR ) { /* * Scan, and skip over, subsequent characters until * another double-quote or a null is encountered. */ while ( *++lpszCommandLine && (*lpszCommandLine != DQUOTECHAR) ); /* * If we stopped on a double-quote (usual case), skip * over it. */ if ( *lpszCommandLine == DQUOTECHAR ) lpszCommandLine++; } while (*lpszCommandLine > SPACECHAR) lpszCommandLine++; if (*lpszCommandLine >= SPACECHAR) lpszCommandLine++; dbgmsg("OK5"); /* * Skip past any white space preceeding the second token. */ while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR)) { lpszCommandLine++; } StartupInfo.dwFlags = 0; GetStartupInfo( &StartupInfo ); #ifdef WPRFLAG __winitenv = (wchar_t**)envp; exit(wWinMain( #else /* WPRFLAG */ __initenv = envp; exit(WinMain( #endif /* WPRFLAG */ GetModuleHandleA(NULL), NULL, (LPTSTR)lpszCommandLine, StartupInfo.dwFlags & STARTF_USESHOWWINDOW ? StartupInfo.wShowWindow : SW_SHOWDEFAULT )); #else /* _WINMAIN_ */ #ifdef WPRFLAG dbgmsg("OK6"); exit(wmain(argc, (wchar_t**)argv, (wchar_t**)envp)); #else /* WPRFLAG */ dbgmsg("OK6"); exit(main(argc, argv, envp)); #endif /* WPRFLAG */ #endif /* _WINMAIN_ */ }
int main() { return WinMain(GetModuleHandle(NULL), NULL, NULL, SW_SHOW); }
int main() { WinMain( GetModuleHandle(NULL), NULL, GetCommandLine(), SW_NORMAL ); return 0; }