Einzelnen Beitrag anzeigen

Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 
#1

Vista und Comandlineparamerübergabe, "..ist ja 'n Ding!

  Alt 4. Jan 2008, 14:35
Vista und Comandlineparamerübergabe, "..ist ja 'n Ding!"

@mods:
Tja, ich weis jetzt nich so recht wohin mit dem Thema, ist sowol API als auch BS.



Also, ich wusel gerade ein wenig mit Vista rum und bemerke das einige ältere Programme für XP
probleme mit Parametern haben. Kann ja nun nicht sein dachte ich mir und habe eine kleines Programm
geschrieben welches als Loader dient. Nun siehe da es klappt. Ich frage mich nur woran das liegt?

Delphi-Quellcode:
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.
Kann so etwas an Unicode liegen ?
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat