2 j8121 J8121 于 2014.12.01 09:08 提问

ShellExecute的返回值

TCHAR doInstall_pars[20000];
CString EXECUTABLE = "//IS//AASA3^\n";
CString Description = "--Description \"航天信息应用服务\" ^\n";
CString DisplayName = "--DisplayName \"Aisino A3 Server\" ^\n";
CString Install = "--Install \"D:\A3\container\bin\tomcat7.exe\" ^\n";
CString LogPath = "--LogPath \"D:\A3\container\bin\logs\" ^\n";
CString StdOutput = "--StdOutput auto ^\n";
CString StdError = "--StdError auto ^\n";
CString Classpath = "--Classpath \"D:\A3\container\bin\bootstrap.jar\" ^\n";
CString Jvm = "--Jvm \"D:\A3\container\jre1.6.0_10\bin\client\jvm.dll\" ^\n";
CString StartMode = "--StartMode jvm ^\n";
CString StopMode = "--StopMode jvm ^\n";
CString StartPath = "--StartPath \"D:\A3\container\" ^\n";
CString StopPath = "--StopPath \"D:\A3\container\" ^\n";
CString StartClass = "--StartClass org.apache.catalina.startup.Bootstrap ^\n";
CString StopClass = "--StopClass org.apache.catalina.startup.Bootstrap ^\n";
CString StartParams = "--StartParams start ^\n";
CString StopParams = "--StopParams stop ^\n";
CString Startup = "--Startup=auto ^\n";
CString JvmOptions = "--JvmOptions \"-Dcatalina.home=D:\A3\container;-Dcatalina.base=D:\A3\container;-Djava.endorsed.dirs=D:\A3\container\endorsed;-Djava.io.tmpdir=D:\A3\container\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=D:\A3\container\conf\logging.properties\" ^\n";
CString JvmMs = "--JvmMs 512 ^\n";
CString JvmMx = "--JvmMx 1024\n";
_stprintf(doInstall_pars, _T("%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s"), EXECUTABLE, Description, DisplayName, Install,
LogPath, StdOutput, StdError, Classpath, Jvm, StartMode, StopMode, StartPath, StopPath,
StartClass, StopClass, StartParams, StopParams, Startup, JvmOptions, JvmMs, JvmMx);
printf(doInstall_pars);
HINSTANCE hInstance = ShellExecute(NULL, _T("open"), _T("tomcat7.exe"), doInstall_pars, _T("D:\A3\container\bin"), SW_HIDE);
if (DWORD num=((DWORD)hInstance >= 32))
{
printf("return value:%d\n", (DWORD)hInstance);
}
else
{
printf("successed!\n");
}
}
这个是做一个服务,上面的CString是要传入tomcat7.exe中的参数。但是参数怎么都传不进去。shellexecute的返回值为1,请问是什么意思?

2个回答

caozhy
caozhy   Ds   Rxr 2014.12.01 10:27

很可能是权限的问题。你直接运行或者通过批处理运行可以成功么?

eagleyan
eagleyan   Rxr 2014.12.01 11:19

ERROR_INVALID_FUNCTION = 1
这里你用tomcat7.exe而不用全路径,你必须把tomcat7.exe所在的directory设到PATH里,当然,如果你能改成全路径的话,应该没有问题。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!