Rev 9 | Rev 16 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9 | daniel-mar | 1 | program AyDos; |
2 | |||
3 | uses |
||
4 | SysUtils, |
||
5 | ShellAPI, |
||
6 | Windows; |
||
7 | |||
8 | {$R *.RES} |
||
9 | |||
10 | function ShellExecuteWait(hWnd: HWND; Operation, FileName, Parameters, |
||
11 | Directory: PAnsiChar; ShowCmd: Integer): DWord; |
||
12 | var |
||
13 | Info: TShellExecuteInfo; |
||
14 | pInfo: PShellExecuteInfo; |
||
15 | exitCode: DWord; |
||
16 | begin |
||
17 | pInfo := @Info; |
||
18 | with Info do |
||
19 | begin |
||
20 | cbSize := SizeOf(Info); |
||
21 | fMask := SEE_MASK_NOCLOSEPROCESS; |
||
22 | wnd := hWnd; |
||
23 | lpVerb := Operation; |
||
24 | lpFile := FileName;; |
||
25 | lpParameters := PChar(Parameters + #0); |
||
26 | lpDirectory := PChar(Directory); |
||
27 | nShow := ShowCmd; |
||
28 | hInstApp := 0; |
||
29 | end; |
||
30 | ShellExecuteEx(pInfo); |
||
31 | |||
32 | repeat |
||
33 | exitCode := WaitForSingleObject(Info.hProcess, 1000); |
||
34 | until (exitCode <> WAIT_TIMEOUT); |
||
35 | |||
36 | result := exitCode; |
||
37 | end; |
||
38 | |||
39 | var |
||
40 | sFile: string; |
||
41 | begin |
||
42 | ShellExecuteWait(0, 'open', 'DOSBox.exe', '-noconsole -conf DOSBox.conf', |
||
43 | PChar(ExtractFilePath(ParamStr(0))), SW_NORMAL); |
||
44 | |||
45 | sFile := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0))) + 'stdout.txt'; |
||
46 | if FileExists(sFile) then DeleteFile(PChar(sFile)); |
||
47 | |||
48 | sFile := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0))) + 'stderr.txt'; |
||
49 | if FileExists(sFile) then DeleteFile(PChar(sFile)); |
||
50 | end. |