使用CreateProcess运行bin文件

时间:2016-10-20 14:23:45

标签: c++

可以像C#一样运行.bin吗?

C#使用诸如此类的代码

int main(int argc, char* argv[]){
    PROCESS_INFORMATION ProcessInfo; 

    STARTUPINFO StartupInfo; 
    char cmdArgs[] = "test.bin";

    ZeroMemory(&StartupInfo, sizeof(StartupInfo));
    StartupInfo.cb = sizeof StartupInfo;

    if (CreateProcess("C:\\Users\\username\\Documents\\Visual Studio 2015\\Projects\\runbin\\Release\\test.bin", cmdArgs, NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo)){
        WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
        CloseHandle(ProcessInfo.hThread);
        CloseHandle(ProcessInfo.hProcess);

        printf("work!");
    }
    else{
        printf("The process could not be started...");
    }
    return 0;
}

在c ++中试过

searchPoint

但不使用.bin

0 个答案:

没有答案