Subversion Repositories aysalia

Rev

Rev 26 | Rev 28 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 26 Rev 27
Line 6... Line 6...
6
 
6
 
7
// This launcher does launch DOSBox with the correct *.conf file,
7
// This launcher does launch DOSBox with the correct *.conf file,
8
// centers the window and changes the window title and icon at runtime.
8
// centers the window and changes the window title and icon at runtime.
9
 
9
 
10
uses
10
uses
-
 
11
 
-
 
12
 
-
 
13
 
-
 
14
dialogs,
-
 
15
 
-
 
16
 
11
  SysUtils,
17
  SysUtils,
12
  ShellAPI,
18
  ShellAPI,
13
  Windows,
19
  Windows,
14
  Messages;
20
  Messages;
15
 
21
 
16
{$R *.RES}
22
{$R *.RES}
17
 
23
 
18
const
24
const
19
  DOSBOX_EXE = 'DOSBox.exe';
25
  DOSBOX_EXE = 'DOSBox.exe';
-
 
26
  AYDOS_MNU = 'AyDos.mnu';
20
 
27
 
21
var
28
var
22
  hPsApiDll: Cardinal = 0;
29
  hPsApiDll: Cardinal = 0;
23
  hIcon: THandle = 0;
30
  hIcon: THandle = 0;
24
  bCeneredOnce: boolean = false;
31
  bCeneredOnce: boolean = false;
Line 177... Line 184...
177
    result := WaitForSingleObject(Info.hProcess, 10);
184
    result := WaitForSingleObject(Info.hProcess, 10);
178
    EnumWindows(@EnumWindowsProc, 0);
185
    EnumWindows(@EnumWindowsProc, 0);
179
  until (result <> WAIT_TIMEOUT);
186
  until (result <> WAIT_TIMEOUT);
180
end;
187
end;
181
 
188
 
-
 
189
function CanRunDosBox: boolean;
-
 
190
var
-
 
191
  windir: array[0..MAX_PATH] of char;
-
 
192
  osVerInfo: TOSVersionInfo;
-
 
193
begin
-
 
194
  osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
-
 
195
  if GetVersionEx(osVerInfo) then
-
 
196
  begin
-
 
197
    // DOSBox does not work with Windows 95
-
 
198
    // It works on Windows 98 (but the VC++ Runtime must be installed)
-
 
199
    if osVerInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS then
-
 
200
    begin
-
 
201
      result := (osVerInfo.dwMajorVersion > 4) or
-
 
202
               ((osVerInfo.dwMajorVersion = 4) and (osVerInfo.dwMinorVersion >= 10{Win98}));
-
 
203
    end
-
 
204
    else if osVerInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then
-
 
205
    begin
-
 
206
      result := true;
-
 
207
    end
-
 
208
    else
-
 
209
    begin
-
 
210
      // This should not happen
-
 
211
      result := false;
-
 
212
    end;
-
 
213
  end
-
 
214
  else
-
 
215
  begin
-
 
216
    if GetWindowsDirectory(windir, sizeof(windir)) > 0 then
-
 
217
    begin
-
 
218
      // In case GetVersionEx fails, we are trying to see if command.com exists
-
 
219
      result := FileExists(windir + '\command.com');
-
 
220
    end
-
 
221
    else
-
 
222
    begin
-
 
223
      // This should never happen
-
 
224
      result := false;
-
 
225
    end;
-
 
226
  end;
-
 
227
end;
-
 
228
 
182
function Main: Integer;
229
function Main: Integer;
183
var
230
var
184
  sFile: string;
231
  sFile: string;
185
begin
232
begin
-
 
233
  if CanRunDosBox then
-
 
234
  begin
186
  ShellExecuteWait(0, 'open', DOSBOX_EXE, '-noconsole -conf DOSBox.conf',
235
    ShellExecuteWait(0, 'open', DOSBOX_EXE, '-noconsole -conf DOSBox.conf',
187
    PChar(ExtractFilePath(ParamStr(0))), SW_NORMAL);
236
      PChar(ExtractFilePath(ParamStr(0))), SW_NORMAL);
188
 
237
 
189
  sFile := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0))) + 'stdout.txt';
238
    sFile := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0))) + 'stdout.txt';
190
  if FileExists(sFile) then DeleteFile(PChar(sFile));
239
    if FileExists(sFile) then DeleteFile(PChar(sFile));
191
 
240
 
192
  sFile := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0))) + 'stderr.txt';
241
    sFile := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0))) + 'stderr.txt';
193
  if FileExists(sFile) then DeleteFile(PChar(sFile));
242
    if FileExists(sFile) then DeleteFile(PChar(sFile));
-
 
243
  end
-
 
244
  else
-
 
245
  begin
-
 
246
    // SEE_MASK_CLASSNAME cannot be used with pure MZ files (it does only work for NE/PE files!)
-
 
247
    // So we need to do the dirty rename-hack...
-
 
248
    RenameFile('AyDos.mnu', 'AyDos.com');
-
 
249
    try
-
 
250
      ShellExecuteWait(0, 'open', 'AyDos.com', '', PChar(ExtractFilePath(ParamStr(0))), SW_NORMAL);
-
 
251
    finally
-
 
252
      RenameFile('AyDos.com', 'AyDos.mnu');
-
 
253
    end;
-
 
254
  end;
194
 
255
 
195
  result := 0;
256
  result := 0;
196
end;
257
end;
197
 
258
 
198
begin
259
begin