Combinaison constantes...
Le
NeoB
Bonjour à tous,
J'utilise l'API NetServerEnum avec les constantes ci-dessous pour lister des
machines dans mon domaine.
Afin de ne lister que certains types de machines, je peux combiner les
constantes avec l'opérateur OR.
Ex: SV_TYPE_SERVER OR SV_TYPE_SQLSERVER OR SV_TYPE_DOMAIN_CTRL
Jusque là, aucun problème.
La constante SV_TYPE_ALL permet de lister tous les types de machines.
Question:
Comment exclure un type de machine précis. Par exemple j'aimerais lister
toutes les machines ( SV_TYPE_ALL ) mais exclure tous les types
SV_TYPE_SERVER_NT par exemple.
SV_TYPE_ALL AND NOT SV_TYPE_SERVER_NT ne fonction pas (XOR non plus). Je
sais qu'il y a une question de masque de bits mais je n'y arrive pas.
Est-ce possible ?
Merci pour vos lumières.
NéoB
Liste des constantes :
Private Const SV_TYPE_WORKSTATION As Long = &H1
Private Const SV_TYPE_SERVER As Long = &H2 ' All Servers
Private Const SV_TYPE_SQLSERVER As Long = &H4 ' SQL Server
Private Const SV_TYPE_DOMAIN_CTRL As Long = &H8
Private Const SV_TYPE_DOMAIN_BAKCTRL As Long = &H10
Private Const SV_TYPE_TIME_SOURCE As Long = &H20
Private Const SV_TYPE_AFP As Long = &H40
Private Const SV_TYPE_NOVELL As Long = &H80
Private Const SV_TYPE_DOMAIN_MEMBER As Long = &H100
Private Const SV_TYPE_PRINTQ_SERVER As Long = &H200
Private Const SV_TYPE_DIALIN_SERVER As Long = &H400
Private Const SV_TYPE_XENIX_SERVER As Long = &H800
Private Const SV_TYPE_SERVER_UNIX As Long = SV_TYPE_XENIX_SERVER
Private Const SV_TYPE_NT As Long = &H1000
Private Const SV_TYPE_WFW As Long = &H2000
Private Const SV_TYPE_SERVER_MFPN As Long = &H4000
Private Const SV_TYPE_SERVER_NT As Long = &H8000
Private Const SV_TYPE_POTENTIAL_BROWSER As Long = &H10000
Private Const SV_TYPE_BACKUP_BROWSER As Long = &H20000
Private Const SV_TYPE_MASTER_BROWSER As Long = &H40000
Private Const SV_TYPE_DOMAIN_MASTER As Long = &H80000
Private Const SV_TYPE_SERVER_OSF As Long = &H100000
Private Const SV_TYPE_SERVER_VMS As Long = &H200000
Private Const SV_TYPE_WINDOWS As Long = &H400000 '/* Windows95 and above */
Private Const SV_TYPE_DFS As Long = &H800000 '/* Root of a DFS tree */
Private Const SV_TYPE_CLUSTER_NT As Long = &H1000000 '/* NT Cluster */
Private Const SV_TYPE_DCE As Long = &H10000000 '/* IBM DSS (Directory and
Security Services) or equivalent */
Private Const SV_TYPE_ALTERNATE_XPORT As Long = &H20000000 '/* return list
for alternate transport */
Private Const SV_TYPE_LOCAL_LIST_ONLY As Long = &H40000000 '/* Return local
list only */
Private Const SV_TYPE_DOMAIN_ENUM As Long = &H80000000
Private Const SV_TYPE_ALL As Long = &HFFFFFFFF '/* handy for NetServerEnum2
*/
J'utilise l'API NetServerEnum avec les constantes ci-dessous pour lister des
machines dans mon domaine.
Afin de ne lister que certains types de machines, je peux combiner les
constantes avec l'opérateur OR.
Ex: SV_TYPE_SERVER OR SV_TYPE_SQLSERVER OR SV_TYPE_DOMAIN_CTRL
Jusque là, aucun problème.
La constante SV_TYPE_ALL permet de lister tous les types de machines.
Question:
Comment exclure un type de machine précis. Par exemple j'aimerais lister
toutes les machines ( SV_TYPE_ALL ) mais exclure tous les types
SV_TYPE_SERVER_NT par exemple.
SV_TYPE_ALL AND NOT SV_TYPE_SERVER_NT ne fonction pas (XOR non plus). Je
sais qu'il y a une question de masque de bits mais je n'y arrive pas.
Est-ce possible ?
Merci pour vos lumières.
NéoB
Liste des constantes :
Private Const SV_TYPE_WORKSTATION As Long = &H1
Private Const SV_TYPE_SERVER As Long = &H2 ' All Servers
Private Const SV_TYPE_SQLSERVER As Long = &H4 ' SQL Server
Private Const SV_TYPE_DOMAIN_CTRL As Long = &H8
Private Const SV_TYPE_DOMAIN_BAKCTRL As Long = &H10
Private Const SV_TYPE_TIME_SOURCE As Long = &H20
Private Const SV_TYPE_AFP As Long = &H40
Private Const SV_TYPE_NOVELL As Long = &H80
Private Const SV_TYPE_DOMAIN_MEMBER As Long = &H100
Private Const SV_TYPE_PRINTQ_SERVER As Long = &H200
Private Const SV_TYPE_DIALIN_SERVER As Long = &H400
Private Const SV_TYPE_XENIX_SERVER As Long = &H800
Private Const SV_TYPE_SERVER_UNIX As Long = SV_TYPE_XENIX_SERVER
Private Const SV_TYPE_NT As Long = &H1000
Private Const SV_TYPE_WFW As Long = &H2000
Private Const SV_TYPE_SERVER_MFPN As Long = &H4000
Private Const SV_TYPE_SERVER_NT As Long = &H8000
Private Const SV_TYPE_POTENTIAL_BROWSER As Long = &H10000
Private Const SV_TYPE_BACKUP_BROWSER As Long = &H20000
Private Const SV_TYPE_MASTER_BROWSER As Long = &H40000
Private Const SV_TYPE_DOMAIN_MASTER As Long = &H80000
Private Const SV_TYPE_SERVER_OSF As Long = &H100000
Private Const SV_TYPE_SERVER_VMS As Long = &H200000
Private Const SV_TYPE_WINDOWS As Long = &H400000 '/* Windows95 and above */
Private Const SV_TYPE_DFS As Long = &H800000 '/* Root of a DFS tree */
Private Const SV_TYPE_CLUSTER_NT As Long = &H1000000 '/* NT Cluster */
Private Const SV_TYPE_DCE As Long = &H10000000 '/* IBM DSS (Directory and
Security Services) or equivalent */
Private Const SV_TYPE_ALTERNATE_XPORT As Long = &H20000000 '/* return list
for alternate transport */
Private Const SV_TYPE_LOCAL_LIST_ONLY As Long = &H40000000 '/* Return local
list only */
Private Const SV_TYPE_DOMAIN_ENUM As Long = &H80000000
Private Const SV_TYPE_ALL As Long = &HFFFFFFFF '/* handy for NetServerEnum2
*/

Poser une question


NeoB a écrit :
Essaie en déclarant tes constantes :
Private Const SV_TYPE_SERVER_NT As Long = &H8000&
(Ajout de & à la fin pour forcer la prise en compte d'un entier long)
Si tu déclares :
Private Const SV_TYPE_SERVER_NT As Long = &H8000
...
Debug.Print Hex(SV_TYPE_ALL And (Not SV_TYPE_SERVER_NT))
renvoie :
7FFF
(Mise à zéro des 16 bits de poids forts, en plus de celui de
SV_TYPE_SERVER_NT)
Si tu déclares :
Private Const SV_TYPE_SERVER_NT As Long = &H8000&
...
Debug.Print Hex(SV_TYPE_ALL And (Not SV_TYPE_SERVER_NT))
renvoie :
FFFF7FFF
ce qui correspond bien à la mise à zéro du bit SV_TYPE_SERVER_NT
(&H8000) uniquement.
Etonnant, non ? ;-)
--
Cordialement,
Jacques.
Je teste cela dès demain au boulot.
Bonsoir.
NéoB
"Jacques93" a écrit dans le message de
news:
des
lister
Je
*/
and
list
local
NetServerEnum2