Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 To: Felipe Melendez
  Where is Felipe Melendez?
 San Salvador
 El Salvador
 Felipe Melendez
 Tags
Subject: RE: cpuid and motherboardid
Thread ID: 395968 Message ID: 396241 # Views: 59 # Ratings: 0
Version: Visual FoxPro 9 Category: Security and Application Protection
Date: Thursday, January 23, 2014 10:41:40 PM         
   


> Hi, im writing right now a new system, and i want to add a security scheme based on
> the cpu id , the motherboard id or the phisical mac address in order to lock the app.
>
> i tried several routines to get those values but in some pc´s
> the only thing i got is 'null' in all, or just the cpuid or the motherboard id
>
> do you have any idea what im doing wrong?, or maybe you have a better way to doit
>
> thanks
>
>
> (sorry my english, spanish is my native languaje)


Hi Felipe,

I believe in some systems the Motherboard SN may not be stored in the BIOS so there could
be cases and systems where you cannot get the motherboard SN. I could be wrong on this
but I have ran into some systems where I was unable to obtain the mb serial number.


Try these:

* --- HDserialNoAll.prg
* --- Modified from Cetin's original code posted to provide manageable cursor to work with!
loWBEMLocator = Createobject("wbemScripting.SwbemLocator")
loWMIService = loWBEMLocator.ConnectServer('', '\root\cimv2')

CREATE CURSOR curHDDinfo (TYPES c(24), DESCRIPTIONS c(24), DEVICEIDENTIFIER c(24), VOLNAMES c(24) NULL, SERIALNOS c(36) NULL, DRIVETAGS c(36) NULL)
IF !ISNULL(loWMIService)
  loLogicalDrives = loWMIService.ExecQuery('Select * from Win32_LogicalDisk')
  For Each loLogicalDrive In loLogicalDrives
     INSERT INTO curHDDINFO (TYPES,DESCRIPTIONS,DEVICEIDENTIFIER,VOLNAMES,SERIALNOS,DRIVETAGS) ;
     VALUES("LOGICAL DISK",ALLTRIM(loLogicalDrive.Description),ALLTRIM(loLogicalDrive.DeviceID), ;
     ALLTRIM(loLogicalDrive.VolumeName),ALLTRIM(loLogicalDrive.VolumeSerialNumber),"")
   Endfor
 
  loPhysicalDrives = loWMIService.ExecQuery('Select * from Win32_PhysicalMedia')
  For Each loPhysicalDrive In loPhysicalDrives
    INSERT INTO curHDDINFO (TYPES,SERIALNOS,DRIVETAGS) VALUES ("PHYSICAL DISK",ALLTRIM(loPhysicalDrive.Tag),ALLTRIM(loPhysicalDrive.SerialNumber))
  Endfor
ENDIF

* --- Browse the local cursor to review the obtain results
* --- Starr out three lines of code below to process the cursor for logical code operatings.
GOTO TOP
BROWSE
USE




THEN YOU CAN ALSO GET THE PROCESSOR ID

* --- GetProcessorID.prg
* --- Syntax:  lcProcerrorID = GetProcessorID()
LOCAL lcComputerName, loWMI, lowmiWin32Objects, lowmiWin32Object
lcComputerName = GETWORDNUM(SYS(0),1)
loWMI = GETOBJECT("WinMgmts://" + lcComputerName)
lowmiWin32Objects = loWMI.InstancesOf("Win32_Processor")
FOR EACH lowmiWin32Object IN lowmiWin32Objects
    WITH lowmiWin32Object
        RETURN TRANSFORM(.ProcessorId)
    ENDWITH
ENDFOR





THEN YOU CAN ALSO GET THE MAC ADDRESS

* --- GetMAC.prg
* --- Syntax: lcMacAddress = GetMAC()
LOCAL lcComputerName, loWMIService, loItems, loItem, lcMACAddress
lcComputerName = "."
loWMIService = GETOBJECT("winmgmts:\\" + lcComputerName + "\root\cimv2")
loItems = loWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
FOR EACH loItem IN loItems
    lcMACAddress = loItem.MACAddress
    IF !ISNULL(lcMACAddress)
        RETURN loItem.MACAddress
    ENDIF
ENDFOR




YOU CAN TRY THIS TO GET THE MOTHERBOARD SN

* --- GetMBSerialNo.prg
loWMI = GETOBJECT("WinMgmts://./root/cimv2")
BaseBoards = loWMI.InstancesOf("Win32_BaseBoard")
FOR EACH MotherBoard IN BaseBoards
?"Product: " + MotherBoard.Product
?"SerialNumber: " + MotherBoard.SerialNumber
NEXT

Pete "the IceMan", from the Great White North of Canada.
www.marathongriffincomputers.com

ENTIRE THREAD

cpuid and motherboardid Posted by Felipe Melendez @ 1/21/2014 11:07:38 PM
RE: cpuid and motherboardid Posted by Tom Saddul @ 1/22/2014 7:09:55 AM
RE: cpuid and motherboardid Posted by Pete Sass @ 1/23/2014 10:41:40 PM
RE: cpuid and motherboardid Posted by Zia Mughal @ 1/24/2014 8:54:41 PM
RE: cpuid and motherboardid Posted by Pete Sass @ 1/24/2014 11:04:12 PM
RE: cpuid and motherboardid Posted by Zia Mughal @ 1/29/2014 2:57:45 PM
RE: cpuid and motherboardid Posted by Pete Sass @ 1/29/2014 8:46:33 PM
RE: cpuid and motherboardid Posted by Felipe Melendez @ 1/28/2014 3:24:07 PM
RE: cpuid and motherboardid Posted by Zia Mughal @ 1/29/2014 3:07:44 PM