Und wieder ontopic

Da ich gerade die etwas ausführlicheren Fehlernummern brauchte, eine etwas erweiterte Version. (Hab mir das als Userlib gebastelt...)
Im Grunde nichts weltbewegendes, aber für "tippfaule" die gesamten SV_TYPE_ Konstanten

und halt mit expliziter Suchauswahl ... z.B. nur Novell Rechner usw.
Code: Alles auswählen
EnableExplicit
CompilerIf Defined(MAX_PREFERRED_LENGTH, #PB_Constant) = 0
#MAX_PREFERRED_LENGTH=-1
CompilerEndIf
CompilerIf Defined(SV_TYPE_WORKSTATION, #PB_Constant) = 0
#SV_TYPE_WORKSTATION = $00000001;A workstation.
#SV_TYPE_SERVER = $00000002;A server.
#SV_TYPE_SQLSERVER = $00000004;A server running With Microsoft SQL Server.
#SV_TYPE_DOMAIN_CTRL = $00000008;A primary domain controller.
#SV_TYPE_DOMAIN_BAKCTRL = $00000010;A backup domain controller.
#SV_TYPE_TIME_SOURCE = $00000020;A server running the Timesource service.
#SV_TYPE_AFP = $00000040;A server running the Apple Filing Protocol (AFP) file service.
#SV_TYPE_NOVELL = $00000080;A Novell server.
#SV_TYPE_DOMAIN_MEMBER = $00000100;A LAN Manager 2.x domain member.
#SV_TYPE_PRINTQ_SERVER = $00000200;A server that shares a print queue.
#SV_TYPE_DIALIN_SERVER = $00000400;A server that runs a dial-in service.
#SV_TYPE_XENIX_SERVER = $00000800;A Xenix Or Unix server.
#SV_TYPE_NT = $00001000;A workstation Or server.
#SV_TYPE_WFW = $00002000;A computer that runs Windows For Workgroups.
#SV_TYPE_SERVER_MFPN = $00004000;A server that runs the Microsoft File And Print For NetWare service.
#SV_TYPE_SERVER_NT = $00008000;Any server that is Not a domain controller.
#SV_TYPE_POTENTIAL_BROWSER = $00010000;A computer that can run the browser service.
#SV_TYPE_BACKUP_BROWSER = $00020000;A server running a browser service As backup.
#SV_TYPE_MASTER_BROWSER = $00040000;A server running the master browser service.
#SV_TYPE_DOMAIN_MASTER = $00080000;A server running the domain master browser.
#SV_TYPE_SERVER_OSF = $00100000;A computer that runs OSF.
#SV_TYPE_SERVER_VMS = $00200000;A computer that runs VMS.
#SV_TYPE_WINDOWS = $00400000;A computer that runs Windows.
#SV_TYPE_DFS = $00800000;A server that is the root of a DFS tree.
#SV_TYPE_CLUSTER_NT = $01000000;A server cluster available in the domain.
#SV_TYPE_TERMINALSERVER = $02000000;A server that runs the Terminal Server service.
#SV_TYPE_CLUSTER_VS_NT = $04000000;Cluster virtual servers available in the domain. Note : Windows 2000: This value is Not supported.
#SV_TYPE_DCE = $10000000;A server that runs the DCE Directory And Security Services Or equivalent.
#SV_TYPE_ALTERNATE_XPORT = $20000000;A server that is returned by an alternate transport.
#SV_TYPE_LOCAL_LIST_ONLY = $40000000;A server that is maintained by the browser
#SV_TYPE_DOMAIN_ENUM = $80000000;A primary domain.
#SV_TYPE_ALL = $FFFFFFFF;All Computer
CompilerEndIf
CompilerIf Defined(SERVER_INFO_101, #PB_Structure) = 0
Structure SERVER_INFO_101
platform_id.i
name.i
version_major.i
version_minor.i
type.i
comment.i
EndStructure
CompilerEndIf
CompilerIf Defined(SERVER_INFO_PB, #PB_Structure) = 0
Structure SERVER_INFO_PB
Name.s
Platform.s
Type.i
Comment.s
EndStructure
CompilerEndIf
Procedure.s NetServerEnumError(ErrorCode.i)
Protected Result.s
Select ErrorCode
Case 5
Result = "ERROR_ACCESS_DENIED" ;Access was denied.
Case 87
Result = "ERROR_INVALID_PARAMETER";The parameter is incorrect.
Case 234
Result = "ERROR_MORE_DATA";More entries are available. Specify a large enough buffer To receive all entries.
Case 6118
Result = "ERROR_NO_BROWSER_SERVERS_FOUND";No browser servers found.
Case 50
Result = "ERROR_NOT_SUPPORTED";The request is Not supported.
Case 2114
Result = "NERR_ServerNotStarted";The server service is Not started.
Case 2184
Result = "NERR_ServiceNotInstalled";The service has Not been started.
Case 2138
Result = "NERR_WkstaNotStarted";The Workstation service has Not been started. The local workstation service is used To communicate With a downlevel remote server.
Default
Result = Chr(34)+Str(ErrorCode)+Chr(34)+" Unknown Error - check http://msdn.microsoft.com/en-us/library/aa370623.aspx For more info"
EndSelect
ProcedureReturn Result
EndProcedure
Procedure.s getLanVersion(LanMajorVersion.l,LanMinorVersion.l,Platform.l)
Protected GetLanVersionString.s
Select Platform
Case 300 : GetLanVersionString = "DOS"
Case 400
Select LanMajorVersion
Case 4
Select LanMinorVersion
Case 0 : GetLanVersionString = "WIN95/OSR2"
Case 1 : GetLanVersionString = "WIN98/SE"
Case 90 : GetLanVersionString = "WIN ME"
EndSelect
EndSelect
Case 500
Select LanMajorVersion
Case 4: GetLanVersionString = "WIN NT"
Case 5
Select LanMinorVersion
Case 0 : GetLanVersionString = "WIN 2000"
Case 1 : GetLanVersionString = "WIN XP/SP2"
Case 2 : GetLanVersionString = "WIN 2003 Server"
EndSelect
Case 6
Select LanMinorVersion
Case 0 : GetLanVersionString = "WIN VISTA"
Case 1 : GetLanVersionString = "WIN 7"
EndSelect
EndSelect
Case 600 : GetLanVersionString = "OSF"
Case 700 : GetLanVersionString = "VMS"
EndSelect
ProcedureReturn GetLanVersionString
EndProcedure
Procedure.s GetLanComputer(List Computer.SERVER_INFO_PB(), Searchmask.i = #SV_TYPE_ALL)
Protected Result.i, Found.i, n.i
Protected infoblock.SERVER_INFO_101
Protected *Buffer
Result = NetServerEnum_(0, 101, @*buffer, #MAX_PREFERRED_LENGTH, @found, @n, Searchmask, 0, 0)
If Result
NetApiBufferFree_(*buffer)
ProcedureReturn NetServerEnumError(Result)
Else
For n=0 To Found-1
CopyMemory(*buffer+SizeOf(SERVER_INFO_101)*n, @infoblock, SizeOf(SERVER_INFO_101))
AddElement(Computer())
Computer()\Name = PeekS(infoblock\name, -1, #PB_Unicode)
Computer()\Platform = getLanVersion(infoblock\version_major.i, infoblock\version_minor.i,infoblock\platform_id)
Computer()\Type = infoblock\type.i
Computer()\Comment = PeekS(infoblock\comment, -1, #PB_Unicode)
Next
NetApiBufferFree_(*buffer)
ProcedureReturn "Ok."
EndIf
EndProcedure
;##### Beispiel
NewList cc.SERVER_INFO_PB()
GetLanComputer(cc(),#SV_TYPE_ALL)
ForEach cc()
Debug cc()\Name + " : "+cc()\Platform
Next