IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Access Discussion :

Connaitre le nom du propriétaire d'un fichier


Sujet :

Access

  1. #1
    Nouveau Candidat au Club
    Inscrit en
    Septembre 2005
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Septembre 2005
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Connaitre le nom du propriétaire d'un fichier
    Bonjour,

    est-il possible d'accéder aux propriétés d'un fichier, notament au nom du propriétaire, en VBA?

    Merci

  2. #2
    Membre habitué
    Inscrit en
    Mai 2005
    Messages
    125
    Détails du profil
    Informations forums :
    Inscription : Mai 2005
    Messages : 125
    Points : 128
    Points
    128
    Par défaut
    de quel type de fichier tu parle

  3. #3
    Membre averti

    Profil pro
    Inscrit en
    Mai 2004
    Messages
    236
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 236
    Points : 310
    Points
    310
    Par défaut
    ça doit être possible en passant par des api windows.

  4. #4
    Nouveau Candidat au Club
    Inscrit en
    Septembre 2005
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Septembre 2005
    Messages : 2
    Points : 1
    Points
    1
    Par défaut
    n'importe quel fichier...

    quelles api windows?
    pour l'instant je n'ai pas trouvé d'exemple sur le net...

  5. #5
    Membre averti

    Profil pro
    Inscrit en
    Mai 2004
    Messages
    236
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 236
    Points : 310
    Points
    310
    Par défaut
    Il me semble que certaines api de "advapi32.dll" devrait correspondre à ton problème.

  6. #6
    Nouveau membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Avril 2004
    Messages : 37
    Points : 32
    Points
    32
    Par défaut
    Bonjour, pouvez-vous indiquer comment ont manipule cette api pour connaître le propriétaire du fichier, avez-vous un exemple ?
    Merci...

  7. #7
    Expert éminent sénior

    Avatar de Tofalu
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Octobre 2004
    Messages
    9 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Octobre 2004
    Messages : 9 501
    Points : 32 311
    Points
    32 311
    Par défaut
    Cette propriété n'est disponible que sur les partitions ntfs je crois Si ton produit a besoin d'une partition propre, je doute de l'efficacité

  8. #8
    Nouveau membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Avril 2004
    Messages : 37
    Points : 32
    Points
    32
    Par défaut
    C'est bien du ntfs, mais je ne sais pas comment déclarer et manipuler l'api citée plus haut. Sais-tu comment on fait?

  9. #9
    Nouveau membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Avril 2004
    Messages : 37
    Points : 32
    Points
    32
    Par défaut
    J'ai trouvé ça sur http://support.microsoft.com et sur xp ça fonctionne, tu met tout le code dans un form avec un bouton Command1 :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    Private Declare Function GetFileSecurity Lib "advapi32.dll" _
          Alias "GetFileSecurityA" ( _
          ByVal lpFileName As String, _
          ByVal RequestedInformation As Long, _
          pSecurityDescriptor As Byte, _
          ByVal nLength As Long, _
          lpnLengthNeeded As Long _
          ) As Long
     
       Private Declare Function GetSecurityDescriptorOwner Lib "advapi32.dll" _
          (pSecurityDescriptor As Any, _
          pOwner As Long, _
          lpbOwnerDefaulted As Long) As Long
     
       Private Declare Function LookupAccountSid Lib "advapi32.dll" _
          Alias "LookupAccountSidA" ( _
          ByVal lpSystemName As String, _
          ByVal Sid As Long, _
          ByVal name As String, _
          cbName As Long, _
          ByVal ReferencedDomainName As String, _
          cbReferencedDomainName As Long, _
          peUse As Long) As Long
     
       Private Declare Function GetWindowsDirectory Lib "kernel32" _
          Alias "GetWindowsDirectoryA" ( _
          ByVal lpBuffer As String, _
          ByVal nSize As Long) As Long
     
       Private Const OWNER_SECURITY_INFORMATION = &H1
       Private Const ERROR_INSUFFICIENT_BUFFER = 122&
       Private Const MAX_PATH = 255
     
       Sub Command1_Click()
     
          Dim szfilename As String   ' File name to retrieve the owner for
          Dim bSuccess As Long       ' Status variable
          Dim sizeSD As Long         ' Buffer size to store Owner's SID
          Dim pOwner As Long         ' Pointer to the Owner's SID
          Dim name As String         ' Name of the file owner
          Dim domain_name As String  ' Name of the first domain for the owner
          Dim name_len As Long       ' Required length for the owner name
          Dim domain_len As Long     ' Required length for the domain name
          Dim sdBuf() As Byte        ' Buffer for Security Descriptor
          Dim nLength As Long        ' Length of the Windows Directory
          Dim deUse As Long          ' Pointer to a SID_NAME_USE enumerated
                                     ' type indicating the type of the account
     
        ' Initialize some required variables.
     
          bSuccess = 0
          name = ""
          domain_name = ""
          name_len = 0
          domain_len = 0
          pOwner = 0
          szfilename = Space(MAX_PATH)
     
       ' Obtain the path to the Windows Directory and use the notepad.exe file
       ' as it should be on the system.
     
       nLength = GetWindowsDirectory(szfilename, Len(szfilename))
       If nLength = 0 Then
         MsgBox "Unable to Obtain the Windows Directory"
       End If
     
       'szfilename = Left$(szfilename, nLength) & "\notepad.exe"
       '*********************************************
       szfilename = "c:\"
       '*********************************************
     
       ' Call GetFileSecurity the first time to obtain the size of the
       ' buffer required for the Security Descriptor.
     
       bSuccess = GetFileSecurity( _
               szfilename, _
               OWNER_SECURITY_INFORMATION, _
               0, _
               0&, _
               sizeSD)
     
       If (bSuccess = 0) And _
          (Err.LastDllError <> ERROR_INSUFFICIENT_BUFFER) Then
             MsgBox "GetLastError returned  : " & Err.LastDllError
       End If
     
       ' Create a buffer of the required size and call GetFileSecurity again.
     
          ReDim sdBuf(0 To sizeSD - 1) As Byte
     
       ' Fill the buffer with the security descriptor of the object specified
       ' by the szfilename parameter. The calling process must have the right
       ' to view the specified aspects of the object's security status.
     
       bSuccess = GetFileSecurity( _
               szfilename, _
               OWNER_SECURITY_INFORMATION, _
               sdBuf(0), _
               sizeSD, _
               sizeSD)
     
       If (bSuccess <> 0) Then
     
       ' Obtain the owner's SID from the Security Descriptor.
       '
          bSuccess = GetSecurityDescriptorOwner(sdBuf(0), pOwner, 0&)
          If (bSuccess = 0) Then
              MsgBox "GetLastError returned : " & Err.LastDllError
          End If
     
       ' Retrieve the name of the account and the name of the first
       ' domain on which this SID is found.  Passes in the Owner's SID
       ' obtained previously.  Call LookupAccountSid twice, the first time
       ' to obtain the required size of the owner and domain names.
     
          bSuccess = LookupAccountSid(vbNullString, pOwner, name, name_len, _
                                      domain_name, domain_len, deUse)
          If (bSuccess = 0) And _
             (Err.LastDllError <> ERROR_INSUFFICIENT_BUFFER) Then
             MsgBox "GetLastError returned : " & Err.LastDllError
          End If
     
       '  Allocate the required space in the name and domain_name string
       '  variables. Allocate 1 byte less to avoid the appended NULL character.
       '
          name = Space(name_len - 1)
          domain_name = Space(domain_len - 1)
     
       '  Call LookupAccountSid again to actually fill in the name of the owner
       '  and the first domain.
       '
          bSuccess = LookupAccountSid(vbNullString, pOwner, name, name_len, _
                                      domain_name, domain_len, deUse)
          If bSuccess = 0 Then
              MsgBox "GetLastError returned : " & Err.LastDllError
          End If
     
          MsgBox "The Owner of " & szfilename & " is " & name
     
          End If
     
       End Sub
    ++

Discussions similaires

  1. Réponses: 5
    Dernier message: 12/08/2007, 15h33
  2. Comment ouvrir un fichier sans connaitre son nom
    Par APoLLoN1234 dans le forum C++
    Réponses: 8
    Dernier message: 10/09/2006, 18h04
  3. [XSLT]connaître le nom du fichier de travail
    Par luta dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 26/07/2006, 11h56
  4. Réponses: 8
    Dernier message: 23/06/2006, 22h53
  5. Réponses: 2
    Dernier message: 26/06/2002, 13h16

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo