#include "stdafx.h"#include <Windows.h>#include <string.h>const int MAXPATHLEN=256;int _tmain(int argc, _TCHAR* argv[]){ TCHAR * appPath=new TCHAR[MAXPATHLEN]; memset(appPath,0,sizeof(TCHAR)*MAXPATHLEN); if ( !GetModuleFileName(NULL,appPath,MAXPATHLEN)) { _tprintf(_T("GetModuleFileName failed. (%d)\n"),GetLastError()); } else { (_tcsrchr(appPath, _T('\\')))[1] = 0; _stprintf(appPath,_T("%scmd.exe"),appPath); _tprintf(_T("%s"),appPath); } delete []appPath; appPath=NULL; return 0;}
转载于:https://www.cnblogs.com/chenheng0056/p/3460203.html