我写了一个服务程序,其中在
void WINAPI ServiceMain(DWORD argc, LPTSTR *argv)函数中有这么一段代码:char chPath[255];
GetCurrentDirectory(255,chPath);
strcat(chPath,"A.exe");
system(chPath);结果system并没有执行A.exe但是如果写成system("c:\\A.exe");他就会执行难道服务程序中不能用system??那请问,我要在服务中执行某个EXE程序该怎么写呢?谢谢!
期盼佳音!!
void WINAPI ServiceMain(DWORD argc, LPTSTR *argv)函数中有这么一段代码:char chPath[255];
GetCurrentDirectory(255,chPath);
strcat(chPath,"A.exe");
system(chPath);结果system并没有执行A.exe但是如果写成system("c:\\A.exe");他就会执行难道服务程序中不能用system??那请问,我要在服务中执行某个EXE程序该怎么写呢?谢谢!
期盼佳音!!
char chPath[255];
GetCurrentDirectory(255,chPath);
strcat(chPath,"\\");
strcat(chPath,"A.exe");
system(chPath);
我测试过的
strcat(chPath,"\\A.exe");
或
strcat(chPath,"\\");
strcat(chPath,"A.exe");
是对的
你这段代码确实要改成strcat(chPath,"\\A.exe");
GetCurrentDirectory只得到当前文件夹没有那个\啊如果这样还不行,你确信整个路径正确
看看system的返回值
GetCurrentDirectory(255,chPath);
strcat(chPath,"\\winamp281_full.exe");
system(chPath);
可以用的,除非你不是把“A.exe”与这个服务程序放在同一个目录下