本文整理自网络,侵删。
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 程序在不同操作系统中 shellexecute 调用 chrome.exe 偶尔无效的问题
Delphi idhttpserver接收http get请求解码问题
Delphi 泛型容器单元(generics.collections) tdictionary<t>
Delphi2010中使用pchar时e2010 incompatible types: 'char' and 'ansichar' 错误的处理
更多相关阅读请进入《Delphi》频道 >>