赞
踩
WinExec,
都能执行cmd命令,
ShellExecute 相对简单些,且可一次执行多行命令
C++
- CString GetModuleDir() {
- HMODULE module = GetModuleHandle(0);
- wchar_t pFileName[MAX_PATH] = { 0 };
- GetModuleFileName(module, pFileName, MAX_PATH);
- CString csFullName(pFileName);
- int nPos = csFullName.ReverseFind('\\');
- if (nPos < 0)
- return CString("");
- else
- return csFullName.Left(nPos) +"\\" + csFullName.Right(csFullName.GetLength() - nPos - 1);
-
- }
-
-
-
-
-
- LPCWSTR stringToLPCWSTR(std::string orig)
- {
- size_t size = orig.length();
- wchar_t* buffer = new wchar_t[size + 1];
- MultiByteToWideChar(CP_ACP, 0, orig.c_str(), size, buffer, size * sizeof(wchar_t));
- buffer[size] = 0; //确保以 '\0' 结尾
- return buffer;
- }
-
-
-
-
-
-
-
- //重启程序自身
- void ReStart()
- {
- string sAppPath = CT2A(GetModuleDir());
- string sCmd &

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。