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 : 2572
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} ACTIVE DIRECTORY : LISTE LES PC DU RÉSEAU
Ce script tout simple se connecte à l'AD, liste les pc du réseau et écrit en sortie un fichier txt q...

{C# / C#.NET} MODIFIER LA CONFIGURATION DU RÉSEAU LOCAL
étant donné ne pas avoir trouvé de codes(sur le NET) afin de pouvoir changer la configuration IP de...

{JAVA / J2EE} CHAT CLIENT-SERVEUR {NOUVEL CONCEPT D'IMPLEMENTATION}
Cette application permet d'implmenter un chat multiuser et offre la possibilité de transfert de fich...

{Visual Basic, VB6, VB.NET, VB 2005} ECRITURE DANS LA BASE DE REGISTRE D'UN ORDINATEUR DISTANT
Au départ, il s'agissait de corriger une erreur de DNS dans certains journaux d'évènements de machin...

{Visual Basic, VB6, VB.NET, VB 2005} MESSAGERIE INSTANTANÉE EN XP ET VISTA SUR RÉSEAU LOCAL
Pour ceux qui, comme moi, ont pas mal galérés à essayer d'envoyer des Net Send entre un poste XP et ...

{Visual Basic, VB6, VB.NET, VB 2005} AFFICHAGE DU CHEMIN D'UN MESSAGE OUTLOOK
Lorsque l'on effectue une recheche avancée de message sous outlook 2003 il n'est pas possible d'acce...

{C# / C#.NET} NETACCESS 2.0 RC2 : LIBRAIRIE POUR APPLICATION CLIENTS/SERVEUR
NetAccess est un librairie fournissant une méthode d'implémentation d'application client/serveur uti...

{PHP} DÉTERMINATION DU CHEMIN D'INDEXAGE MENANT À UNE VALEUR DANS UN TABLEAU MULTI-DIMENSIONNEL
Cette fonction sert à trouver tous les indices qu'il faut suivre dans un tableau multidimentionnel p...

{C / C++ / C++.NET} CONVERTIR CHEMIN RELATIF EN CHEMIN ABSOLUE (POUR DISQUE DUR)
ce code est un complement de l'utilisation de GetFullPathName() qui necessite un fichier existant ...

{C# / C#.NET} AUDIO STREAMING LAN
Ce petit programme est basé sur les wrappers des API waveIn et waveOut que Ianier Munoz a publié sur...