Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Problem mit DoFileWork() aus CodeLibrary (https://www.delphipraxis.net/133055-problem-mit-dofilework-aus-codelibrary.html)

mh166 24. Apr 2009 14:31


Problem mit DoFileWork() aus CodeLibrary
 
Hallo allerseits,

ich hab aus der CodeLibrary diesen Tipp genommen und wollte das in mein Projekt einbauen. Allerdings bricht Delphi beim compilieren immer mit dem Fehler ab:
Code:
E2010 Inkompatible Typen: 'AnsiChar' und 'Char'
E2010 Inkompatible Typen: 'AnsiChar' und 'Char'
E2010 Inkompatible Typen: '_SHFILEOPSTRUCTA' und '_SHFILEOPSTRUCTW'
Die ersten beiden Fehler beziehen sich auf PAnsiChar(), der letzte auf den SHFileOperationA-Aufruf.

Ich hab echt keine Ahnung wieso das nicht [mehr?] funktioniert ... Wäre schön, wenn ihr mir helfen könntet. :)

mfg, mh166

Bernhard Geyer 24. Apr 2009 14:36

Re: Problem mit DoFileWork() aus CodeLibrary
 
Glaskugel auspack: Probierst du es mit Delphi 2009?

Ändere
Delphi-Quellcode:
  SHFileOpStruct: TSHFileOpStruct;
mal auf
Delphi-Quellcode:
  SHFileOpStruct: TSHFileOpStructA;
oder

Delphi-Quellcode:
function DoFileWork(aOperation: FILEOP_FLAGS; aFrom, aTo: String;
    Flags: FILEOP_FLAGS): Integer;
var
  FromPath, ToPath: AnsiString;
  SHFileOpStruct: TSHFileOpStruct;
begin
  FromPath := aFrom + #0#0;
  ToPath := aTo + #0#0;
  with SHFileOpStruct do
  begin
    Wnd := 0;
    wFunc := aOperation;
    pFrom := PChar(FromPath);
    if ToPath <> '' then
    begin
      pTo := PChar(ToPath)
    end else begin // target available
      pTo := nil;
    end; // target not available
    fFlags := Flags;
  end; // structure
  Result := SHFileOperation(SHFileOpStruct);
end;

Reinhardtinho 24. Apr 2009 14:38

Re: Problem mit DoFileWork() aus CodeLibrary
 
In deinem Profil steht Delphi 6, mit Delphi 5 funktioniert es.

mirage228 24. Apr 2009 14:39

Re: Problem mit DoFileWork() aus CodeLibrary
 
Oder Du nimmst meine Wrapper-Unit für SHFileOperation aus der Code-Library ;-)

Viele Grüße

mh166 24. Apr 2009 15:37

Re: Problem mit DoFileWork() aus CodeLibrary
 
Zitat:

Zitat von Bernhard Geyer
Glaskugel auspack: Probierst du es mit Delphi 2009?

Ich glaub so eine brauch ich auch mal. ;) Guter Treffer! :D

@Reinhardtinho: Ich glaub ich muss mein Profil mal aktualisieren. 8) Hat sich halt einiges verändert seit dem man auf Arbeit was programmieren muss.

@mirage228: Auch ne Idee. Allerdings brauch ich die Funktion eh nur mal kurz. Aber danke für den Hinweis, kann ich bestimmt mal gebrauchen. :)

Danke euch allen.


mfg, mh166

nytaiceman 20. Jul 2010 13:28

AW: Re: Problem mit DoFileWork() aus CodeLibrary
 
Zitat:

Zitat von Bernhard Geyer (Beitrag 906031)
Glaskugel auspack: Probierst du es mit Delphi 2009?

Ändere
Delphi-Quellcode:
  SHFileOpStruct: TSHFileOpStruct;
mal auf
Delphi-Quellcode:
  SHFileOpStruct: TSHFileOpStructA;

Könnte jemand das Codebeispiel in der Library bitte entsprechend anpassen? Vielen herzlichen Dank für eure Hilfe. :thumb:

himitsu 20. Jul 2010 15:06

AW: Problem mit DoFileWork() aus CodeLibrary
 
So wäre es aber Ansi ... ich würde es eher andersrum ändern.

ab D2009 Unicode (davor ANSI):
Delphi-Quellcode:
function DoFileWork(aOperation: FILEOP_FLAGS; aFrom, aTo: String;
    Flags: FILEOP_FLAGS): Integer;
var
  SHFileOpStruct: TSHFileOpStruct;
begin
  with SHFileOpStruct do
  begin
    Wnd := 0;
    wFunc := aOperation;
    pFrom := PChar(aFrom + #0);
    if aTo <> '' then
      pTo := PChar(aTo + #0)
    else
      pTo := nil;
    fFlags := Flags;
  end;
  Result := SHFileOperation(SHFileOpStruct);
end;
immer ANSI:
Delphi-Quellcode:
function DoFileWork(aOperation: FILEOP_FLAGS; aFrom, aTo: AnsiString;
    Flags: FILEOP_FLAGS): Integer;
var
  SHFileOpStruct: TSHFileOpStructA;
begin
  with SHFileOpStruct do
  begin
    Wnd := 0;
    wFunc := aOperation;
    pFrom := PAnsiChar(aFrom + #0);
    if aTo <> '' then
      pTo := PAnsiChar(aTo + #0)
    else
      pTo := nil;
    fFlags := Flags;
  end;
  Result := SHFileOperationA(SHFileOpStruct);
end;

mirage228 20. Jul 2010 15:20

AW: Problem mit DoFileWork() aus CodeLibrary
 
Die von mir erstellte und hier verlinkte Wrapper-Unit für SHFileOperation sollte ohne weitere Änderungen Delphi 2009 und 2010-kompatibel sein...


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:45 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz