program ResEd;
{$R '_res\resources.res' '_res\resources.rc'}
{.$DEFINE DEBUG}
uses
Windows,
ShellAPI;
const
OrginalExecFile = '
ResEd!.exe';
function LastDelimiter(S:
String; Delimiter: Char): Integer;
var
i: Integer;
begin
Result := -1;
i := Length(S);
if (S = '
')
or (i = 0)
then
Exit;
while S[i] <> Delimiter
do
begin
if i < 0
then
break;
dec(i);
end;
Result := i;
end;
function ExtractFilePath(sFilename:
String):
String;
begin
if LastDelimiter(sFilename, '
\') = -1
then
Exit;
Result := Copy(sFilename, 1, LastDelimiter(sFilename, '
\'));
end;
{function GetVirtualPathName(path: string): string;
var
FileInfo: TSHFileInfo;
begin
SHGetFileInfo( PAnsiChar(path), 0,
FileInfo, SizeOf(TSHFIleInfo), SHGFI_DISPLAYNAME);
result := FileInfo.szDisplayName;
end;}
function WinMain(hInstance: HINST; hPrevInstance: HINST;
lpCmdLine: PChar; nCmdShow: Integer): Integer;
stdcall;
var
Err : Cardinal;
s :
String[128];
params :
string;
i : integer;
begin
params := '
';
s := '
';
if ParamCount > 0
then
begin
for i := 1
to ParamCount
do
begin
params := params + #32 + ParamStr(i);
end;
if params[1] = #32
then Delete(params, 1, 1);
end;
Err := ShellExecute(GetDesktopWindow, '
open', PCHAR(OrginalExecFile), PCHAR(Params),
PCHAR(ExtractFilePath(ParamStr(0))), nCmdShow);
if Err <= 32
then
begin
case err
of
0 : s:= '
The operating system is out of memory or resources.';
ERROR_FILE_NOT_FOUND : s:= '
The specified file was not found.';
ERROR_PATH_NOT_FOUND : s:= '
The specified path was not found.';
// ... *schnipp*
end;
MessageBox(0, PChar('
Error:'#10#13#10#13'
CmdLine: '+ Paramstr(0) + #10#13+
params+#10#13#10#13+s), '
!Launcer', MB_ICONERROR
or MB_OK);
end;
Result := 0;
end;
BEGIN
WinMain(hInstance, System.hPrevInst, System.CmdLine, System.CmdShow);
{$IFDEF DEBUG}
MessageBox(GetDesktopWindow, System.CmdLine,
'
!Launcer: CmdLine:', MB_ICONINFORMATION
or MB_OK);
{$ENDIF DEBUG}
END.