Subversion Repositories aysalia

Compare Revisions

No changes between revisions

Regard whitespace Rev 19 → Rev 18

/trunk/Aysalia DOS/AyDos.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Aysalia DOS/Source/AyDos.dpr
27,10 → 27,11
external 'psapi.dll' name 'GetModuleFileNameExA';
*)
{$IFDEF UNICODE}
function GetModuleFileNameEx(inProcess: THandle; inModule: THandle; Filename: PWideChar; size: DWord): Integer;
function GetModuleFileNameEx(inProcess: THandle; inModule: THandle; Filename: PWideChar; size: DWord): DWord;
type
TGetModuleFileNameExFunc = function (inProcess: THandle; inModule: THandle; Filename: PWideChar; size: DWord): DWord; stdcall;
var
dllHandle: Cardinal;
funcGetModuleFileNameEx: TGetModuleFileNameExFunc;
begin
if psAPIHandle <> 0 then
39,12 → 40,12
if Assigned(funcGetModuleFileNameEx) then
result := funcGetModuleFileNameEx(inProcess, inModule, Filename, size)
else
result := -1;
result := 0;
end
else result := -2;
else result := 0;
end;
{$ELSE}
function GetModuleFileNameEx(inProcess: THandle; inModule: THandle; Filename: PAnsiChar; size: DWord): Integer;
function GetModuleFileNameEx(inProcess: THandle; inModule: THandle; Filename: PAnsiChar; size: DWord): DWord;
type
TGetModuleFileNameExFunc = function (inProcess: THandle; inModule: THandle; Filename: PAnsiChar; size: DWord): DWord; stdcall;
var
56,9 → 57,9
if Assigned(funcGetModuleFileNameEx) then
result := funcGetModuleFileNameEx(inProcess, inModule, Filename, size)
else
result := -1;
result := 0;
end
else result := -2;
else result := 0;
end;
{$ENDIF}
 
111,21 → 112,23
function EnumWindowsProc(Handle: hWnd; dummy: DWORD): BOOL; stdcall;
var
Title: array[0..255] of Char;
WinFileName: array[0..MAX_PATH] of Char;
const
C_FileNameLength = 256;
var
PID: DWORD;
hProcess: THandle;
Len: Integer;
WinFileName: string;
PID, hProcess: DWORD;
Len: Byte;
begin
Result := True;
ZeroMemory(@WinFileName, sizeof(WinFileName));
GetWindowThreadProcessId(Handle, @PID);
SetLength(WinFileName, C_FileNameLength);
GetWindowThreadProcessId(Handle, PID);
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, PID);
Len := GetModuleFileNameEx(hProcess, 0, WinFileName, sizeof(WinFileName)-1);
Len := GetModuleFileNameEx(hProcess, 0, PChar(WinFileName), C_FileNameLength);
if Len > 0 then
begin
// GetModuleFileNameEx is available on newer operating systems;
// it ensures that we find the correct window by checking its EXE filename.
SetLength(WinFileName, Len);
if SameText(WinFileName, ExtractFilePath(ParamStr(0)) + DOSBOX_EXE) then
begin
Result := False; // stop enumeration
132,7 → 135,7
ChangeTitleAndIcon(Handle);
end;
end
else if Len < 0 then
else
begin
// At Win9x, there is no psapi.dll, so we try it the old fashioned way,
// finding the window by parts of its title
155,6 → 158,7
var
Info: TShellExecuteInfo;
pInfo: PShellExecuteInfo;
exitCode: DWord;
begin
pInfo := @Info;
with Info do
163,7 → 167,7
fMask := SEE_MASK_NOCLOSEPROCESS;
wnd := hWnd;
lpVerb := Operation;
lpFile := FileName;
lpFile := FileName;;
lpParameters := PChar(Parameters + #0);
lpDirectory := PChar(Directory);
nShow := ShowCmd;
172,9 → 176,11
ShellExecuteEx(pInfo);
 
repeat
result := WaitForSingleObject(Info.hProcess, 10);
exitCode := WaitForSingleObject(Info.hProcess, 10);
EnumWindows(@EnumWindowsProc, 0);
until (result <> WAIT_TIMEOUT);
until (exitCode <> WAIT_TIMEOUT);
 
result := exitCode;
end;
 
function Main: Integer;
184,10 → 190,10
ShellExecuteWait(0, 'open', DOSBOX_EXE, '-noconsole -conf DOSBox.conf',
PChar(ExtractFilePath(ParamStr(0))), SW_NORMAL);
 
sFile := IncludeTrailingBackSlash(ExtractFilePath(ParamStr(0))) + 'stdout.txt';
sFile := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'stdout.txt';
if FileExists(sFile) then DeleteFile(PChar(sFile));
 
sFile := IncludeTrailingBackSlash(ExtractFilePath(ParamStr(0))) + 'stderr.txt';
sFile := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'stderr.txt';
if FileExists(sFile) then DeleteFile(PChar(sFile));
 
result := 0;
195,10 → 201,7
 
begin
hPsApiDll := LoadLibrary('psapi.dll');
try
hIcon := LoadIcon(hInstance, 'MainIcon');
ExitCode := Main;
finally
FreeLibrary(hPsApiDll);
end;
end.
/trunk/Aysalia DOS/Source/AyDos.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream