rt

解决方案 »

  1.   

    BOOL TerminateProcess(
      HANDLE hProcess, // handle to the process
      UINT uExitCode   // exit code for the process
    );
      

  2.   

    BOOL TerminateProcess(
      HANDLE hProcess, // handle to the process
      UINT uExitCode   // exit code for the process
    );
      

  3.   

    http://community.csdn.net/Expert/topic/3564/3564323.xml?temp=.6520197
      

  4.   

    faint~~~我也知道TerminateProcess这个函数阿!!!问题是shellexcute创建的进程没有句柄给你返回~而我又不想用ex版本,或者谁有一个例子给看一下?
      

  5.   

    SHELLEXECUTEINFO ShExecInfo = {0};
    ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
    ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
    ShExecInfo.hwnd = NULL;
    ShExecInfo.lpVerb = NULL;
    ShExecInfo.lpFile = "c:\\MyProgram.exe";
    ShExecInfo.lpParameters = "";
    ShExecInfo.lpDirectory = NULL;
    ShExecInfo.nShow = SW_SHOW;
    ShExecInfo.hInstApp = NULL;
    ShellExecuteEx(&ShExecInfo);
    WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
    或: PROCESS_INFORMATION ProcessInfo; 
    STARTUPINFO StartupInfo; //This is an [in] parameter
    ZeroMemory(&StartupInfo, sizeof(StartupInfo));
    StartupInfo.cb = sizeof StartupInfo ; //Only compulsory field
    if(CreateProcess("c:\\winnt\\notepad.exe", NULL, 
        NULL,NULL,FALSE,0,NULL,
        NULL,&StartupInfo,&ProcessInfo))

        WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
        CloseHandle(ProcessInfo.hThread);
        CloseHandle(ProcessInfo.hProcess);
    }  
    else
    {
        MessageBox("The process could not be started...");
    }