Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding hard disk serial no.

Status
Not open for further replies.

rehanqadri

Programmer
Jan 31, 2004
40
PK
HOW CAN I FIND HARD DISK SERIAL NO. WHILE IN MY FOXPRO PROGRAMMING ENVIRONMENT.
 
In Visual FoxPro it's really easy, but making the API call in FPW in difficult and impossible in FPD.

You best bet may be to RUN the VOL command and pipe it to a file, then use FoxPro's low-level IO functions to read the resulting text file. There will be minimal parsing to pull out the serial number.

Rick
 
This is what rick is reffering to:


Function ReadSerial()
Local Serial,nHandle
Run VOL > SER
nHandle = Fopen("SER")
If Ferror() != 0
? Ferror()
Inkey(0)
Endif
Fseek(nHandle,-11,2)
Serial = FREADSTR(nHandle,9)
Fclose(nHandle)
Ferase("SER")
Return(Serial)


Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
u can try this program,
? VOLSER("C:")
? VOLSER("w:")
* VOLSER.PRG
PARAMETERS pcDrive
PRIVATE lcCommand, lnHandle, lcLine, lcSerialNo
lcCommand = "VOL "+pcDrive+" > c:\vol.txt"
RUN &lcCommand
=INKEY(1) && stall for file to be created (may need to adjust)
lcSerialNo = "(unknown)"
lnHandle = FOPEN("c:\vol.txt",0)
IF lnHandle > 0
   DO WHILE NOT FEOF(lnHandle)
      lcLine = FGETS(lnHandle)
      IF "SERIAL NUMBER" $ UPPER(lcLine)
         lcSerialNo = RIGHT(lcLine, 9)
         EXIT
      ENDIF
   ENDDO
   =FCLOSE(lnHandle)
ELSE
   WAIT WINDOW "Try increasing the INKEY() time"
ENDIF
RETURN lcSerialN

-giri
 
Just a couple corrections and clarifications:
Code:
Function ReadSerial()
Private Serial,nHandle
Run VOL > SER.TXT
 = INKEY(0.001) && stall - give it time to close
nHandle = Fopen("SER.TXT")
If Ferror() != 0
   ? Ferror()
   = Inkey(0)
   RETURN -1
Endif
 = Fseek(nHandle,-11,2)
Serial = FREAD(nHandle,9)
 = Fclose(nHandle)
ERASE "SER.TXT"
Return(Serial)
FP 2.x doesn't know about LOCALs, and it really doesn't like not having returned values ( requires the = on Inkey(),FSEEK() and FCLOSE()). Especially on NT/2000/XP the slight delay after the RUN VOL command makes it more likely that the file will be available.

Rick
 
Thanks Rick.. I copied this from my Old Collection of Clipper Apps :)

But, I think he got the idea.

Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
I think, we have misunderstood the question. It is the Hard Disk Serial number not Volumn serial Number.

The only way to do is assembly code call to the hard disk controller, depending on the type of hard disk (MFM,IDE, SCSI,etc.) It is not high level programming language problem. You need OEM reference manual for the type of drive(s) and then make a (bios) call to read the correct SECTOR of the hard disk where the serial number is stored.

Nasib Kalsi
Try it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top