获取并解析命令行参数

#include <Windows.h>
#include <ShellAPI.h>
#include <tchar.h>
#include <assert.h>
#include <atltrace.h>

#define WIN32_LEAN_AND_MEAN

#ifdef _DEBUG
#pragma comment(lib, "atlsd.lib")
#define TRACE ATLTRACE
#define ASSERT assert
#endif // _DEBUG



INT WINAPI _tWinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, 
				   __in_opt LPTSTR lpCmdLine, __in int nShowCmd )
{	
	int nNumArgs;
	LPTSTR *ppArgv = CommandLineToArgvW(GetCommandLine(),&nNumArgs);
	
	for (int i=0; i<nNumArgs; i++)
	{
		TRACE("Arg%d:%S.\n", i, ppArgv[i]);
	}
	return 0;
}

posted @ 2011-09-14 16:56  SaikSy  阅读(249)  评论(0编辑  收藏  举报