Registriert seit: 18. Okt 2003
Ort: Nellmersbach/Stuttgart
23 Beiträge
Delphi 6 Professional
|
Re: TService - Druckerproblem!
26. Nov 2003, 14:48
das ist bisher so:
Code:
procedure TService1.ServiceStart(Sender: TService; var Started: Boolean);
var
ProcID: PCardinal;
begin
RunProcess(ExtractFilePath(ParamStr(0)) + 'Disco.exe', SW_MINIMIZE, TRUE, ProcID);
end;
function TService1.RunProcess(FileName: string; ShowCmd: DWORD; wait: Boolean; ProcID: PCardinal): Longword;
var
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin
FillChar(StartupInfo, SizeOf(StartupInfo), #0);
StartupInfo.cb := SizeOf(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
StartupInfo.wShowWindow := ShowCmd;
if not CreateProcess(nil,
@Filename[1],
nil,
nil,
False,
CREATE_NEW_CONSOLE or
NORMAL_PRIORITY_CLASS,
nil,
nil,
StartupInfo,
ProcessInfo)
then
Result := WAIT_FAILED
else
begin
if wait = FALSE then
begin
if ProcID <> nil then ProcID^ := ProcessInfo.dwProcessId;
exit;
end;
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, Result);
end;
if ProcessInfo.hProcess <> 0 then
CloseHandle(ProcessInfo.hProcess);
if ProcessInfo.hThread <> 0 then
CloseHandle(ProcessInfo.hThread);
end;
dai ich ja kein form anzeigen will, sondern ein Programm starte...
Life is hard and then you die
|
|
Zitat
|