Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   ERROR:ShLink.GetPath(Buffer, Sizeof(Buffer), Data, SLGP_UNCPRIORITY) (https://www.clubdelphi.com/foros/showthread.php?t=56717)

Mav 25-05-2008 23:15:19

ERROR:ShLink.GetPath(Buffer, Sizeof(Buffer), Data, SLGP_UNCPRIORITY)
 
Código:

function estrai_path_da_lnk(filen:widestring):widestring;
var
  AnObj: IUnknown;
  ShLink: IShellLinkW;
  PFile: IPersistFile;
  Data: TWin32FindData;
  Buffer: array [0..255] of widechar;
begin
result:='';
try
  AnObj := CreateComObject(CLSID_ShellLink);
  ShLink := AnObj as IShellLinkW;
  PFile := AnObj as IPersistFile;

  PFile.Load(PWChar(FileN), STGM_READ);


  ShLink.GetPath(Buffer, Sizeof(Buffer), Data, SLGP_UNCPRIORITY);
  result := Buffer;

 except
 end;
end;

En esta linea es donde dá el siguiente error:
ShLink.GetPath(Buffer, Sizeof(Buffer), Data, SLGP_UNCPRIORITY);

[DCC Error] helper_urls.pas(153): E2033 Types of actual and formal var parameters must be identical

En ShlObj.pas:
Código:

IShellLinkW = interface(IUnknown) { sl }
    [SID_IShellLinkW]
    function GetPath(pszFile: PWideChar; cchMaxPath: Integer;
      var pfd: TWin32FindDataW; fFlags: DWORD): HResult; stdcall;

De la "Guia de Referencia de Delphi":

(E2033)Types of actual and formal var parameters must be identical:
For a variable parameter, the actual argument must be of the exact type of the formal parameter.
He cambiado declaraciones de variables, modificado parámetros ,en fin le he dado a esto muchas vueltas...No le encuentro la solución.
¿Podria alguien ayudarme? ¡ Gracias!
Saludos a todos.

xEsk 25-05-2008 23:55:25

Hola, prueba cambiando
Código Delphi [-]
Data: TWin32FindData;
por
Código Delphi [-]
Data: TWin32FindDataW;

El error ya te esta dando una pista de cual es el problema, que los tipos deben ser identicos, y si te fijas el tipo del parametro pfd es TWin32FindDataW y no TWin32FindData.

Cita:

function GetPath(pszFile: PWideChar; cchMaxPath: Integer; var pfd: TWin32FindDataW; fFlags: DWORD): HResult; stdcall;
Saludos.

Mav 26-05-2008 21:31:49

Si,si! ¡Correcto, muchas gracias!
Como no lo ví, si lo tenía delante...
Saludos:)


La franja horaria es GMT +2. Ahora son las 03:43:03.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi