本文整理自网络,侵删。
var SI : TStartupInfo; PI : TProcessInformation; pid:DWORD; begin ZeroMemory(@SI, SizeOf(SI)); //ZeroMemory宏用0来填充一块内存区域 SizeOf//Pascal的一种内存容量度量函数 ZeroMemory(@PI, SizeOf(PI)); SI.cb := SizeOf(SI); if CreateProcess(nil,'d:/CALC.EXE', nil, nil, FALSE, 0 ,nil,nil, SI, PI) then begin Pid := pi.dwProcessId; //获取打开文件的PID ShowMessage(IntToStr(pid));//显示PID值 CloseHandle(PI.hProcess); CloseHandle(PI.hThread); end; end;
相关阅读 >>
Delphi使用json解析调用淘宝ip地址库rest api 示例
Delphi 解决“richedit line insertion error”错误
Delphi setpriorityclass 设置当前程序的优先级
Delphi 能否把.txt文件的数据导入到access数据库中
Delphi getsessionusername通过会话id得到会话名称
Delphi createthread的线程传参数(小熊论坛的)
更多相关阅读请进入《Delphi》频道 >>