//变量声明
sInfo: TStartupInfo;
pInfo: TProcessInformation;
cmdLine: string;
exitCode: Cardinal;
//执行代码
cmdLine := 'regsvr32.exe /s Loader.DLL';
FillChar(sInfo, sizeof(sInfo), #0);
sInfo.cb := sizeof(sInfo);
sInfo.dwFlags := STARTF_USESHOWWINDOW;
sInfo.wShowWindow := SW_NORMAL;
if not CreateProcess(nil, Pchar(cmdLine), nil, nil, false, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, sInfo, pInfo) then
Application.MessageBox(DLL initialize error!', 'Error', MB_OK + MB_ICONSTOP)
else begin
WaitForSingleObject(pInfo.hProcess, INFINITE);
GetExitCodeProcess(pInfo.hProcess, exitCode);
end;