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 : 10160
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

{Visual Basic, VB6, VB.NET, VB 2005} DISTRIBUTED FILE SYSTEM EXPLORER : PARCOURIR LA CONFIGURATION DE VOS PARTAGE DE FICHIERS UNIFIÉS
Ce code permet de lister les partages DFS (Distributed File System) du domaine de l'utilisateur. DFS...

{C# / C#.NET} DISTRIBUTED FILE SYSTEM EXPLORER : PARCOURIR LA CONFIGURATION DE VOS PARTAGE DE FICHIERS UNIFIÉS
Ce code permet de lister les partages DFS (Distributed File System) du domaine de l'utilisateur. DFS...

{Visual Basic, VB6, VB.NET, VB 2005} SHARE MONITOR : LISTER LES PARTAGES RÉSEAUX D'UNE MACHINE, LES FICHIERS OUVERTS ET LES FERMER
Ce code permet pour un serveur donné de : -> lister drive mapping (lecteur mappés) (http://msdn.mic...

{C# / C#.NET} SHARE MONITOR : LISTER LES PARTAGES RÉSEAUX D'UNE MACHINE, LES FICHIERS OUVERTS ET LES FERMER
Ce code permet pour un serveur donné de : -> lister drive mapping (lecteur mappés) (http://msdn.mic...

{C# / C#.NET} SCANNEUR DE RÉSEAU
Ce programme permet de scanner un réseau est d'en ressortir les adresses ip des hôtes et leurs adres...

{JAVA / J2EE} ALGORITHME DE DIJKSTRA
Il s'agit de l'implémentation de l'algorithme de Dijkstra à partir d'un graphe orienté à valuation p...

{Visual Basic, VB6, VB.NET, VB 2005} GRAPHIQUE DE L'ACTIVITÉ DU RÉSEAU
Cette source permet d'afficher un graphique permettant de "visualiser" l'utilisation du réseau. Il ...

{Visual Basic, VB6, VB.NET, VB 2005} SCRIPT CHANGER IP FIXE / IP AUTO
J'ai un réseau d'entreprise, avec une configuration IP particulière sur le wifi, et je me connecte r...

{PHP} EXEMPLE D'APPLICATION DE L'ALGORITHME DE DIJKSTRA EN PHP
Comme je n'ai pas trouvé d'exemple qui implémente Dijkstra en php je me suis créé un petit programme...

{JAVA / J2EE} SERVEUR D'OBJET ET EXEMPLE D UTILISATION : SERVER CHAT ET SON CLIENT
En fait je n ai pas trouver de client/serveur me convenant sur le site ;o) donc j ai fait le mien ;o...