Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi GetLongPathName (https://www.delphipraxis.net/37654-getlongpathname.html)

MasterC 8. Jan 2005 13:25


GetLongPathName
 
Hi,

GetLongPathName geht nicht, Delphi meint: "Undefinierter Bezeichner: 'GetLongPathName'";

Welche Unit brauche ich für GetLongPathName? GetShortPathName funktioniert ja.

MFG Chris.

PierreB 8. Jan 2005 13:36

Re: GetLongPathName
 
Moin,

Google hat das hier ausgespuckt:

Code:
unit PathGetLongName_Unit;

interface

uses
  Windows, SysUtils;

function PathGetLongName(const ShortPath: String): String;

implementation

type
  TGetLongPathName = function(lpszShortPath, lpszLongPath: PChar;
    cchBuffer: DWORD): DWORD; stdcall;

// -----------------------------------------------------------------------------

function PathGetLongName(const ShortPath: String): String;
var
  GetLongPathName: TGetLongPathName;
  hKernel32: THandle;
begin

  hKernel32 := LoadLibrary(kernel32);
  try
    GetLongPathName := GetProcAddress(hKernel32, 'GetLongPathNameA');

    if not Assigned(GetLongPathName) then
      RaiseLastWin32Error;

    SetLength(Result, GetLongPathName(PChar(ShortPath), nil, 0));
    SetLength(Result, GetLongPathName(PChar(ShortPath), PChar(Result),
      Length(Result)));
  finally
    FreeLibrary(hKernel32);
  end; {end try/finally}

end; {end function}

// -----------------------------------------------------------------------------

end.
Damit müsste es eigentlich gehen. ;)

tommie-lie 8. Jan 2005 13:38

Re: GetLongPathName
 
Zitat:

Zitat von MS PSDK
Windows NT and Windows 95: Include an additional header file called NewAPIs.h to make GetLongPathName available on these operating systems. The function is not implemented natively, but by a wrapper that utilizes other native functions on these systems.

Man kann also davon ausgehen, daß die VCL die Funktion nicht bereitstellt. Aber in System.pas wird sie lustigerweise in der Funktion ToLongPath() benutzt, die könntest du alternativ nehmen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:21 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