我已经尝试使用 Stackoverflow 中的一些解决方案,但我无法让它工作,我想从 C++ 启动一个 .LOG(.txt 文件),但包含它的路径文件夹可能有空格,所以当我尝试要启动它,我收到一条错误消息,说它找不到文件,因为 pah(包含空格)是错误的,这是我的代码的样子:
void Log (unsigned int Code,...)
{
char currdate[11] = {0};
SYSTEMTIME t;
GetLocalTime(&t);
sprintf(currdate, "%02d:%02d:%02d", t.wHour, t.wMinute, t.wSecond);
PROCESSENTRY32 pe32;
FILE* FileHwnd1;
FileHwnd1 = fopen("TEST.log","a+");
fprintf(FileHwnd1,"[%s] Code: %X\n",currdate,Code);
fclose(FileHwnd1);
char buffer[MAX_PATH];
GetModuleFileName( NULL, buffer, MAX_PATH);
char Path[50];
wsprintf(Path,"start %s\\AntiHack.log",buffer);
system(Path);//Here is where i get the containing spaces path error
}
谢谢。