Les Snippets

Connexion

Obtenir le chemin UNC d'un fichier

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 05/10/2007 14:22:17 et initié par Willi [Liste]
Vue : 5007
Catégorie(s) : Fichier / Disque
Langages dispo pour ce code :
- VB6, VBA
- Delphi 5



Langage : VB6 , VBA
Date ajout : 05/10/2007
Posté par Willi [Liste]

Private Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocalName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long

Public Function GetUNCPath(ByVal PathName As String) As String

    Dim sUNCPath As String
    sUNCPath = String(260, 0)
    
    If WNetGetConnection(Left$(PathName, 2), sUNCPath, 260) = 0 Then
    
        sUNCPath = Trim(Left(sUNCPath, InStr(sUNCPath, vbNullChar) - 1))
        sUNCPath = sUNCPath & Mid$(PathName, 3)
        
    End If
    
    GetUNCPath = sUNCPath
    
End Function

Remarque :
Utilisation:

Dim sCheminUNC as String
sCheminUNC = GetUNCPath("Z:\MonFichier.txt")
Langage : Delphi 5
Date ajout : 09/10/2007
Posté par Loulibier [Liste]
function GetUNCPath(const sPathName : string): string;
var
  pcUNCPath : array [0..255] of char;
  iLength   : cardinal;
begin
  iLength := 256;
  if WNetGetConnection(PChar(LeftStr(sPathName, 2)), pcUNCPath, iLength) = 0 then
    Result := pcUNCPath;
end;
Remarque :
Utilisation:

var
sCheminUNC : string;
begin
  sCheminUNC := GetUNCPath('Z:\MonFichier.txt');
end;

Snippets en rapport avec : Chemin, Unc, Absolu, Réseau



Codes sources en rapport avec : Chemin, Unc, Absolu, Réseau

{JAVA / J2EE} TROUVER SON CHEMIN DANS UN LABYRINTHE
programme permettant de rechercher la sortie dans un labyrinthe a l'aide d'un algorithme de backtrac...

{Visual Basic, VB6, VB.NET, VB 2005} RACCOURCIR UN CHEMIN (PATH) OU URL INTERNET
Je pensais que je trouverai cette source sur le site, mais je n'ai rien trouvé! Il faut dire que tro...

{Visual Basic, VB6, VB.NET, VB 2005} YET ANOTHER PROCESS MONITOR : REMOTE VERSION
Bonjour à tous, YAPM (Yet Another (remote) Process Monitor) est un programme de monitoring avancé...

{C / C++ / C++.NET} TRANSFERT DE FICHIER TCP [GCC - GTK]
Transfert de fichier via socket en langage C : L'utilisateur du serveur choisie le fichier que le c...

{Flash} LAN CHESS, JEU D'ÉCHEC EN RÉSEAU
Voici un jeux d'échec expérimental avec lequel on peu jouer en réseau.J'utilise un socket pour établ...

{Assembleur} DLL ALGORYTHME DE RECHERCHE DE CHEMIN EN A STAR, A*, FASM
Je cherchais un algorithme qui me trouvait un chemin entre deux points avec des obstacles réutilisab...

{Python} FTP AVEC PYTHON
Pratique pour par exemple transférer un dossier d'images (gallerie) vers un FTP distant. Genre Orang...

{Visual Basic, VB6, VB.NET, VB 2005} FOLDER HELPER - DOSSIERS SPECIAUX, MANIPULATION DE DOSSIERS, ET PLUS... [MODULE DE CLASSE]
voici une classe que j'avais commencé il y a un moment, elle attendait dans son coin... elle deva...

{Delphi} DJIKSTRA EN MODE GRAPHIQUE
Algorithme de Djikstra: Afin de rechercher dans un graphe le plus court chemin à traverser d'un po...

{Visual Basic, VB6, VB.NET, VB 2005} NETWORK MONITOR INTER-PROCESS
Bonjour, Voici un moment que je n'avais pas deposé une source alors voici un petit code pour nove...