Autor Beitrag
kandesbunzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 116
Erhaltene Danke: 1


Delphi 7, XE2
BeitragVerfasst: Di 21.11.06 01:27 
Hallo allerseits,

beim Auswerten eines Dateisuchergebnisses (mit dme FileFind - Beispiel) erhalte ich folgendes Ergebnis:
" 'C:\Test\Ergebnis.exe' #$D#$A ".

Die Weiterverwendung als Stringvariable scheitert an der Fehlermeldung : 'Inkompatible Typen 'String' und 'PAnsiChar'.

Was mache ich falsch?

Danke und auf bald ...
kandesbunzler.
Manina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44

Win 7 Pro
RAD Studio 2010 Pro
BeitragVerfasst: Di 21.11.06 01:33 
Ich kenne das FileFind-Beispiel nicht und weiß daher net, wie Du an das Ergebnis kommst, aber:

#$D#$A ist einfach ein Zeilenumbruch...

mit s := Trim(StrPas(p)) solltest Du den String durchaus weiter benutzen können... :)
kandesbunzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 116
Erhaltene Danke: 1


Delphi 7, XE2
BeitragVerfasst: Di 21.11.06 01:39 
Hallo Manina,

auch noch wach? -)) Danke für die rasche Antwort. Leider erhalte ich dennoch weiterhin die inkompatibilitätsfehlermeldung.

Eventuell sollte ich erwähnen, daß ich die Prozedur:

Procedure FindFiles (aPath, aFindMask: String; aWithSub: Boolean; aResult: tStrings);

verwende.

Auf bald ...
kandesbunzler.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 21.11.06 01:49 
Moin und :welcome: im Forum!

user profile iconkandesbunzler hat folgendes geschrieben:
Die Weiterverwendung

Könntest du das mal näher erklären? ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Manina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44

Win 7 Pro
RAD Studio 2010 Pro
BeitragVerfasst: Di 21.11.06 01:52 
Ah jaaaaa....

versuchs mal so: (wie zum Ku... fügt man hier formatierten Quelltext ein ? :) )

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var myList : TStringList;
...
myList := TStringList.Create;
myList.Sorted := TRUE;          // da hst Du gleich alles sortiert
myList.Duplicates := dupIgnore; // und nur EIN-mal, falls doppelt gefunden :)
FindFiles(..., myList);
for i := 0 to myList.Count - 1 do begin
  s := Trim(myList[i]);
  if s <> '' then begin
     ...
  end;
end;
myList.Free;


Hilft das weiter ?

Gruß und GutNacht :)

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 21.11.06 01:56 
Moin!

user profile iconManina hat folgendes geschrieben:
(wie zum Ku... fügt man hier formatierten Quelltext ein ? :) )

Markier den Quelltext und klicke auf das Plus neben dem "Delphi" in der Listbox im Editor. ;)

Abgesehen davon ist dein Code so aufwändig gar nicht nötig (sofern es sich um die Suche in: Delphi-Forum, Delphi-Library DRIVETOOLS von user profile iconLuckie handelt, was ich mal unterstelle). ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
kandesbunzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 116
Erhaltene Danke: 1


Delphi 7, XE2
BeitragVerfasst: Di 21.11.06 02:04 
Guten Morgen allerseits

und danke für den freundlichen Empfang!

Urks - ich hatte mich wohl etwas zu kurz gefaßt. Also:

Ich suche mit Hilfe der FindFile Prozedure (siehe www.delphi-library.d...89802c27b6e14d4fe85) eine Datei.

Die o.g. Prozedur liefert das -fast- korrekte Ergebnis lt. Debugger (bspw.: " 'C:\Test\Ergebnis.exe' #$D#$A "). Auch die Übergabe dieses Ergebnisses an bspw.'Datei_und_Pfad_Name' (als String definiert !) klappt. Nun möchte ich diese Variable per WinExec (Datei_und_Pfad_Name, SW_SHOW) aufrufen und ausführen. Dies läßt der Compiler leider wegen besagter Fehlermeldung nicht durch.

Auf bald ...
kandesbunzler.
Manina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44

Win 7 Pro
RAD Studio 2010 Pro
BeitragVerfasst: Di 21.11.06 02:05 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var myList : TStringList; 
... 
myList := TStringList.Create; 
myList.Sorted := TRUE;          // da hst Du gleich alles sortiert 
myList.Duplicates := dupIgnore; // und nur EIN-mal, falls doppelt gefunden  
FindFiles(..., myList); 
for i := 0 to myList.Count - 1 do begin 
  s := Trim(myList[i]); 
  if s <> '' then begin 
  ... 
  end
end
myList.Free;


Wunderbar ! Danke Narses ! :zustimm:

Aber da ich die DriveTools noch net kenne, hab ichs halt geschreibt, wie ichs dachte... Du siehst ja, ich bin auch noch ziemlich neu *kicher*, zumindest hier in diesem Forum...

Gruß, Manina.
Manina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44

Win 7 Pro
RAD Studio 2010 Pro
BeitragVerfasst: Di 21.11.06 02:11 
HA ! Das ist ja ein gaaaanz anderes Problem !

WinExec erwartet ein PChar als Parameter, keinen String !

Also mußt Du genau das andersrumme bauen ! :)


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var a : Array[0.. MAXPATHLENGTH] of Char;

...

StrPCopy(a, aResultvonOben); 
WinExec(a, ....);


Ich hoffe, das war jetzt syntaktisch korrekt... Es ist spät und ich bin müde.. Entschuldige ! :(
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 21.11.06 02:11 
Moin!

user profile iconkandesbunzler hat folgendes geschrieben:
Die o.g. Prozedur liefert das -fast- korrekte Ergebnis lt. Debugger (bspw.: " 'C:\Test\Ergebnis.exe' #$D#$A ").

Die Prozedur liefert das absolut korrekte Ergebnis, nicht nur fast. ;)

user profile iconkandesbunzler hat folgendes geschrieben:
Auch die Übergabe dieses Ergebnisses an bspw.'Datei_und_Pfad_Name' (als String definiert !) klappt. Nun möchte ich diese Variable per WinExec (Datei_und_Pfad_Name, SW_SHOW) aufrufen und ausführen.

Schätze mal, du meinst ShellExecute? :gruebel: WinExec kenn ich nicht... :?

user profile iconkandesbunzler hat folgendes geschrieben:
Dies läßt der Compiler leider wegen besagter Fehlermeldung nicht durch.

Ja, da die API-Funktion einen PAnsiChar erwartet, du aber einen Pascal-String übergibst. Also noch ein PAnsiChar() um deine Variable im Aufruf, dann sollte es klappen. ;)

@user profile iconManina: Viel zu aufwändig, ein Typecast reicht da völlig. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Manina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44

Win 7 Pro
RAD Studio 2010 Pro
BeitragVerfasst: Di 21.11.06 02:22 
@user profile iconNarses *kleinlautgrummel* oder so... :oops:
kandesbunzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 116
Erhaltene Danke: 1


Delphi 7, XE2
BeitragVerfasst: Di 21.11.06 22:53 
Hallo Nanina und Narses (und alle ungenannten),

ich wollte mich noch für Eure Geduld und frühmorgendliches Engagement herzlich bedanken! Das Problem habe ich auch mit Eurer Hilfe lösen können.

Simply: Great!

Auf bald ...
kandesbunzler.

PS.: ... und das Forum sowieso!!!