Get MAC-Address ?

Everything else that doesn't fall into one of the other PB categories.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Image
Image
That's what i can say :?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

The code updated by ABBKlaus works as expected here.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Time ago I switched off many of the commonly used services in windows.
So perhaps it could be caused by that...
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

this example is definitely not crash save :roll:
you have to check every hres <> 0 if there was an error :!:

When i deactivated my DCOM-Server it crashes on this line :

Code: Select all

hres=penum\GetObjects(0,100*SizeOf(IWbemObjectAccess),@tab(),@retour.l)
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

Post by bingo »

no problems with Data type: string , boolean , unit32 .
but how handle Data type: string array (IPAddress) ??? :oops:

Code: Select all

Procedure.l Ansi2Uni(ansi.s) 
SHStrDup_(@ansi,@memziel)
ProcedureReturn memziel 
EndProcedure
           
Procedure.s Uni2Ansi(*Unicode.l) 
size.l = WideCharToMultiByte_(#CP_ACP, 0, *Unicode, -1, #Null, #Null, #Null, #Null) 
ansi.s=Space(size) 
WideCharToMultiByte_(#CP_ACP, 0, *Unicode, -1, @ansi, size, #Null, #Null) 
ProcedureReturn ansi  
EndProcedure

#COINIT_MULTITHREAD=0 
#EOAC_NONE=0 
#CLSCTX_INPROC_SERVER=1 
#RPC_C_AUTHN_LEVEL_PKT = 4
#RPC_C_IMP_LEVEL_IMPERSONATE = 3 

Procedure wmi_error(tmp)
CoUninitialize_()
MessageRequester("error", "WMI ERROR (" + Str(tmp) + ") !", #MB_ICONHAND)
  End
EndProcedure

CoInitializeEx_(0,#COINIT_MULTITHREAD) 
CoInitializeSecurity_(0, -1,0,0,#RPC_C_AUTHN_LEVEL_PKT,#RPC_C_IMP_LEVEL_IMPERSONATE,0,#EOAC_NONE,0) 
If CoCreateInstance_(?CLSID_WbemLocator,0,#CLSCTX_INPROC_SERVER,?IID_IWbemLocator,@loc.IWbemLocator) <> 0: wmi_error(1): EndIf
loc\ConnectServer(ansi2uni("root\cimv2"),0,0,0,0,0,0,@svc.IWbemServices) 
CoCreateInstance_(?CLSID_WbemRefresher,0,#CLSCTX_INPROC_SERVER,?IID_IWbemRefresher,@pRefresher.IWbemRefresher) 
pRefresher\queryinterface(?IID_IWbemConfigureRefresher,@pConfig.IWbemConfigureRefresher) 
If pConfig\AddEnum(svc,ansi2uni("Win32_NetworkAdapterConfiguration"),0,0,@penum.IWbemHiPerfEnum,@id)  <> 0: wmi_error(2): EndIf
pConfig\release() 

pRefresher\refresh(0) 

penum\GetObjects(0,0,0,@retour) 

Dim tab.IWbemObjectAccess(retour) 

penum\GetObjects(0,(retour) * SizeOf(IWbemObjectAccess),@tab(),@retour) 

memlaenge = 255
*memID = AllocateMemory(memlaenge) 
propstring.l

For i=0 To retour - 1
tab(i)\GetPropertyHandle(ansi2uni("Caption"),0,@propstring) 
tab(i)\ReadPropertyValue(propstring,@memlaenge,@tmplaenge,*memID) 
Debug UCase(Uni2Ansi(*memID)) ;Data type: string
ZeroMemory_(*memID,memlaenge)

tab(i)\GetPropertyHandle(ansi2uni("MACAddress"),0,@propstring) 
tab(i)\ReadPropertyValue(propstring,@memlaenge,@tmplaenge,*memID) 
Debug UCase(Uni2Ansi(*memID)) ;Data type: string
ZeroMemory_(*memID,memlaenge)

tab(i)\GetPropertyHandle(ansi2uni("IPEnabled"),0,@propstring) 
tab(i)\ReadPropertyValue(propstring,@memlaenge,@tmplaenge,*memID) 
Debug PeekB(*memID) ;Data type: boolean
ZeroMemory_(*memID,memlaenge)

tab(i)\GetPropertyHandle(ansi2uni("IPConnectionMetric"),0,@propstring) 
tab(i)\ReadPropertyValue(propstring,@memlaenge,@tmplaenge,*memID) 
Debug PeekL(*memID) ;Data type: uint32
ZeroMemory_(*memID,memlaenge)

;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_networkadapterconfiguration.asp
;"IPAddress"
;Data type: string array
;how handle this type in pb ???

Next

penum\release() 
pRefresher\release(); 
svc\release() 
loc\release() 

CoUninitialize_() 

FreeMemory(*memID)

DataSection 

CLSID_WbemLocator: 
Data.l $4590F811 
Data.w $1D3A, $11D0 
Data.b $89, $1F, $00, $AA, $00, $4B, $2E, $24 
IID_IWbemLocator: 
Data.l $DC12A687 
Data.w $737F, $11CF 
Data.b $88, $4D, $00, $AA, $00, $4B, $2E, $24 
IID_IWbemRefresher: 
Data.l $49353C99 
Data.w $516B, $11D1 
Data.b $AE, $A6, $00, $C0, $4F, $B6, $88, $20 
CLSID_WbemRefresher: 
Data.l $C71566F2 
Data.w $561E, $11D1 
Data.b $AD,$87,$00,$C0,$4F,$D8,$FD,$FF 
IID_IWbemConfigureRefresher: 
Data.l $49353C92 
Data.w $516B, $11D1 
Data.b $AE, $A6, $00, $C0, $4F, $B6, $88, $20 
IID_IWbemObjectAccess: 
Data.l $49353C9A 
Data.w $516B, $11D1 
Data.b $AE, $A6, $00, $C0, $4F, $B6, $88, $20 
EndDataSection
["1:0>1"]
Post Reply