brain-tools/usbstorage/usbstorage_spawn.cpp

36 lines
792 B
C++
Raw Normal View History

2014-01-26 12:35:57 +09:00
#include <string>
#include <windows.h>
using namespace std;
#ifdef UNICODE
namespace std { typedef wstring tstring; }
#else
namespace std { typedef string tstring; }
#endif
tstring getCurrentDirectory() {
TCHAR path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
TCHAR *p = _tcschr(path, _T('\0'));
for ( ; p >= path; p--) {
if (*p == _T('\\')) {
*p = _T('\0');
break;
}
}
return path;
}
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR lpCmd, int nShow)
{
tstring mainProcPath = getCurrentDirectory() + _T("\\usbstorage.exe");
CreateProcess(mainProcPath.c_str(), mainProcPath.c_str(), NULL, NULL,
false, 0, NULL, NULL, NULL, NULL);
return 0;
}