Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi MapUNCPathToDrivePath (https://www.delphipraxis.net/212403-mapuncpathtodrivepath.html)

PeterPanino 6. Feb 2023 11:18

MapUNCPathToDrivePath
 
Ich habe mir eine Funktion geschrieben, die einen UNC-Pfad (beginnt mit "\\") in den zugehörigen Drive-Path (startet z.B. mit "C:\") konvertiert:

Delphi-Quellcode:
function MapUNCPathToDrivePath(UNCPath: string): string;
var
  DrivePath: array[0..MAX_PATH] of Char;
  BufferSize: DWORD;
  Error: DWORD;
begin
  BufferSize := SizeOf(DrivePath);
  Error := Winapi.Windows.WNetGetUniversalName(PChar(UNCPath), UNIVERSAL_NAME_INFO_LEVEL, @DrivePath[0], BufferSize);
  if Error = NO_ERROR then
  begin
    Result := DrivePath;
    CodeSite.Send('MapUNCPathToDrivePath: NO_ERROR');
  end
  else
  begin
    Result := '';
    CodeSite.Send('MapUNCPathToDrivePath: ERROR', Error);
  end;
end;
Auf meinem Test-System ist "\\Mac\Home" äquivalent zu "Y:\". Beides wird im Windows File Explorer äquivalent angezeigt.

Aber diese Funktion gibt einen Leerstring und den Fehlercode 1200 zurück:

Delphi-Quellcode:
MapUNCPathToDrivePath('\\Mac\Home');

himitsu 6. Feb 2023 12:16

AW: MapUNCPathToDrivePath
 
NIEMALS bei gerade erstellten Threads/Postings das [ZURÜCK] im Browser benutzen. :!:

dort geht's weiter
https://www.delphipraxis.net/212404-...drivepath.html


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