主调程序代码:
var
FileName, Version: string;
ExeInfo: SHELLEXECUTEINFO;
begin
ExeInfo.cbSize := SizeOf(SHELLEXECUTEINFO);
ExeInfo.fMask := 0;
ExeInfo.Wnd := Handle;
ExeInfo.lpVerb := 'open';
//这里是要打开文件的绝对路径
ExeInfo.lpFile := 'C:/MyFile/MyExe.exe';
//写入参数,使用空格分开
ExeInfo.lpParameters := PChar(edtIP.Text + ' ' + edtPort.Text +
' ' + edtInterceptorGUID.Text);
ExeInfo.lpDirectory := 'C:/MyFile';
ExeInfo.nShow := SW_SHOWNORMAL;
ExeInfo.hInstApp := Handle;
ShellExecuteEx(@ExeInfo);
end;
被调程序的代码
if ParamCount = 0 then
begin
Application.MessageBox('客户端无法直接运行,请运行客户端加载程序启动系统!',
'非法运行', MB_OK + MB_ICONSTOP);
Application.Terminate;
end;