Windows API createprocess为getlasterror返回2

时间:2016-03-11 09:40:54

标签: c++

我将createprocess的getlasterror设置为2。 代码如下:

#include<Windows.h>
#include<tchar.h>
#include<iostream>
int main()
{
    std::string cmd = "\"c:\\Program Files (x86)\\Java\\jre1.8.0_66\\bin\\java.exe\"";
    std::string param = " com.server.serv %*";
    STARTUPINFO si = { 0 };
    si.cb = sizeof(si);
    std::cout << cmd.c_str();
    PROCESS_INFORMATION pi = { 0 };
int result = CreateProcess((LPCTSTR)cmd.c_str()  ,   // No module name (use command line)
            _T(" -cp com.ge.med.terra.eat.server.EATServer %*" ),       // Command line
            NULL,           // Process handle not inheritable
            NULL,           // Thread handle not inheritable
            FALSE,          // Set handle inheritance to FALSE
            0,              // No creation flags
            NULL,           // Use parent's environment block
            NULL,           // Use parent's starting directory
            &si,            // Pointer to STARTUPINFO structure
            &pi);
        if(result == 0)
        {

            DWORD dw = GetLastError();
            std::cout << dw;
        }
        return 0;
}

我检查了java.exe的路径及其正确,有人请指点我做错了什么。 我不想使用cmd.exe / C执行。

0 个答案:

没有答案
相关问题