Subversion Repositories aysalia

Compare Revisions

Regard whitespace Rev 15 → Rev 16

/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
1,12 → 1,158
program AyDos;
 
// Aysalia DOS Launcher
// Revision 2018-12-06
// (C) 2018 Daniel Marschall, ViaThinkSoft
 
// This launcher does launch DOSBox with the correct *.conf file,
// centers the window and changes the window title and icon at runtime.
 
uses
SysUtils,
ShellAPI,
Windows;
Windows,
Messages;
 
{$R *.RES}
 
const
DOSBOX_EXE = 'DOSBox.exe';
 
var
hPsApiDll: cardinal;
 
(*
function GetModuleFileNameEx(inProcess: THandle; inModule: THandle;
Filename: PChar; size: DWord): DWord; stdcall;
external 'psapi.dll' name 'GetModuleFileNameExA';
*)
{$IFDEF UNICODE}
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
begin
@funcGetModuleFileNameEx := GetProcAddress(psAPIHandle, 'GetModuleFileNameExW') ;
if Assigned (funcGetModuleFileNameEx) then
result := funcGetModuleFileNameEx(inProcess, inModule, Filename, size)
else
result := 0;
end
else result := 0;
end;
{$ELSE}
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
funcGetModuleFileNameEx : TGetModuleFileNameExFunc;
begin
if hPsApiDll <> 0 then
begin
@funcGetModuleFileNameEx := GetProcAddress(hPsApiDll, 'GetModuleFileNameExA') ;
if Assigned (funcGetModuleFileNameEx) then
result := funcGetModuleFileNameEx(inProcess, inModule, Filename, size)
else
result := 0;
end
else result := 0;
end;
{$ENDIF}
 
var
hIcon: THandle = 0;
bCeneredOnce: boolean = false;
 
procedure ChangeTitleAndIcon(hWnd: Thandle);
var
Title: array[0..255] of Char;
const
TargetWinWidth = 640;
TargetWinHeight = 480;
begin
ZeroMemory(@Title, sizeof(Title));
GetWindowText(hWnd, @Title, sizeof(Title)-1);
 
// Center window (once)
if (Title = 'DOSBox') and not bCeneredOnce then
begin
MoveWindow(hWnd, GetSystemMetrics(SM_CXSCREEN) div 2 - TargetWinWidth div 2,
GetSystemMetrics(SM_CYSCREEN) div 2 - TargetWinHeight div 2,
TargetWinWidth,
TargetWinHeight,
true);
bCeneredOnce := true;
end;
 
// Change window title
if Pos('AYDOS1', Title) > 0 then
SetWindowText(hWnd, 'Aysalia DOS I')
else if Pos('AYDOS2', Title) > 0 then
SetWindowText(hWnd, 'Aysalia DOS II')
else
SetWindowText(hWnd, 'Aysalia DOS');
 
// Change window and taskbar icon
if hIcon > 0 then
begin
// Change both icons to the same icon handle.
SendMessage(hWnd, WM_SETICON, ICON_SMALL, hIcon);
SendMessage(hWnd, WM_SETICON, ICON_BIG, hIcon);
 
// This will ensure that the application icon gets changed too.
SendMessage(GetWindow(hWnd, GW_OWNER), WM_SETICON, ICON_SMALL, hIcon);
SendMessage(GetWindow(hWnd, GW_OWNER), WM_SETICON, ICON_BIG, hIcon);
end;
end;
 
function EnumWindowsProc(Handle: hWnd; dummy: DWORD): BOOL; stdcall;
var
Title: array[0..255] of Char;
const
C_FileNameLength = 256;
var
WinFileName: string;
PID, hProcess: DWORD;
Len: Byte;
begin
Result := True;
SetLength(WinFileName, C_FileNameLength);
GetWindowThreadProcessId(Handle, PID);
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, PID);
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
ChangeTitleAndIcon(Handle);
end;
end
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
ZeroMemory(@Title, sizeof(Title));
GetWindowText(Handle, Title, sizeof(Title)-1);
if IsWindowVisible(Handle) then
begin
if (title = 'DOSBox') or ((Pos('DOSBox ', title) > 0) and
(Pos('Cpu speed', title) > 0)) then
begin
Result := False; // stop enumeration
ChangeTitleAndIcon(Handle);
end;
end;
end;
end;
 
function ShellExecuteWait(hWnd: HWND; Operation, FileName, Parameters,
Directory: PAnsiChar; ShowCmd: Integer): DWord;
var
30,21 → 176,32
ShellExecuteEx(pInfo);
 
repeat
exitCode := WaitForSingleObject(Info.hProcess, 1000);
exitCode := WaitForSingleObject(Info.hProcess, 10);
EnumWindows(@EnumWindowsProc, 0);
until (exitCode <> WAIT_TIMEOUT);
 
result := exitCode;
end;
 
function Main: Integer;
var
sFile: string;
begin
ShellExecuteWait(0, 'open', 'DOSBox.exe', '-noconsole -conf DOSBox.conf',
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;
end;
 
begin
hPsApiDll := LoadLibrary('psapi.dll') ;
hIcon := LoadIcon(hInstance, 'MainIcon');
ExitCode := Main;
FreeLibrary(hPsApiDll);
end.
/trunk/Aysalia DOS/Source/AyDos.dproj
0,0 → 1,33
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{19b697c4-ec95-436f-a24a-835c62a5d966}</ProjectGuid>
<MainSource>AyDos.dpr</MainSource>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
<DCC_DependencyCheckOutputName>AyDos.exe</DCC_DependencyCheckOutputName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Version>7.0</Version>
<DCC_DebugInformation>False</DCC_DebugInformation>
<DCC_LocalDebugSymbols>False</DCC_LocalDebugSymbols>
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
<DCC_Define>RELEASE</DCC_Define>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Version>7.0</Version>
<DCC_Define>DEBUG</DCC_Define>
</PropertyGroup>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality</Borland.Personality>
<Borland.ProjectType>VCLApplication</Borland.ProjectType>
<BorlandProject>
<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1031</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">AyDos.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject>
</ProjectExtensions>
<Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" />
<ItemGroup>
<DelphiCompile Include="AyDos.dpr">
<MainSource>MainSource</MainSource>
</DelphiCompile>
</ItemGroup>
</Project>
/trunk/Aysalia DOS/Source/AyDos.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Aysalia DOS/Source/Source Notes.txt
29,6 → 29,7
 
In Windows mode, it calls DOSBox.exe with the arguments "-noconsole -conf DOSBox.conf" and
the working directory being the directory where the EXE file is located.
It also centers the DOSBox window and changes its window title and icon at runtime.
 
In DOS mode, it executes the application "AYDOS.MNU" (which is actually a COM-file
containing the menu code that will eventually call AYDOS1.GAM or AYDOS2.GAM which are