To je humus - vyrabas tym 100% zatazenie CPU robenim nicoho
Osobne pouzivam toto - kedysi som to niekde vyhrabal a upravil:
Kód:
function ShellExec(Verb,FileName,Params,Path:PChar; Show:Word; Wait:Boolean):LongInt;
var OK:Boolean;
Info:TShellExecuteInfo;
begin
FillChar(Info,SizeOf(Info),0);
with Info do
begin
cbSize:=SizeOf(Info);
fMask:=SEE_MASK_NOCLOSEPROCESS;
lpVerb:=Verb;
lpFile:=FileName;
lpParameters:=Params;
lpDirectory:=Path;
nShow:=show;
end;
OK:=Boolean(ShellExecuteEx(@Info));
if OK then
if wait then
begin
while WaitForSingleObject(Info.hProcess,100)=WAIT_TIMEOUT do Application.ProcessMessages;
OK:=GetExitCodeProcess(Info.hProcess,DWord(Result));
end
else Result:=0;
if not OK then Result:=-1;
end;
Pouziva sa to napriklad takto:
Kód:
ShellExec('open','rundll32.exe','setupapi.dll,InstallHinfSection DefaultInstall 132 L3CODEC\L3CODEC.INF','',0,TRUE)