2023年8月1日发(作者:)
Windows编程-做⼀个简单的命令⾏程序#include #include #include #include using namespace std;int main(){ TCHAR ws_Directory[MAX_PATH]; GetCurrentDirectory(MAX_PATH, ws_Directory); //_tprintf(L"%sn",ws_Directory);//打印不完全 wcout << ws_Directory << endl; //做⼀个简单的命令⾏程序 STARTUPINFO start_info; memset(&start_info, 0, sizeof (start_info)); PROCESS_INFORMATION info; memset(&info, 0, sizeof (info)); TCHAR str_Command[MAX_PATH]; while (CSTR_EQUAL != CompareStringW(NULL, TRUE, str_Command, 4, L"quit", 4)) { wcout << ws_Directory << "";//这⾥为什么⽤正斜杠我也不知道,但是⽤正斜杠可以有换⾏ //输⼊quit就退出 wcin >> str_Command;//_getw_s不能⽤,所以⽤wcin,但是还是跑不起来,qt垃圾 CreateProcess(NULL, str_Command, NULL, NULL, FALSE, 0, NULL, NULL, &start_info, &info); } //_gettchar(); return 0;}
发布者:admin,转转请注明出处:http://www.yc00.com/web/1690873167a452007.html
评论列表(0条)