#include
typedef void (__cdecl *_PVFV)(void);
#pragma data_seg(".CRT$XCA")
_PVFV __xc_a[] = { NULL };
#pragma data_seg(".CRT$XCZ")
_PVFV __xc_z[] = { NULL };
#pragma data_seg() /* reset */
#pragma comment(linker, "/merge:.CRT=.data")
void __cdecl _initterm (
_PVFV * pfbegin,
_PVFV * pfend
)
{
/*
* walk the table of function pointers from the bottom up, until
* the end is encountered. Do not skip the first entry. The initial
* value of pfbegin points to the first valid entry. Do not try to
* execute what pfend points to. Only entries before pfend are valid.
*/
while ( pfbegin < pfend )
{
// if current table entry is non-NULL, call thru it.
if ( *pfbegin != NULL )
(**pfbegin)();
++pfbegin;
}
}
extern "C" void __cdecl tinyWinMainCRTStartup( void )
{
int mainret;
char *lpszCommandLine;
STARTUPINFO StartupInfo;
lpszCommandLine = GetCommandLine();
// Skip past program name (first token in command line).
if ( *lpszCommandLine == '"' ) // Check for and handle quoted program name
{
// Scan, and skip over, subsequent characters until another
// double-quote or a null is encountered
while( *lpszCommandLine && (*lpszCommandLine != '"') )
lpszCommandLine++;
// If we stopped on a double-quote (usual case), skip over it.
if ( *lpszCommandLine == '"' )
lpszCommandLine++;
}
else // First token wasn't a quote
{
while ( *lpszCommandLine > ' ' )
lpszCommandLine++;
}
// Skip past any white space preceeding the second token.
while ( *lpszCommandLine && (*lpszCommandLine lpszCommandLine++;
StartupInfo.dwFlags = 0;
GetStartupInfo( &StartupInfo );
// Call C++ constructors
_initterm( __xc_a, __xc_z );
mainret = WinMain( GetModuleHandle(NULL),
NULL,
lpszCommandLine,
StartupInfo.dwFlags & STARTF_USESHOWWINDOW
? StartupInfo.wShowWindow : SW_SHOWDEFAULT );
//除去ExitProcess函数的调用,以便壳运行之后仍可使程序继续执行
//ExitProcess(0);
}