ich finde in der Codelib das hier:
Delphi-Quellcode:
function ExecAndWait(Filename, Params: Widestring; WindowState: word = SW_SHOWNORMAL): boolean;
var
ShExecInfoW: SHELLEXECUTEINFOW;
ShExecInfoA: SHELLEXECUTEINFOA;
r : Cardinal;
begin
Result := false;
if Filename = '' then exit;
if not WideFileExists(FileName) then
exit;
if Win32IsUnicode then
begin
ZeroMemory(@ShExecInfoW, SizeOf(ShExecInfoW));
ShExecInfoW.Wnd := GetForegroundWindow;
ShExecInfoW.cbSize := sizeof(SHELLEXECUTEINFOW);
ShExecInfoW.fMask := SEE_MASK_NOCLOSEPROCESS;
ShExecInfoW.lpVerb := 'open';
ShExecInfoW.lpFile := PWideChar(Filename);
ShExecInfoW.lpParameters := PWideChar(Params);
ShExecInfoW.lpDirectory := PWideChar(WideExtractFileDir(Filename));
ShExecInfoW.nShow := WindowState;
Result := ShellExecuteExW(@ShExecInfoW);
end
else
begin
ZeroMemory(@ShExecInfoA, SizeOf(ShExecInfoA));
ShExecInfoA.Wnd := GetForegroundWindow;
ShExecInfoA.cbSize := sizeof(SHELLEXECUTEINFOA);
ShExecInfoA.fMask := SEE_MASK_NOCLOSEPROCESS;
ShExecInfoA.lpVerb := 'open';
ShExecInfoA.lpFile := PChar(AnsiString(Filename));
ShExecInfoA.lpParameters := PChar(AnsiString(Params));
ShExecInfoA.lpDirectory := PChar(AnsiString(WideExtractFileDir(Filename)));
ShExecInfoA.nShow := WindowState;
Result := ShellExecuteExA(@ShExecInfoA);
end;
try
if Result then
begin
if Win32IsUnicode then
r := WaitForSingleObject(ShExecInfoW.hProcess, INFINITE)
else
r := WaitForSingleObject(ShExecInfoA.hProcess, INFINITE);
end;
finally
if Win32IsUnicode then
CloseHandle(ShExecInfoW.hProcess)
else
CloseHandle(ShExecInfoA.hProcess);
end;
end;
Was für eine
Unit muss ich für WideExtractFileDir etc. angeben?
bzw. eigentlich sollte das ja auch mit extractfiledir etc. gehen?
und wo muss man das hier:
(Win32Platform = VER_PLATFORM_WIN32_NT)
angeben?
Gruss
EL