Page 1 sur 1
Lister tous les Dossiers partagé sur un Réseau
Publié : jeu. 13/avr./2017 14:32
par celtic88
Bon Jour,
Ancien sujet sans réponse
viewtopic.php?f=3&t=246&view=next
le code
Code : Tout sélectionner
Structure _sWNetEnum
sNetEnum.NetResource[512]
EndStructure
Procedure.b EnumFuncLAN(*NetResource.NetResource=0)
Protected Enum.i,Count.l = $FFFFFFFF,Buffer._sWNetEnum,isizBuffer.l= 512*SizeOf(NetResource)
If WNetOpenEnum_(#RESOURCE_GLOBALNET, #RESOURCETYPE_ANY, 0, *NetResource, @Enum) = #NO_ERROR
If WNetEnumResource_(Enum, @Count, @Buffer, @isizBuffer) = #NO_ERROR
With Buffer
For i = 0 To Count - 1
If \sNetEnum[i]\dwType = #RESOURCETYPE_DISK
Debug PeekS(\sNetEnum[i]\lpRemoteName)
EndIf
If \sNetEnum[i]\dwUsage & #RESOURCEUSAGE_CONTAINER
EnumFuncLAN(@\sNetEnum[i])
EndIf ;
Next
EndWith
WNetCloseEnum_(Enum);
EndIf
EndIf
EndProcedure
EnumFuncLAN()
Re: Lister tous les Dossiers partagé sur un Réseau
Publié : jeu. 13/avr./2017 15:22
par Ar-S
Je n'avais même pas vu le sujet mais c'est excellent.
Merci

Re: Lister tous les Dossiers partagé sur un Réseau
Publié : jeu. 13/avr./2017 16:26
par Zorro
ben dans ce cas, pourquoi n'as tu pas poursuivi le premier topic ??
en creer un deuxieme n'a pas de sens .... surtout si c'est le meme sujet
Merci pour le code

Re: Lister tous les Dossiers partagé sur un Réseau
Publié : jeu. 13/avr./2017 22:54
par celtic88
Merci pour vos commentaires
@Dobro
j'ai vu que c'était trop ancien "2004" j'avais 7 ans a cette epoque

,,,et puit pour quoi pas créer un qui n'existe pas avant.
Re: Lister tous les Dossiers partagé sur un Réseau
Publié : ven. 14/avr./2017 14:43
par Mesa
Plus de fonctions sur les sessions réseaux ici:
http://www.purebasic.fr/english/viewtop ... 12&t=61318
Et pour ceux qui voudraient plus de détails avec le code de dessus:
Code : Tout sélectionner
Structure _sWNetEnum
sNetEnum.NetResource[512]
EndStructure
Procedure DisplayError(err)
; erreurs courantes:
Select err
Case #ERROR_NO_MORE_ITEMS
Debug "There are no more entries. The buffer contents are undefined."
found = #True
Case #ERROR_NOT_CONTAINER
Debug "The lpNetResource parameter does Not point To a container."
found = #True
Case #ERROR_INVALID_PARAMETER
Debug "Either the dwScope Or the dwType parameter is invalid, Or there is an invalid combination of parameters."
found = #True
Case #ERROR_NO_NETWORK
Debug "The network is unavailable."
found = #True
Case #ERROR_EXTENDED_ERROR
Debug "A network-specific error occurred. To obtain a description of the error, CALL the WNetGetLastError function."
found = #True
Case #ERROR_INVALID_ADDRESS
Debug "A remote network resource name supplied IN the NETRESOURCE Structure resolved To an invalid network address."
found = #True
Case #ERROR_MORE_DATA
Debug "More entries are available With subsequent calls. For more information, see the following Remarks section."
found = #True
Case #ERROR_INVALID_HANDLE
Debug "The handle specified by the hEnum parameter is Not valid."
found = #True
Default
found = #False
EndSelect
;https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681381(v=vs.85).aspx
If found = #False
Select err
Case 0 To 499
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681382(v=vs.85).aspx")
Case 500 To 999
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681388(v=vs.85).aspx")
Case 1000 To 1299
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681383(v=vs.85).aspx")
Case 1300 To 1699
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681385(v=vs.85).aspx")
Case 1700 To 3999
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681386(v=vs.85).aspx")
Case 4000 To 5999
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681387(v=vs.85).aspx")
Case 6000 To 8199
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681389(v=vs.85).aspx")
Case 8200 To 8999
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681390(v=vs.85).aspx")
Case 9000 To 11999
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681391(v=vs.85).aspx")
Case 12000 To 15999
RunProgram("https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms681384(v=vs.85).aspx")
Default
Debug "Erreur inconnue ! ! !"
EndSelect
EndIf
EndProcedure
Global level = 0
Procedure.b EnumFuncLAN(*NetResource.NetResource=0)
Protected Enum.i,Count.l = $FFFFFFFF,Buffer._sWNetEnum,isizBuffer.l= 512*SizeOf(NetResource)
Protected r1, r2
r1=WNetOpenEnum_(#RESOURCE_GLOBALNET, #RESOURCETYPE_ANY, 0, *NetResource, @Enum)
If r1 = #NO_ERROR
r2=WNetEnumResource_(Enum, @Count, @Buffer, @isizBuffer)
If r2 = #NO_ERROR
Debug "Nbre d'entrées: " + Count
Debug "==========================="
With Buffer
For i = 0 To Count - 1
Debug "Entrée n: " + Str(i) + "/" + Str(Count) + " of level " + Str(level)
Select \sNetEnum[i]\dwScope
Case #RESOURCE_CONNECTED
Debug "RESOURCE_CONNECTED"
Debug "Enumerate currently connected resources. The dwUsage member cannot be specified."
Case #RESOURCE_GLOBALNET
Debug "RESOURCE_GLOBALNET"
Debug "Enumerate all resources on the network. The dwUsage member is specified."
Case #RESOURCE_REMEMBERED
Debug "RESOURCE_REMEMBERED"
Debug "Enumerate remembered (persistent) connections. The dwUsage member cannot be specified."
Default
Debug "scope unknown"
EndSelect
Select \sNetEnum[i]\dwType
Case #RESOURCETYPE_ANY
Debug "RESOURCETYPE_ANY"
Case #RESOURCETYPE_DISK
Debug "RESOURCETYPE_DISK"
Debug PeekS(\sNetEnum[i]\lpRemoteName)
Case #RESOURCETYPE_PRINT
Debug "RESOURCETYPE_PRINT"
Case #RESOURCETYPE_UNKNOWN
Debug "RESOURCETYPE_UNKNOWN"
Default
Debug "Type unknown"
EndSelect
Select \sNetEnum[i]\dwDisplayType
Case #RESOURCEDISPLAYTYPE_GENERIC
Debug "The method used To display the object does Not matter."
Case #RESOURCEDISPLAYTYPE_DOMAIN
Debug "The object should be displayed As a domain."
Case #RESOURCEDISPLAYTYPE_SERVER
Debug "The object should be displayed As a server."
Case #RESOURCEDISPLAYTYPE_SHARE
Debug "The object should be displayed As a share."
Case #RESOURCEDISPLAYTYPE_FILE
Debug "The object should be displayed As a file."
Case #RESOURCEDISPLAYTYPE_GROUP
Debug "The object should be displayed As a group."
Case 6;#RESOURCEDISPLAYTYPE_NETWORK
Debug "The object should be displayed As a network."
Case 7;#RESOURCEDISPLAYTYPE_ROOT
Debug "The object should be displayed As a logical root For the entire network."
Case 8;#RESOURCEDISPLAYTYPE_SHAREADMIN
Debug "The object should be displayed As a administrative share."
Case 9;#RESOURCEDISPLAYTYPE_DIRECTORY
Debug "The object should be displayed As a directory."
Case 10;#RESOURCEDISPLAYTYPE_TREE
Debug "The object should be displayed As a tree. This display type was used For a NetWare Directory Service (NDS) tree by the NetWare Workstation service supported on Windows XP And earlier."
Case 11;#RESOURCEDISPLAYTYPE_NDSCONTAINER
Debug "The object should be displayed As a Netware Directory Service container. This display type was used by the NetWare Workstation service supported on Windows XP And earlier."
Default
Debug "DisplayType unknown"
EndSelect
If \sNetEnum[i]\dwScope = #RESOURCE_GLOBALNET
Select \sNetEnum[i]\dwUsage
Case #RESOURCEUSAGE_CONNECTABLE
Debug "The resource is a connectable resource; the name pointed to by the lpRemoteName member can be passed to the WNetAddConnection function to make a network connection."
Case #RESOURCEUSAGE_CONTAINER
Debug "The resource is a container resource; the name pointed to by the lpRemoteName member can be passed to the WNetOpenEnum function to enumerate the resources in the container."
Case 4;#RESOURCEUSAGE_NOLOCALDEVICE
Debug "The resource is Not a local device."
Case 8;#RESOURCEUSAGE_SIBLING
Debug "The resource is a sibling. This value is Not used by Windows."
Case 10;#RESOURCEUSAGE_ATTACHED
Debug "The resource must be attached. This value specifies that a function To enumerate resource this should fail If the caller is Not authenticated, even If the network permits Enumeration without authentication."
Default
Debug "Usage unknown"
EndSelect
EndIf
If \sNetEnum[i]\lpLocalName <> 0
Debug "LocalName:" + PeekS(\sNetEnum[i]\lpLocalName)
EndIf
If \sNetEnum[i]\lpRemoteName <> 0
Debug "RemoteName: " + PeekS(\sNetEnum[i]\lpRemoteName)
EndIf
If \sNetEnum[i]\lpComment <> 0
Debug "Comment: " + PeekS(\sNetEnum[i]\lpComment)
EndIf
If \sNetEnum[i]\lpProvider <> 0
Debug "Provider: " + PeekS(\sNetEnum[i]\lpProvider)
EndIf
Debug "================================="
If \sNetEnum[i]\dwUsage & #RESOURCEUSAGE_CONTAINER
Debug "RESOURCEUSAGE_CONTAINER"
level = level + 1
EnumFuncLAN(@\sNetEnum[i])
Else
Debug "pas de RESOURCEUSAGE_CONTAINER"
EndIf ;
Next
EndWith
WNetCloseEnum_(Enum);
Else
Debug "Erreur WNetEnumResource r2: " + r2
DisplayError(r2)
Debug "------------------------------------"
EndIf
Else
Debug "Erreur WNetOpenEnum r1: " + r1
DisplayError(r1)
Debug "--------------------------------------"
EndIf
EndProcedure
EnumFuncLAN()
M.
Re: Lister tous les Dossiers partagé sur un Réseau
Publié : ven. 14/avr./2017 15:57
par celtic88
@Mesa
J 'ai pas vu ce sujet
merci
