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: naveed ahmad
  Where is naveed ahmad?
 peshawar
 Pakistan
 naveed ahmad
 Tags
Subject: RE: Hard Disk Serial Number Problem
Thread ID: 393678 Message ID: 393684 # Views: 47 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Saturday, December 21, 2013 4:05:43 PM         
   


> >
> >
> > Hi,
> >
> > Please try my code example below and advise if this works as expected:
> >
* --- GetHDInfo.prg
> > 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 STARRED OUT FOR DEBUGGING PURPOSES ONLY.
> > * --- BROWSE 
> > LOCATE FOR ALLTRIM(DEVICEIDENTIFIER) == "C:"
> > lcHDSerialNo = ALLTRIM(SERIALNOS)
> > 
> > * --- Issue USE to close this local cursor.
> > USE
> > 
> > * --- Return the C:\ drives serial number.
> > RETURN lcHDSerialNo

> >
> >
> >
> >
> > You can un-star the line * --- BROWSE and see what drive information you are obtaining.
> > Set the code line below:
> >
LOCATE FOR ALLTRIM(DEVICEIDENTIFIER) == "C:"

> > to set what drive letter you want to get the serial number for.
> >
> >
> >
> >
> > Pete "the IceMan", from the Great White North of Canada.
> > www.marathongriffincomputers.com
>
> dear sir,
> thanks for reply, i have tried your code also but same result, i made form where have one textbox and one button i code on button click event it works my system very well but not respond another system. please guide me what should i do for this problem.
> thanks a lot.
> regards


Hi,

I would suggest you try on a few other systems and if works on them all but the
one you have the issue with... maybe not code issue maybe computer issue.

Anything strange about the computer that the code does not work on such as:
- Solid state drive SSD?
- Can you see the HD in the computer BIOS setup?
- Are there hard drive errors in the Windows system event log?
- etc.

The routine I sent to you is running on over 350 systems and these systems are a mixture
of XP, Vista, Win7 and a few Win8 and code is working.
I have not tested on Win8.1 as yet!

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

ENTIRE THREAD

Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/21/2013 1:58:34 PM
RE: Hard Disk Serial Number Problem Posted by Pete Sass @ 12/21/2013 2:32:54 PM
RE: Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/21/2013 2:39:56 PM
RE: Hard Disk Serial Number Problem Posted by Pete Sass @ 12/21/2013 4:05:43 PM
RE: Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/23/2013 8:35:33 AM
RE: Hard Disk Serial Number Problem Posted by Pete Sass @ 12/23/2013 2:51:58 PM
RE: Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/23/2013 3:22:47 PM
RE: Hard Disk Serial Number Problem Posted by Pete Sass @ 12/24/2013 8:11:42 PM
RE: Hard Disk Serial Number Problem Posted by Tore Bleken @ 12/21/2013 6:24:19 PM
RE: Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/23/2013 8:32:47 AM