Page 1 sur 1

Récupérer le nom de sa carte mère et le socket ?

Publié : sam. 15/sept./2012 19:22
par Ar-S
Bonjour,
Si capter sa version de windows, le nom de son ordi ou son nom d'utilisateur est aisé via le registre, savez vous comment récupérer le modèle de sa carte mère (ex : P35 Neo2) et le socket de son processeur (775, 1155 etc..) ? un logiciel comme CPU-Z le fait, j'aimerai y arriver.

Que ce soit dans le registre ou via un API je reste dans le floue.

Merci

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : sam. 15/sept./2012 21:08
par G-Rom
si tu te sent de fouinner la dedans , y a ce qu'il faut :
http://www.nongnu.org/dmidecode/

bon courage ;)

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : sam. 15/sept./2012 21:13
par falsam
Le code d'IdeasVacuum sur le forum anglais.
http://www.purebasic.fr/english/viewtop ... 59#p384959

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : sam. 15/sept./2012 21:25
par falsam
Tu peux aussi trouver bonheur dans systeminfo.exe

Code : Tout sélectionner

program = RunProgram("systeminfo.exe","","",#PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
While ProgramRunning(program) 
  If AvailableProgramOutput(program) 
    Debug Trim(ReadProgramString(program))
  EndIf 
Wend 
Sous Windows 7 pas de problème, à voir sous XP

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : sam. 15/sept./2012 21:53
par falsam
Code de PB (2003)

Code : Tout sélectionner

Procedure.s RegReadString(section,path$,key$)
  value.s=Space(9999) : datasize.l=255
  If RegOpenKeyEx_(section,path$,0,#KEY_READ,@tmp)=#ERROR_SUCCESS
    If RegQueryValueEx_(tmp,key$,0,0,@value,@datasize)<>#ERROR_SUCCESS : value="-1" : EndIf
    RegCloseKey_(tmp)
  EndIf
  ProcedureReturn value
EndProcedure

Debug Trim(RegReadString(#HKEY_LOCAL_MACHINE,"HARDWARE\DESCRIPTION\System\CentralProcessor\0","ProcessorNameString"))
Debug Trim(RegReadString(#HKEY_LOCAL_MACHINE,"HARDWARE\DESCRIPTION\System\CentralProcessor\0","VendorIdentifier"))
Code de ts-soft (2007)

Code : Tout sélectionner

Procedure.s GetCPUName()
  Protected sBuffer.s
  Protected Zeiger1.l, Zeiger2.l, Zeiger3.l, Zeiger4.l
 
  !MOV eax, $80000002
  !CPUID
  ; the CPU-Name is now stored in EAX-EBX-ECX-EDX
  !MOV [p.v_Zeiger1], EAX ; move eax to the buffer
  !MOV [p.v_Zeiger2], EBX ; move ebx to the buffer
  !MOV [p.v_Zeiger3], ECX ; move ecx to the buffer
  !MOV [p.v_Zeiger4], EDX ; move edx to the buffer
 
  ;Now move the content of Zeiger (4*4=16 Bytes to a string
  sBuffer = PeekS(@Zeiger1, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger2, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger3, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger4, 4, #PB_Ascii)
 
  ;Second Part of the Name
  !MOV eax, $80000003
  !CPUID
  ; the CPU-Name is now stored in EAX-EBX-ECX-EDX
  !MOV [p.v_Zeiger1], EAX ; move eax to the buffer
  !MOV [p.v_Zeiger2], EBX ; move ebx to the buffer
  !MOV [p.v_Zeiger3], ECX ; move ecx to the buffer
  !MOV [p.v_Zeiger4], EDX ; move edx to the buffer
 
  ;Now move the content of Zeiger (4*4=16 Bytes to a string
  sBuffer + PeekS(@Zeiger1, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger2, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger3, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger4, 4, #PB_Ascii)
 
 
  ;Third Part of the Name
  !MOV eax, $80000004
  !CPUID
  ; the CPU-Name is now stored in EAX-EBX-ECX-EDX
  !MOV [p.v_Zeiger1], EAX ; move eax to the buffer
  !MOV [p.v_Zeiger2], EBX ; move ebx to the buffer
  !MOV [p.v_Zeiger3], ECX ; move ecx to the buffer
  !MOV [p.v_Zeiger4], EDX ; move edx to the buffer
 
  ;Now move the content of Zeiger (4*4=16 Bytes to a string
  sBuffer + PeekS(@Zeiger1, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger2, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger3, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger4, 4, #PB_Ascii)
 
  ProcedureReturn sBuffer
EndProcedure

Debug GetCPUName()

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : dim. 16/sept./2012 2:34
par Ar-S
Merci pour toutes ces bonnes choses !
Le coup du systeminfo.exe est vraiment pas mal.
:P

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : lun. 17/sept./2012 14:11
par Mesa
Avec, il y a tout, trop même 8O , même les imprimantes. Mais je ne sais plus où je l'ai trouvé.
Ça fonctionne sous xp32.

Code : Tout sélectionner

#COINIT_MULTITHREAD=0  
#RPC_C_AUTHN_LEVEL_CONNECT=2  
#RPC_C_IMP_LEVEL_IDENTIFY=2  
#EOAC_NONE=0  
#RPC_C_AUTHN_WINNT=10  
#RPC_C_AUTHZ_NONE=0  
#RPC_C_AUTHN_LEVEL_CALL=3  
#RPC_C_IMP_LEVEL_IMPERSONATE=3  
#CLSCTX_INPROC_SERVER=1  
#wbemFlagReturnImmediately=16  
#wbemFlagForwardOnly=32  
#IFlags = #wbemFlagReturnImmediately + #wbemFlagForwardOnly  
#WBEM_INFINITE=$FFFFFFFF  


Procedure.l ansi2bstr(ansi.s)
	size.l=MultiByteToWideChar_(#CP_ACP,0,ansi,Len(ansi),0,0)
	;size =20
  Dim unicode.w(size)
  MultiByteToWideChar_(#CP_ACP, 0, ansi, Len(ansi), unicode(), size);#CP_ACP
  For i=0 To size
  	tmp.s + Hex(unicode(i),#PB_Unicode)
  	Next
  ;MessageRequester(Str(size), tmp )
  ProcedureReturn SysAllocString_(@unicode())
EndProcedure
 
Procedure bstr2string (bstr)
	Shared result.s
  result = PeekS(bstr, -1, #PB_Unicode)
  ProcedureReturn @result
EndProcedure
 
 
 Procedure.l GetWMIData(WMIobj.s)
ClearGadgetItems(0)
SetWindowTitle(0,"WMI Reader  -  retrieving data from " + WMIobj)
If Left(LCase(WMIobj),6)="win32_": WMIobj = "SELECT * FROM " + WMIobj: EndIf
;- WMI calling
; --- Step 1: Initialize COM parameters with a call to CoInitializeEx  
CoInitializeEx_(0,#COINIT_MULTITHREAD)  
; --- Step 2: Initialize COM process security by calling CoInitializeSecurity.  
hres=CoInitializeSecurity_(0, -1,0,0,#RPC_C_AUTHN_LEVEL_CONNECT,#RPC_C_IMP_LEVEL_IDENTIFY,0,#EOAC_NONE,0)  
If hres <> 0: MessageRequester("ERROR", "unable to call CoInitializeSecurity", #MB_OK): Goto cleanup: EndIf  
; --- Step 3: Obtain the initial locator to WMI by calling CoCreateInstance.  
hres=CoCreateInstance_(?CLSID_WbemLocator,0,#CLSCTX_INPROC_SERVER,?IID_IWbemLocator,@loc.IWbemLocator)  
If hres <> 0: MessageRequester("ERROR", "unable to call CoCreateInstance", #MB_OK): Goto cleanup: EndIf   
; --- Step 4: Obtain a pointer to IWbemServices for the root\cimv2 namespace on the local computer by calling IWbemLocator::ConnectServer.  
If #PB_Compiler_Unicode = 1;we create unicode application
	hres=loc\ConnectServer(@"root\cimv2" ,0,0,0,0,0,0,@svc.IWbemServices)
Else; non unicode
	hres=loc\ConnectServer(ansi2bstr("root\cimv2"),0,0,0,0,0,0,@svc.IWbemServices)  
EndIf
If hres <> 0: MessageRequester(Hex(hres), "unable To call IWbemLocator::ConnectServer", #MB_OK): Goto cleanup: EndIf  
hres=svc\queryinterface(?IID_IUnknown,@pUnk.IUnknown)  
; --- Step 5: Set IWbemServices proxy security so the WMI service can impersonate the client by calling CoSetProxyBlanket.  
hres=CoSetProxyBlanket_(svc,#RPC_C_AUTHN_WINNT,#RPC_C_AUTHZ_NONE,0,#RPC_C_AUTHN_LEVEL_CALL,#RPC_C_IMP_LEVEL_IMPERSONATE,0,#EOAC_NONE)  
If hres <> 0: MessageRequester("ERROR", "unable to call CoSetProxyBlanket", #MB_OK): Goto cleanup: EndIf   
hres=CoSetProxyBlanket_(pUnk,#RPC_C_AUTHN_WINNT,#RPC_C_AUTHZ_NONE,0,#RPC_C_AUTHN_LEVEL_CALL,#RPC_C_IMP_LEVEL_IMPERSONATE,0,#EOAC_NONE)  
If hres <> 0: MessageRequester("ERROR", "unable to call CoSetProxyBlanket", #MB_OK): Goto cleanup: EndIf   
pUnk\release()  
; --- Step 6: Use the IWbemServices pointer to make requests of WMI.
If #PB_Compiler_Unicode = 1
	hres=svc\ExecQuery(@"WQL",@WMIobj, #IFlags,0,@pEnumerator.IEnumWbemClassObject)  
Else
	hres=svc\ExecQuery(ansi2bstr("WQL"),ansi2bstr(WMIobj), #IFlags,0,@pEnumerator.IEnumWbemClassObject) 
EndIf
If hres <> 0: MessageRequester("ERROR", "unable to call IWbemServices::ExecQuery", #MB_OK): Goto cleanup: EndIf   
; --- Step 7: Get the data from the WQL query. The IEnumWbemClassObject pointer is linked to the data objects that the query returned,  
; ---            and the data objects can be retrieved with the IEnumWbemClassObject::Next method. This method links the data objects to an IWbemClassObject pointer  
; ---            that is passed into the method. Use the IWbemClassObject::Get method to get the desired information from the data objects.  
mem=AllocateMemory(1000)  
hres=pEnumerator\reset()  
ItemCount.l=0
Repeat  
	ItemCount+ 1
	hres = pEnumerator\Next(#WBEM_INFINITE, 1, @pclsObj.IWbemClassObject, @uReturn) 
	If uReturn = 0
		Break
	Else
		AddGadgetItem(0,-1,"")
		AddGadgetItem(0,-1,"Item #" + Str(ItemCount))
		SetGadgetItemColor(0,CountGadgetItems(0)-1,#PB_Gadget_FrontColor, $900000)
	EndIf
	hres=pclsObj\GetNames(0, 0, 0,@sf.l); get a list with the names of the properties.
	SafeArrayGetLBound_(sf, 1, @lBound)
	SafeArrayGetUBound_(sf, 1, @uBound)
	Dim indices(1)
	For i = lBound To uBound
		indices(0) = i
		SafeArrayGetElement_(sf, @indices(), @temp)
		If temp
			tmp.s = PeekS(temp, -1, #PB_Unicode) 
			If #PB_Compiler_Unicode = 1
				hres=pclsObj\get(@tmp, 0, mem, 0, 0)  
			Else
				hres=pclsObj\get(ansi2bstr(tmp), 0, mem, 0, 0) 
			EndIf
			
			type=PeekW(mem)  
			
			Select type  
				Case 8  
					val.s=PeekS(bstr2string(PeekL(mem+8)))  
				Case 3  
					val.s=Str(PeekL(mem+8))  
				Default  
					val.s=""  
			EndSelect
			If FindString(WMIobj,"*",1) <> 0;we need everything, not just some specific properties
				AddGadgetItem(0,-1,tmp+Chr(10)+val)
			ElseIf Left(tmp,1)<>"_";we need some specific properties, not all, not these starting with '_'.
				AddGadgetItem(0,-1,tmp+Chr(10)+val)
			EndIf
				
		EndIf
	Next
Until uReturn = 0 
If CountGadgetItems(0) > 0
	RemoveGadgetItem(0,0)
	If ItemCount = 2
		RemoveGadgetItem(0,0)
	EndIf
Else
	AddGadgetItem(0,-1,""+Chr(10)+"No data to display")
EndIf
; --- Step 8: Cleanup  
cleanup:
svc\release()
loc\release()
pEnumerator\release()
If uReturn: pclsObj\release(): EndIf
CoUninitialize_()
SetWindowTitle(0,"WMI Reader")
EndProcedure
 
If OpenWindow(0,0,0,800,500,"WMI Reader",#PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)
ListIconGadget(0,310,10,480,480,"Property",200,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"Value",400)
AddGadgetItem(0,-1,""+Chr(10)+"Please select a class to access its data")

PanelGadget(1, 10,10,280,480)
AddGadgetItem(1,-1,"Hierarchical Order")
	TreeGadget(2, 6, 10, 260, 437)
AddGadgetItem(1,-1,"Alphabetical Order")
	TreeGadget(3, 6, 10, 260, 437)
AddGadgetItem(1,-1,"Custom")
	TextGadget(4, 10, 10, 260, 160,"Please enter the WMI class you want to execute."+Chr(13)+Chr(13)+"For example:"+Chr(13)+"Win32_OperatingSystem"+Chr(13)+"Or"+Chr(13)+"win32_operatingsystem"+Chr(13)+"(the name that you write is case insensitive.)"+Chr(13)+"Or"+Chr(13)+"Select * from Win32_OperatingSystem"+Chr(13)+"Or"+Chr(13)+"Select Caption, Name from Win32_OperatingSystem")
	StringGadget(5, 6,160,260,25,"")
	ButtonGadget(6,6,190,60,30,"Execute")
CloseGadgetList()

NewList WC.s()
ii.l=0; this var is needed to obtain the type of the inserted value, node or sub item.
Restore WMIClasses
Repeat
	Read.s tmp.s
	If tmp = "-1": Break: EndIf
	Select Left(tmp,2)
		Case "++"
			AddGadgetItem (2, -1, Right(tmp,Len(tmp)-2),0,1)
			SetGadgetItemColor(2,CountGadgetItems(2)-1,#PB_Gadget_FrontColor, $900000)
			ii = 2
		Case "+ "
			AddGadgetItem (2, -1, Right(tmp,Len(tmp)-2))
			SetGadgetItemColor(2,CountGadgetItems(2)-1,#PB_Gadget_FrontColor, $900000)
			ii = 1
		Default
			AddGadgetItem(2, -1, tmp, 0, ii)
			AddElement(WC()): WC() = tmp
		EndSelect
ForEver

SortList(WC(),#PB_Sort_Ascending)
ForEach WC()
	AddGadgetItem(3, -1, WC())
Next

Repeat
	Select WaitWindowEvent()
		Case #PB_Event_Gadget
         Select EventGadget()
         	Case 2;hierarchical view
         		tmp = GetGadgetItemText(2,GetGadgetState(2))
         		If Left(tmp,5)="Win32"
         			GetWMIData(tmp)
         		EndIf
         	Case 3;alphabetical view
         		GetWMIData(GetGadgetItemText(3,GetGadgetState(3)))
         	Case 6;try to execute a user's class. we do not worry if the class is present or not.
         		GetWMIData(GetGadgetText(5))
         EndSelect
		Case #PB_Event_CloseWindow
			Break
	EndSelect
ForEver
EndIf

;- DATA  
DataSection  
CLSID_IEnumWbemClassObject:  
   ;1B1CAD8C-2DAB-11D2-B604-00104B703EFD  
Data.l $1B1CAD8C  
Data.w $2DAB, $11D2  
Data.b $B6, $04, $00, $10, $4B, $70, $3E, $FD  
IID_IEnumWbemClassObject:  
   ;7C857801-7381-11CF-884D-00AA004B2E24  
Data.l $7C857801  
Data.w $7381, $11CF  
Data.b $88, $4D, $00, $AA, $00, $4B, $2E, $24  
CLSID_WbemLocator:  
    ;4590f811-1d3a-11d0-891f-00aa004b2e24  
Data.l $4590F811  
Data.w $1D3A, $11D0  
Data.b $89, $1F, $00, $AA, $00, $4B, $2E, $24  
IID_IWbemLocator:  
    ;dc12a687-737f-11cf-884d-00aa004b2e24  
Data.l $DC12A687  
Data.w $737F, $11CF  
Data.b $88, $4D, $00, $AA, $00, $4B, $2E, $24  
IID_IUnknown:  
    ;00000000-0000-0000-C000-000000000046  
Data.l $00000000  
Data.w $0000, $0000  
Data.b $C0, $00, $00, $00, $00, $00, $00, $46  
IID_IWbemRefresher:  
    ;49353c99-516b-11d1-aea6-00c04fb68820  
Data.l $49353C99  
Data.w $516B, $11D1  
Data.b $AE, $A6, $00, $C0, $4F, $B6, $88, $20  
CLSID_WbemRefresher:  
    ;c71566f2-561E-11D1-AD87-00C04FD8FDFF  
Data.l $C71566F2  
Data.w $561E, $11D1  
Data.b $AD,$87,$00,$C0,$4F,$D8,$FD,$FF  
IID_IWbemConfigureRefresher:  
    ;49353c92-516b-11d1-aea6-00c04fb68820  
Data.l $49353C92  
Data.w $516B, $11D1  
Data.b $AE, $A6, $00, $C0, $4F, $B6, $88, $20  
IID_IWbemObjectAccess:  
    ;49353c9a-516b-11d1-aea6-00c04fb68820  
Data.l $49353C9A  
Data.w $516B, $11D1  
Data.b $AE, $A6, $00, $C0, $4F, $B6, $88, $20  
EndDataSection  

;WMI classes, the '+' symbol indicates new node
DataSection
WMIClasses:
Data.s "+ Computer System Hardware Classes"
Data.s "++Cooling Device"
Data.s "Win32_Fan"
Data.s "Win32_HeatPipe"
Data.s "Win32_Refrigeration"
Data.s "Win32_TemperatureProbe"
Data.s "++Input Device"
Data.s "Win32_Keyboard"
Data.s "Win32_PointingDevice"
Data.s "++Mass Storage"
Data.s "Win32_AutochkSetting"
Data.s "Win32_CDROMDrive"
Data.s "Win32_DiskDrive"
Data.s "Win32_FloppyDrive"
Data.s "Win32_LogicalDisk"
Data.s "Win32_PhysicalMedia"
Data.s "Win32_TapeDrive"
Data.s "++Motherboard, Controller, and Port"
Data.s "Win32_1394Controller"
Data.s "Win32_1394ControllerDevice"
Data.s "Win32_AllocatedResource"
Data.s "Win32_AssociatedProcessorMemory"
Data.s "Win32_BaseBoard"
Data.s "Win32_BIOS"
Data.s "Win32_Bus"
Data.s "Win32_CacheMemory"
Data.s "Win32_ControllerHasHub"
Data.s "Win32_DeviceBus"
Data.s "Win32_DeviceMemoryAddress"
Data.s "Win32_DeviceSettings"
Data.s "Win32_DMAChannel"
Data.s "Win32_FloppyController"
Data.s "Win32_IDEController"
Data.s "Win32_IDEControllerDevice"
Data.s "Win32_InfraredDevice"
Data.s "Win32_IRQResource"
Data.s "Win32_MemoryArray"
Data.s "Win32_MemoryArrayLocation"
Data.s "Win32_MemoryDevice"
Data.s "Win32_MemoryDeviceArray"
Data.s "Win32_MemoryDeviceLocation"
Data.s "Win32_MotherboardDevice"
Data.s "Win32_OnBoardDevice"
Data.s "Win32_ParallelPort"
Data.s "Win32_PCMCIAController"
Data.s "Win32_PhysicalMemory"
Data.s "Win32_PhysicalMemoryArray"
Data.s "Win32_PhysicalMemoryLocation"
Data.s "Win32_PNPAllocatedResource"
Data.s "Win32_PNPDevice"
Data.s "Win32_PNPEntity"
Data.s "Win32_PortConnector"
Data.s "Win32_PortResource"
Data.s "Win32_Processor"
Data.s "Win32_SCSIController"
Data.s "Win32_SCSIControllerDevice"
Data.s "Win32_SerialPort"
Data.s "Win32_SerialPortConfiguration"
Data.s "Win32_SerialPortSetting"
Data.s "Win32_SMBIOSMemory"
Data.s "Win32_SoundDevice"
Data.s "Win32_SystemBIOS"
Data.s "Win32_SystemDriverPNPEntity"
Data.s "Win32_SystemEnclosure"
Data.s "Win32_SystemMemoryResource"
Data.s "Win32_SystemSlot"
Data.s "Win32_USBController"
Data.s "Win32_USBControllerDevice"
Data.s "Win32_USBHub"
Data.s "++Networking Device"
Data.s "Win32_NetworkAdapter"
Data.s "Win32_NetworkAdapterConfiguration"
Data.s "Win32_NetworkAdapterSetting"
Data.s "++Power"
Data.s "Win32_AssociatedBattery"
Data.s "Win32_Battery"
Data.s "Win32_CurrentProbe"
Data.s "Win32_PortableBattery"
Data.s "Win32_PowerManagementEvent"
Data.s "Win32_UninterruptiblePowerSupply"
Data.s "Win32_VoltageProbe"
Data.s "++Printing"
Data.s "Win32_DriverForDevice"
Data.s "Win32_Printer"
Data.s "Win32_PrinterConfiguration"
Data.s "Win32_PrinterController"
Data.s "Win32_PrinterDriver"
Data.s "Win32_PrinterDriverDll"
Data.s "Win32_PrinterSetting"
Data.s "Win32_PrintJob"
Data.s "Win32_TCPIPPrinterPort"
Data.s "++Telephony"
Data.s "Win32_POTSModem"
Data.s "Win32_POTSModemToSerialPort"
Data.s "++Video and Monitor"
Data.s "Win32_DesktopMonitor"
Data.s "Win32_DisplayConfiguration"
Data.s "Win32_DisplayControllerConfiguration"
Data.s "Win32_VideoConfiguration"
Data.s "Win32_VideoController"
Data.s "Win32_VideoSettings"
Data.s "+ Operating System"
Data.s "++COM"
Data.s "Win32_ClassicCOMApplicationClasses"
Data.s "Win32_ClassicCOMClass"
Data.s "Win32_ClassicCOMClassSettings"
Data.s "Win32_ClientApplicationSetting"
Data.s "Win32_COMApplication"
Data.s "Win32_COMApplicationClasses"
Data.s "Win32_COMApplicationSettings"
Data.s "Win32_COMClass"
Data.s "Win32_ComClassAutoEmulator"
Data.s "Win32_ComClassEmulator"
Data.s "Win32_ComponentCategory"
Data.s "Win32_COMSetting"
Data.s "Win32_DCOMApplication"
Data.s "Win32_DCOMApplicationAccessAllowedSetting"
Data.s "Win32_DCOMApplicationLaunchAllowedSetting"
Data.s "Win32_DCOMApplicationSetting"
Data.s "Win32_ImplementedCategory"
Data.s "++Desktop"
Data.s "Win32_Desktop"
Data.s "Win32_Environment"
Data.s "Win32_TimeZone"
Data.s "Win32_UserDesktop"
Data.s "++Drivers"
Data.s "Win32_DriverVXD"
Data.s "Win32_SystemDriver"
Data.s "++File System"
Data.s "Win32_CIMLogicalDeviceCIMDataFile"
Data.s "Win32_Directory"
Data.s "Win32_DirectorySpecification"
Data.s "Win32_DiskDriveToDiskPartition"
Data.s "Win32_DiskPartition"
Data.s "Win32_DiskQuota"
Data.s "Win32_LogicalDisk"
Data.s "Win32_LogicalDiskRootDirectory"
Data.s "Win32_LogicalDiskToPartition"
Data.s "Win32_MappedLogicalDisk"
Data.s "Win32_OperatingSystemAutochkSetting"
Data.s "Win32_QuotaSetting"
Data.s "Win32_ShortcutFile"
Data.s "Win32_SubDirectory"
Data.s "Win32_SystemPartitions"
Data.s "Win32_Volume"
Data.s "Win32_VolumeQuota"
Data.s "Win32_VolumeQuotaSetting"
Data.s "Win32_VolumeUserQuota"
Data.s "++Job Objects"
Data.s "Win32_CollectionStatistics"
Data.s "Win32_LUID"
Data.s "Win32_LUIDandAttributes"
Data.s "Win32_NamedJobObject"
Data.s "Win32_NamedJobObjectActgInfo"
Data.s "Win32_NamedJobObjectLimit"
Data.s "Win32_NamedJobObjectLimitSetting"
Data.s "Win32_NamedJobObjectProcess"
Data.s "Win32_NamedJobObjectSecLimit"
Data.s "Win32_NamedJobObjectSecLimitSetting"
Data.s "Win32_NamedJobObjectStatistics"
Data.s "Win32_SIDandAttributes"
Data.s "Win32_TokenGroups"
Data.s "Win32_TokenPrivileges"
Data.s "++Memory And Page Files"
Data.s "Win32_LogicalMemoryConfiguration"
Data.s "Win32_PageFile"
Data.s "Win32_PageFileElementSetting"
Data.s "Win32_PageFileSetting"
Data.s "Win32_PageFileUsage"
Data.s "Win32_SystemLogicalMemoryConfiguration"
Data.s "++Multimedia Audio Or Visual"
Data.s "Win32_CodecFile"
Data.s "++Networking"
Data.s "Win32_ActiveRoute"
Data.s "Win32_IP4PersistedRouteTable"
Data.s "Win32_IP4RouteTable"
Data.s "Win32_IP4RouteTableEvent"
Data.s "Win32_NetworkClient"
Data.s "Win32_NetworkConnection"
Data.s "Win32_NetworkProtocol"
Data.s "Win32_NTDomain"
Data.s "Win32_PingStatus"
Data.s "Win32_ProtocolBinding"
Data.s "++Operating System Events"
Data.s "Win32_ComputerShutdownEvent"
Data.s "Win32_ComputerSystemEvent"
Data.s "Win32_DeviceChangeEvent"
Data.s "Win32_ModuleLoadTrace"
Data.s "Win32_ModuleTrace"
Data.s "Win32_ProcessStartTrace"
Data.s "Win32_ProcessStopTrace"
Data.s "Win32_ProcessTrace"
Data.s "Win32_SystemConfigurationChangeEvent"
Data.s "Win32_SystemTrace"
Data.s "Win32_ThreadStartTrace"
Data.s "Win32_ThreadStopTrace"
Data.s "Win32_ThreadTrace"
Data.s "Win32_VolumeChangeEvent"
Data.s "++Operating System Settings"
Data.s "Win32_BootConfiguration"
Data.s "Win32_ComputerSystem"
Data.s "Win32_ComputerSystemProcessor"
Data.s "Win32_ComputerSystemProduct"
Data.s "Win32_DependentService"
Data.s "Win32_LoadOrderGroup"
Data.s "Win32_LoadOrderGroupServiceDependencies"
Data.s "Win32_LoadOrderGroupServiceMembers"
Data.s "Win32_OperatingSystem"
Data.s "Win32_OperatingSystemQFE"
Data.s "Win32_OSRecoveryConfiguration"
Data.s "Win32_QuickFixEngineering"
Data.s "Win32_StartupCommand"
Data.s "Win32_SystemBootConfiguration"
Data.s "Win32_SystemDesktop"
Data.s "Win32_SystemDevices"
Data.s "Win32_SystemLoadOrderGroups"
Data.s "Win32_SystemNetworkConnections"
Data.s "Win32_SystemOperatingSystem"
Data.s "Win32_SystemProcesses"
Data.s "Win32_SystemProgramGroups"
Data.s "Win32_SystemResources"
Data.s "Win32_SystemServices"
Data.s "Win32_SystemSetting"
Data.s "Win32_SystemSystemDriver"
Data.s "Win32_SystemTimeZone"
Data.s "Win32_SystemUsers"
Data.s "++Processes"
Data.s "Win32_Process"
Data.s "Win32_ProcessStartup"
Data.s "Win32_Thread"
Data.s "++Registry"
Data.s "Win32_Registry"
Data.s "++Scheduler Jobs"
Data.s "Win32_CurrentTime"
Data.s "Win32_ScheduledJob"
Data.s "Win32_LocalTime"
Data.s "Win32_UTCTime"
Data.s "++Security"
Data.s "Win32_AccountSID"
Data.s "Win32_ACE"
Data.s "Win32_LogicalFileAccess"
Data.s "Win32_LogicalFileAuditing"
Data.s "Win32_LogicalFileGroup"
Data.s "Win32_LogicalFileOwner"
Data.s "Win32_LogicalFileSecuritySetting"
Data.s "Win32_LogicalShareAccess"
Data.s "Win32_LogicalShareAuditing"
Data.s "Win32_LogicalShareSecuritySetting"
Data.s "Win32_PrivilegesStatus"
Data.s "Win32_SecurityDescriptor"
Data.s "Win32_SecuritySetting"
Data.s "Win32_SecuritySettingAccess"
Data.s "Win32_SecuritySettingAuditing"
Data.s "Win32_SecuritySettingGroup"
Data.s "Win32_SecuritySettingOfLogicalFile"
Data.s "Win32_SecuritySettingOfLogicalShare"
Data.s "Win32_SecuritySettingOfObject"
Data.s "Win32_SecuritySettingOwner"
Data.s "Win32_SID"
Data.s "Win32_Trustee"
Data.s "++Services"
Data.s "Win32_BaseService"
Data.s "Win32_Service"
Data.s "++Shares"
Data.s "Win32_DFSNode"
Data.s "Win32_DFSNodeTarget"
Data.s "Win32_DFSTarget"
Data.s "Win32_ServerConnection"
Data.s "Win32_ServerSession"
Data.s "Win32_ConnectionShare"
Data.s "Win32_PrinterShare"
Data.s "Win32_SessionConnection"
Data.s "Win32_SessionProcess"
Data.s "Win32_ShareToDirectory"
Data.s "Win32_Share"
Data.s "++Start Menu"
Data.s "Win32_LogicalProgramGroup"
Data.s "Win32_LogicalProgramGroupDirectory"
Data.s "Win32_LogicalProgramGroupItem"
Data.s "Win32_LogicalProgramGroupItemDataFile"
Data.s "Win32_ProgramGroup"
Data.s "Win32_ProgramGroupContents"
Data.s "Win32_ProgramGroupOrItem"
Data.s "++Storage"
Data.s "Win32_ShadowBy"
Data.s "Win32_ShadowContext"
Data.s "Win32_ShadowCopy"
Data.s "Win32_ShadowDiffVolumeSupport"
Data.s "Win32_ShadowFor"
Data.s "Win32_ShadowOn"
Data.s "Win32_ShadowProvider"
Data.s "Win32_ShadowStorage"
Data.s "Win32_ShadowVolumeSupport"
Data.s "Win32_Volume"
Data.s "Win32_VolumeUserQuota"
Data.s "++Users"
Data.s "Win32_Account"
Data.s "Win32_Group"
Data.s "Win32_GroupInDomain"
Data.s "Win32_GroupUser"
Data.s "Win32_LogonSession"
Data.s "Win32_LogonSessionMappedDisk"
Data.s "Win32_NetworkLoginProfile"
Data.s "Win32_SystemAccount"
Data.s "Win32_UserAccount"
Data.s "Win32_UserInDomain"
Data.s "++Windows NT Event Log"
Data.s "Win32_NTEventlogFile"
Data.s "Win32_NTLogEvent"
Data.s "Win32_NTLogEventComputer"
Data.s "Win32_NTLogEventLog"
Data.s "Win32_NTLogEventUser"
Data.s "++Windows Product Activation"
Data.s "Win32_ComputerSystemWindowsProductActivationSetting"
Data.s "Win32_Proxy"
Data.s "Win32_WindowsProductActivation"
Data.s "+ Installed Applications"
Data.s "Win32_ActionCheck"
Data.s "Win32_ApplicationCommandLine"
Data.s "Win32_ApplicationService"
Data.s "Win32_Binary"
Data.s "Win32_BindImageAction"
Data.s "Win32_CheckCheck"
Data.s "Win32_ClassInfoAction"
Data.s "Win32_CommandLineAccess"
Data.s "Win32_Condition"
Data.s "Win32_CreateFolderAction"
Data.s "Win32_DuplicateFileAction"
Data.s "Win32_EnvironmentSpecification"
Data.s "Win32_ExtensionInfoAction"
Data.s "Win32_FileSpecification"
Data.s "Win32_FontInfoAction"
Data.s "Win32_IniFileSpecification"
Data.s "Win32_InstalledSoftwareElement"
Data.s "Win32_LaunchCondition"
Data.s "Win32_ManagedSystemElementResource"
Data.s "Win32_MIMEInfoAction"
Data.s "Win32_MoveFileAction"
Data.s "Win32_MSIResource"
Data.s "Win32_ODBCAttribute"
Data.s "Win32_ODBCDataSourceAttribute"
Data.s "Win32_ODBCDataSourceSpecification"
Data.s "Win32_ODBCDriverAttribute"
Data.s "Win32_ODBCDriverSoftwareElement"
Data.s "Win32_ODBCDriverSpecification"
Data.s "Win32_ODBCSourceAttribute"
Data.s "Win32_ODBCTranslatorSpecification"
Data.s "Win32_Patch"
Data.s "Win32_PatchFile"
Data.s "Win32_PatchPackage"
Data.s "Win32_Product"
Data.s "Win32_ProductCheck"
Data.s "Win32_ProductResource"
Data.s "Win32_ProductSoftwareFeatures"
Data.s "Win32_ProgIDSpecification"
Data.s "Win32_Property"
Data.s "Win32_PublishComponentAction"
Data.s "Win32_RegistryAction"
Data.s "Win32_RemoveFileAction"
Data.s "Win32_RemoveIniAction"
Data.s "Win32_ReserveCost"
Data.s "Win32_SelfRegModuleAction"
Data.s "Win32_ServiceControl"
Data.s "Win32_ServiceSpecification"
Data.s "Win32_ServiceSpecificationService"
Data.s "Win32_SettingCheck"
Data.s "Win32_ShortcutAction"
Data.s "Win32_ShortcutSAP"
Data.s "Win32_SoftwareElement"
Data.s "Win32_SoftwareElementAction"
Data.s "Win32_SoftwareElementCheck"
Data.s "Win32_SoftwareElementCondition"
Data.s "Win32_SoftwareElementResource"
Data.s "Win32_SoftwareFeature"
Data.s "Win32_SoftwareFeatureAction"
Data.s "Win32_SoftwareFeatureCheck"
Data.s "Win32_SoftwareFeatureParent"
Data.s "Win32_SoftwareFeatureSoftwareElements"
Data.s "Win32_TypeLibraryAction"
Data.s "+ WMI Service Management"
Data.s "++WMI Configuration"
Data.s "Win32_MethodParameterClass"
Data.s "++WMI Management"
Data.s "Win32_WMISetting"
Data.s "Win32_WMIElementSetting"
Data.s "+ Performance Counter"
Data.s "++Formatted Performance Counter"
Data.s "Win32_PerfFormattedData"
Data.s "Win32_PerfFormattedData_ASP_ActiveServerPages"
Data.s "Win32_PerfFormattedData_ContentFilter_IndexingServiceFilter"
Data.s "Win32_PerfFormattedData_ContentIndex_IndexingService"
Data.s "Win32_PerfFormattedData_InetInfo_InternetInformationServicesGlobal"
Data.s "Win32_PerfFormattedData_ISAPISearch_HttpIndexingService"
Data.s "Win32_PerfFormattedData_MSDTC_DistributedTransactionCoordinator"
Data.s "Win32_PerfFormattedData_NTFSDRV_SMTPNTFSStoreDriver"
Data.s "Win32_PerfFormattedData_PerfDisk_LogicalDisk"
Data.s "Win32_PerfFormattedData_PerfDisk_PhysicalDisk"
Data.s "Win32_PerfFormattedData_PerfNet_Browser"
Data.s "Win32_PerfFormattedData_PerfNet_Redirector"
Data.s "Win32_PerfFormattedData_PerfNet_Server"
Data.s "Win32_PerfFormattedData_PerfNet_ServerWorkQueues"
Data.s "Win32_PerfFormattedData_PerfOS_Cache"
Data.s "Win32_PerfFormattedData_PerfOS_Memory"
Data.s "Win32_PerfFormattedData_PerfOS_Objects"
Data.s "Win32_PerfFormattedData_PerfOS_PagingFile"
Data.s "Win32_PerfFormattedData_PerfOS_Processor"
Data.s "Win32_PerfFormattedData_PerfOS_System"
Data.s "Win32_PerfFormattedData_PerfProc_FullImage_Costly"
Data.s "Win32_PerfFormattedData_PerfProc_Image_Costly"
Data.s "Win32_PerfFormattedData_PerfProc_JobObject"
Data.s "Win32_PerfFormattedData_PerfProc_JobObjectDetails"
Data.s "Win32_PerfFormattedData_PerfProc_Process"
Data.s "Win32_PerfFormattedData_PerfProc_ProcessAddressSpace_Costly"
Data.s "Win32_PerfFormattedData_PerfProc_Thread"
Data.s "Win32_PerfFormattedData_PerfProc_ThreadDetails_Costly"
Data.s "Win32_PerfFormattedData_PSched_PSchedFlow"
Data.s "Win32_PerfFormattedData_PSched_PSchedPipe"
Data.s "Win32_PerfFormattedData_RemoteAccess_RASPort"
Data.s "Win32_PerfFormattedData_RemoteAccess_RASTotal"
Data.s "Win32_PerfFormattedData_RSVP_ACSRSVPInterfaces"
Data.s "Win32_PerfFormattedData_RSVP_ACSRSVPService"
Data.s "Win32_PerfFormattedData_SMTPSVC_SMTPServer"
Data.s "Win32_PerfFormattedData_Spooler_PrintQueue"
Data.s "Win32_PerfFormattedData_TapiSrv_Telephony"
Data.s "Win32_PerfFormattedData_Tcpip_ICMP"
Data.s "Win32_PerfFormattedData_Tcpip_IP"
Data.s "Win32_PerfFormattedData_Tcpip_NBTConnection"
Data.s "Win32_PerfFormattedData_Tcpip_NetworkInterface"
Data.s "Win32_PerfFormattedData_Tcpip_TCP"
Data.s "Win32_PerfFormattedData_Tcpip_UDP"
Data.s "Win32_PerfFormattedData_TermService_TerminalServices"
Data.s "Win32_PerfFormattedData_TermService_TerminalServicesSession"
Data.s "Win32_PerfFormattedData_W3SVC_WebService"
Data.s "++Raw Performance Counter"
Data.s "Win32_PerfRawData"
Data.s "Win32_PerfRawData_ASP_ActiveServerPages"
Data.s "Win32_PerfRawData_ContentFilter_IndexingServiceFilter"
Data.s "Win32_PerfRawData_ContentIndex_IndexingService"
Data.s "Win32_PerfRawData_InetInfo_InternetInformationServicesGlobal"
Data.s "Win32_PerfRawData_ISAPISearch_HttpIndexingService"
Data.s "Win32_PerfRawData_MSDTC_DistributedTransactionCoordinator"
Data.s "Win32_PerfRawData_NTFSDRV_SMTPNTFSStoreDriver"
Data.s "Win32_PerfRawData_PerfDisk_LogicalDisk"
Data.s "Win32_PerfRawData_PerfDisk_PhysicalDisk"
Data.s "Win32_PerfRawData_PerfNet_Browser"
Data.s "Win32_PerfRawData_PerfNet_Redirector"
Data.s "Win32_PerfRawData_PerfNet_Server"
Data.s "Win32_PerfRawData_PerfNet_ServerWorkQueues"
Data.s "Win32_PerfRawData_PerfOS_Cache"
Data.s "Win32_PerfRawData_PerfOS_Memory"
Data.s "Win32_PerfRawData_PerfOS_Objects"
Data.s "Win32_PerfRawData_PerfOS_PagingFile"
Data.s "Win32_PerfRawData_PerfOS_Processor"
Data.s "Win32_PerfRawData_PerfOS_System"
Data.s "Win32_PerfRawData_PerfProc_FullImage_Costly"
Data.s "Win32_PerfRawData_PerfProc_Image_Costly"
Data.s "Win32_PerfRawData_PerfProc_JobObject"
Data.s "Win32_PerfRawData_PerfProc_JobObjectDetails"
Data.s "Win32_PerfRawData_PerfProc_Process"
Data.s "Win32_PerfRawData_PerfProc_ProcessAddressSpace_Costly"
Data.s "Win32_PerfRawData_PerfProc_Thread"
Data.s "Win32_PerfRawData_PerfProc_ThreadDetails_Costly"
Data.s "Win32_PerfRawData_PSched_PSchedFlow"
Data.s "Win32_PerfRawData_PSched_PSchedPipe"
Data.s "Win32_PerfRawData_RemoteAccess_RASPort"
Data.s "Win32_PerfRawData_RemoteAccess_RASTotal"
Data.s "Win32_PerfRawData_RSVP_ACSRSVPInterfaces"
Data.s "Win32_PerfRawData_RSVP_ACSRSVPService"
Data.s "Win32_PerfRawData_SMTPSVC_SMTPServer"
Data.s "Win32_PerfRawData_Spooler_PrintQueue"
Data.s "Win32_PerfRawData_TapiSrv_Telephony"
Data.s "Win32_PerfRawData_Tcpip_ICMP"
Data.s "Win32_PerfRawData_Tcpip_IP"
Data.s "Win32_PerfRawData_Tcpip_NBTConnection"
Data.s "Win32_PerfRawData_Tcpip_NetworkInterface"
Data.s "Win32_PerfRawData_Tcpip_TCP"
Data.s "Win32_PerfRawData_Tcpip_UDP"
Data.s "Win32_PerfRawData_TermService_TerminalServices"
Data.s "Win32_PerfRawData_TermService_TerminalServicesSession"
Data.s "Win32_PerfRawData_W3SVC_WebService"
Data.s "+ Security Descriptor Helper"
Data.s "Win32_SecurityDescriptor"
Data.s "-1";end of data
EndDataSection
Mesa.

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : lun. 17/sept./2012 14:21
par falsam
WMI ..... je ne sais pas ou tu as trouvé ce code mais chapeau à celui qui a réussi à l'implanter avec Pure basic !!! On peut aussi implanter les fonctionnalités de WMI avec Comate.

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : lun. 17/sept./2012 14:24
par falsam
@Ar-s si tu as l'include comate.pbi essaye ce code pour détecter la carte mére. ça fonctionne sous Windows XP et 7

Code : Tout sélectionner

;Information system : Carte mére
XIncludeFile "COMatePLUS.pbi"

Define.COMateObject objWMIService, MotherBoard
  
Global Result.COMateEnumObject 
Global strComputer.s = "." 
Global Buffer.s


objWMIService = COMate_GetObject("winmgmts:\\" + strComputer + "\root\cimv2", "") 
If objWMIService
  Result = objWMIService\CreateEnumeration("ExecQuery('Select * from Win32_BaseBoard')")
    
  If Result
    MotherBoard = Result\GetNextObject()
    While MotherBoard
        
      Buffer = "Constructeur "+ MotherBoard\GetStringProperty("Manufacturer") + #CRLF$
      Buffer + "Reference " + MotherBoard\GetStringProperty("Product") + #CRLF$
      Buffer + "N° de série "+  MotherBoard\GetStringProperty("SerialNumber") + #CRLF$ 
      Buffer + "Version "+ MotherBoard\GetStringProperty("Version") + #CRLF$        
          
      MotherBoard\Release()
      MotherBoard = Result\GetNextObject()
    Wend 
    Result\Release()
       
  EndIf 
  
  MessageRequester("Carte mére", Buffer)   
  objWMIService\Release()
    
Else
  MessageRequester("Information", "Erreur WMI")  
EndIf

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : lun. 17/sept./2012 14:27
par Ar-S
J'ai réglé le soucis de carte mère (voir dans Application/MONPC)
J'aimerai y arriver sans inclure Comate

Vraiment pas mal ce code même si sous w7 il affiche moins d'infos et peut crasher.
Par contre il affiche l'info que je recherche à savoir le WMI : Win32_VideoController et sa descriptin (son nom).
Faut que je sorte le scalpel.
Merci :D

Re: Récupérer le nom de sa carte mère et le socket ?

Publié : lun. 17/sept./2012 15:53
par kernadec
bonjour
merci Mesa pour ton code.

il y a aussi ce code pour CPU et son numéro

Cordialement

Code : Tout sélectionner

;http://www.purebasic.fr/english/viewtopic.php?f=13&t=50510&start=12
; danilo
; Import "Kernel32.lib"
;     CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
;         GetNativeSystemInfo_(*si.SYSTEM_INFO) As "_GetNativeSystemInfo@4"
;     CompilerElse
;         GetNativeSystemInfo_(*si.SYSTEM_INFO) As "GetNativeSystemInfo"
;     CompilerEndIf
; EndImport


Declare CpuArchitecture()
Declare.s GetOsVersn()
Declare.s OSbits()
Declare.s GetOsServicePack()
Declare.s GetWindowsProductKey()
Declare.s GetCpuName()
Declare.q GetCpuNumber()
Declare.s GetPcName()

Global sgProcessorArchitecture.s = ""
Global sgPageSize.s = ""
Global sgNumberOfProcessors.s = ""

Import "kernel32.lib"
  GlobalMemoryStatusEx.i(*lpBuffer)
EndImport

Procedure CpuArchitecture()
  ;--------------------------
  
  #PROCESSOR_ARCHITECTURE_INTEL = 0
  #PROCESSOR_ARCHITECTURE_MIPS = 1
  #PROCESSOR_ARCHITECTURE_ALPHA = 2
  #PROCESSOR_ARCHITECTURE_PPC = 3
  #PROCESSOR_ARCHITECTURE_IA64 = 6
  #PROCESSOR_ARCHITECTURE_AMD64 = 9 ; = AMD or Intel 64bit processor (std defined by AMD)
  #PROCESSOR_ARCHITECTURE_UNKNOWN = $FFFF
  
  Protected ThisSystemInfo.SYSTEM_INFO
  
  If OSVersion() < #PB_OS_Windows_XP
    GetSystemInfo_(ThisSystemInfo)
  Else
    ;GetNativeSystemInfo_(ThisSystemInfo.SYSTEM_INFO) ; do not use 'Import', use OpenLibrary instead
    
    Protected OK, hDLL, GetNativeSystemInfo_
    hDll = OpenLibrary(#PB_Any,"kernel32.dll")
    If hDll
      GetNativeSystemInfo_ = GetFunction(hDll,"GetNativeSystemInfo")
      If GetNativeSystemInfo_
        CallFunctionFast(GetNativeSystemInfo_, ThisSystemInfo.SYSTEM_INFO)
        OK = #True
      EndIf
      CloseLibrary(hDll)
    EndIf
    If Not OK
      GetSystemInfo_(ThisSystemInfo)
    EndIf
  EndIf
  
  Select ThisSystemInfo\wProcessorArchitecture
      
    Case #PROCESSOR_ARCHITECTURE_AMD64 : sgProcessorArchitecture = "CPU Architecture: x64 (AMD or Intel)"
      ;Case #PROCESSOR_ARCHITECTURE_IA64  : sgProcessorArchitecture = "CPU Architecture: Intel Itanium"
    Case #PROCESSOR_ARCHITECTURE_INTEL : sgProcessorArchitecture = "CPU Architecture: x86"
      ;Case #PROCESSOR_ARCHITECTURE_MIPS  : sgProcessorArchitecture = "CPU Architecture: MIPS"
      ;Case #PROCESSOR_ARCHITECTURE_ALPHA : sgProcessorArchitecture = "CPU Architecture: ALPHA"
      ;Case #PROCESSOR_ARCHITECTURE_PPC   : sgProcessorArchitecture = "CPU Architecture: Power PC"
    Default : sgProcessorArchitecture = "CPU Architecture: Unknown"
      
  EndSelect
  
  sgPageSize = Str(ThisSystemInfo\dwPageSize)
  sgNumberOfProcessors = Str(ThisSystemInfo\dwNumberOfProcessors)
  
EndProcedure

Procedure.s GetOsVersn()
  ;----------------------
  
  sVersion.s = ""
  
  Select OSVersion()
      
    Case #PB_OS_Windows_NT3_51:       sVersion = "Windows NT3.51"
    Case #PB_OS_Windows_95:           sVersion = "Windows 95"
    Case #PB_OS_Windows_NT_4:         sVersion = "Windows NT4"
    Case #PB_OS_Windows_98:           sVersion = "Windows 98"
    Case #PB_OS_Windows_ME:           sVersion = "Windows ME"
    Case #PB_OS_Windows_2000:         sVersion = "Windows 2000"
    Case #PB_OS_Windows_XP:           sVersion = "Windows XP"
    Case #PB_OS_Windows_Server_2003:  sVersion = "Windows Server 2003"
    Case #PB_OS_Windows_Vista:        sVersion = "Windows Vista"
    Case #PB_OS_Windows_Server_2008:  sVersion = "Windows Server 2008"
    Case #PB_OS_Windows_7:            sVersion = "Windows 7"
    Case #PB_OS_Windows_Future:       sVersion = "Windows 8"
    Default:                          sVersion = "Windows Version not identified"
      
  EndSelect
  
  ProcedureReturn sVersion
  
EndProcedure

Procedure.s OSbits()
  ;-------------------
  ; Check if the OS is 32 or 64 bit.
  ;
  Protected Is64BitOS = 0
  Protected hDLL, IsWow64Process_
  Protected sOSbits.s = "32"
  
  If SizeOf(Integer) = 8
    
    sOSbits = "64"
  Else
    
    hDll = OpenLibrary(#PB_Any,"kernel32.dll")
    If hDll
      
      IsWow64Process_ = GetFunction(hDll,"IsWow64Process")
      If IsWow64Process_
        
        CallFunctionFast(IsWow64Process_, GetCurrentProcess_(), @Is64BitOS)
        
      EndIf
      
      CloseLibrary(hDll)
    EndIf
    
    If(Is64BitOS = 1) : sOSbits = "64" : EndIf
  EndIf
  
  ProcedureReturn sOSbits
  
EndProcedure

Procedure.s GetOsServicePack()
  ;-----------------------------
  
  OSVerInfo.OSVERSIONINFOEX
  
  OSVerInfo\dwOSVersionInfoSize = SizeOf(OSVERSIONINFOEX)
  
  GetVersionEx_(@OSVerInfo)
  
  sServicePack.s = "SP" + Str(OSVerInfo\wServicePackMajor) + "." + Str(OSVerInfo\wServicePackMinor) + " [Build " + Str(OSVerInfo\dwBuildNumber) + "]"
  
  ProcedureReturn sServicePack
  
EndProcedure

Procedure.s GetWindowsProductKey()
  ;---------------------------------
  
  #KEY_WOW64_64KEY = $100
  
  Protected hKey, Res, size = 280
  Protected i, j, x, Result.s
  Protected *mem = AllocateMemory(size)
  Protected *newmem = AllocateMemory(size)
  Protected *digits = AllocateMemory(25)
  
  PokeS(*digits, "BCDFGHJKMPQRTVWXY2346789", -1, #PB_Ascii)
  
  If OSVersion() <= #PB_OS_Windows_2000
    
    Res = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT\CurrentVersion", 0, #KEY_READ, @hKey)
    
  Else
    
    Res = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT\CurrentVersion", 0, #KEY_READ | #KEY_WOW64_64KEY, @hKey)
    
  EndIf
  
  If Res = #ERROR_SUCCESS
    
    RegQueryValueEx_(hKey, "DigitalProductID", 0, 0, *mem, @size)
    RegCloseKey_(hKey)
    
    If size <> 280
      
      For i = 24 To 0 Step -1
        x = 0
        
        For j = 66 To 52 Step -1
          x = (x << 8) + PeekA(*mem + j)
          PokeA(*mem + j, x / 24)
          x % 24
        Next
        
        PokeA(*newmem + i, PeekA(*digits + x))
      Next
      
      For i = 0 To 15 Step 5
        
        Result + PeekS(*newmem + i, 5, #PB_Ascii) + "-"
        
      Next
      
      Result + PeekS(*newmem + 20, 5, #PB_Ascii)
      
    EndIf
  EndIf
  
  FreeMemory(*mem) : FreeMemory(*newmem) : FreeMemory(*digits)
  
  ProcedureReturn Result
  
EndProcedure

Procedure.s GetCpuName()
  ;-----------------------
  
  Protected sBuffer.s
  Protected Zeiger1.i, Zeiger2.i, Zeiger3.i, Zeiger4.i
  
  !MOV eax, $80000002
  !CPUID
  ; the CPU-Name is now stored in EAX-EBX-ECX-EDX
  !MOV [p.v_Zeiger1], EAX ; move eax to the buffer
  !MOV [p.v_Zeiger2], EBX ; move ebx to the buffer
  !MOV [p.v_Zeiger3], ECX ; move ecx to the buffer
  !MOV [p.v_Zeiger4], EDX ; move edx to the buffer
  
  ;Now move the content of Zeiger (4*4=16 Bytes to a string
  sBuffer = PeekS(@Zeiger1, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger2, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger3, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger4, 4, #PB_Ascii)
  
  ;Second Part of the Name
  !MOV eax, $80000003
  !CPUID
  ; the CPU-Name is now stored in EAX-EBX-ECX-EDX
  !MOV [p.v_Zeiger1], EAX ; move eax to the buffer
  !MOV [p.v_Zeiger2], EBX ; move ebx to the buffer
  !MOV [p.v_Zeiger3], ECX ; move ecx to the buffer
  !MOV [p.v_Zeiger4], EDX ; move edx to the buffer
  
  ;Now move the content of Zeiger (4*4=16 Bytes to a string
  sBuffer + PeekS(@Zeiger1, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger2, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger3, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger4, 4, #PB_Ascii)
  
  
  ;Third Part of the Name
  !MOV eax, $80000004
  !CPUID
  ; the CPU-Name is now stored in EAX-EBX-ECX-EDX
  !MOV [p.v_Zeiger1], EAX ; move eax to the buffer
  !MOV [p.v_Zeiger2], EBX ; move ebx to the buffer
  !MOV [p.v_Zeiger3], ECX ; move ecx to the buffer
  !MOV [p.v_Zeiger4], EDX ; move edx to the buffer
  
  ;Now move the content of Zeiger (4*4=16 Bytes to a string
  sBuffer + PeekS(@Zeiger1, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger2, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger3, 4, #PB_Ascii)
  sBuffer + PeekS(@Zeiger4, 4, #PB_Ascii)
  
  sCpuName.s = RemoveString(sBuffer,"   ",#PB_String_NoCase)
  
  ProcedureReturn sCpuName
  
EndProcedure

Procedure.q GetCpuNumber()
  ;-------------------------
  
  Define highbits.l
  Define lowbits.l
  Define serial.q
  
  !MOV eax, $80000003
  !CPUID
  !MOV dword [p.v_lowbits], ecx
  !MOV dword [p.v_highbits], edx
  
  serial = lowbits | highbits << 32
  
  ProcedureReturn serial
  
EndProcedure


Procedure.s GetPcName()
  ;----------------------
  
  Protected sComputerName.s = GetEnvironmentVariable("COMPUTERNAME")
  
  If sComputerName
    
    sComputerName = "Computer Name: " + sComputerName
  Else
    sComputerName = "Not Found"
  EndIf
  
  ProcedureReturn(sComputerName)
  
EndProcedure

;==== TEST ========
CpuArchitecture()
Debug sgProcessorArchitecture
Debug sgPageSize
Debug sgNumberOfProcessors

Debug GetOsVersn()
Debug OSbits()
Debug GetOsServicePack()
Debug GetWindowsProductKey()
Debug GetCpuName()
Debug GetCpuNumber()
Debug GetPcName()