Autor Beitrag
Experience1986
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 192

Win XP Pro SP2
Delphi 7
BeitragVerfasst: Mi 01.06.05 17:36 
Hi,

ich wollte die Startparameter einer Instanz übergeben. Dazu habe ich mir euer Hinweis in den Faq angeschaut.

www.delphi-forum.de/...=instanzen+parameter

Leider läuft da etwas nicht so wie ich es mir vorstelle.

Wenn ich die Daten einer Instanz empfange (OnMessage, bei einer ApplicationEvent Komponente), empfang meiner Empfangsinstanz 2 mal die Parameter und dann bestimmt 6 mal ein Leerstring. Woran könnte das liegen?

Mein Code:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
procedure TFRM_MAIN.ApplicationEvents1Message(var Msg: tagMSG;  var Handled: Boolean);
var Str:String; i,j,x:integer; IstStringWithSpace,SimpleMode:Boolean; Files:TStringList; CurFile:String; CorrectFiles:TStringList;
begin

  if (Msg.message = ActivationMessage) then
  begin     
    Str:=(ReadStringFromMMF(MyGUID + 'MMF'));
    Str:=StringReplace(Str,'"','',[]);

    // AB HIER VERSUCHE ICH DIE EINZELNEN DATEIEN IM
    // PARAMETER STRING ZU TRENNEN. DIE QUALITÄT STEHT NICHT
    // ZUR DEBATTE *G*         

    Files:=TStringlist.Create;
    CorrectFiles:=TStringlist.Create;
    IstStringWithSpace:=false;
    SimpleMode:=true;
    CurFile:=''; 

    for i:=1 to length(Str) do
      begin  
        CurFile:=CurFile+Str[i];
        if not (i+1 > length(Str) ) then
           begin
             if (Str[i] = ' ') and (Str[i+1] = ' ') then
               begin
                 Files.Add(CurFile);
                 CurFile:='';
               end;
           end
         else
           begin
                 Files.Add(CurFile);
                 CurFile:='';
           end;
      end;


    for i:=0 to Files.Count-1 do
      begin
        CurFile:=Files.Strings[i];
        
        // Erstes Zeichen Prüfen
        if (Copy(CurFile,0,1) = '"') or (Copy(CurFile,0,1) = ' ') then
          Delete(CurFile,1,1);
        // Zweites Zeichen Prüfen
        if (Copy(CurFile,0,1) = '"') or (Copy(CurFile,0,1) = ' ') then
          Delete(CurFile,1,1);

        //letztesZeichen Prüfen
        if (Copy(CurFile,length(CurFile),length(CurFile)) = '"') or (Copy(CurFile,length(CurFile),length(CurFile)) = ' ') then
          Delete(CurFile,length(CurFile),length(CurFile));

        if (Copy(CurFile,length(CurFile),length(CurFile)) = '"') or (Copy(CurFile,length(CurFile),length(CurFile)) = ' ') then
          Delete(CurFile,length(CurFile),length(CurFile));

        if not (lowercase(CurFile) = lowercase(ParamStr(0))) and (FileExists(CurFile) or DirectoryExists(CurFile)) then
          begin
            if not CorrectFiles.Find(CurFile,x) then
              begin
                CorrectFiles.Add(CurFile);
              end;
          end;
      end;
    ProceedInstanceParameters(CorrectFiles);
    Handled := True;
  end;
end;



Könnt ihr einen Fehler entdecken? Oder habt Ihr eine Lösung wie das Problem umgehen könnte?
Experience1986 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 192

Win XP Pro SP2
Delphi 7
BeitragVerfasst: Fr 03.06.05 17:23 
So, ich habe mir nochmals das Beispiel der FAQ angesehen und musste feststellen das ich alles genauso umgesetzt habe wie angegeben.

Nun nochmals die Frage, woran könnte das liegen?
Kann dieser Code von anderem Beeinflusst werden? Zum Beispiel von Windows Messages von GGlobalen Hotkeys oder etwa Systemtray Icons?