Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Taz
  Where is Taz?
 semarang
 Indonesia
 Taz
 To: Sherina -
  Where is Sherina -?
 Cirebon
 Indonesia
 Sherina -
 Tags
Subject: RE: Disk volume, silinder, and serial number
Thread ID: 84770 Message ID: 84949 # Views: 32 # Ratings: 0
Version: Visual FoxPro 9 Category: Install & Config. issues
Date: Monday, December 26, 2005 8:21:49 AM         
   


what about this prg? i forgot where i got it, it return hdd sn. but i'm not sure about hdd sn changes after formated. here's the code:
**************************************************
GetVolumeInformation
*
*
*** Declare Local Variables ***
LOCAL i && counter
LOCAL lnDrvType && DRIVETYPE
LOCAL lcDrive && string
LOCAL lnDrive && bitmap of legal drives

* standard declares for WinAPI calls
LOCAL lpRootPathName, ;
lpVolumeNameBuffer, ;
lpVolumeSerialNumber, ;
lpMaximumComponentLength, ;
lpFileSystemFlags, ;
lpFileSystemNameBuffer, ;
nVolumeNameSize, ;
nFileSystemNameSize

*** Declare API calls ***
* GetDriveType() returns numeric type of drive
DECLARE INTEGER GetDriveType IN WIN32API ;
STRING lpRootPathName && address of root path

* GetLogicalDrives() returns a bitmap of
* "legal" logical drives
DECLARE INTEGER GetLogicalDrives in win32api

* GetVolumeInformation() returns volume names, ;
serial numbers, file systems, and other stuff.

DECLARE short GetVolumeInformation IN Win32API ;
STRING lpRootPathName, ;
STRING lpVolumeNameBuffer, ;
INTEGER nVolumeNameSize, ;
STRING lpVolumeSerialNumber, ;
STRING lpMaximumComponentLength, ;
STRING lpFileSystemFlags, ;
STRING lpFileSystemNameBuffer, ;
INTEGER nFileSystemNameSize

* GetDriveType RETURN VALUES:
#DEFINE DRIVE_NONE 0 && Cannot be determined.
#DEFINE DRIVE_BAD 1 && Root directory does not exist.
#DEFINE DRIVE_REMOVABLE 2 && Disk can be removed.
#DEFINE DRIVE_FIXED 3 && Disk cannot be removed.
#DEFINE DRIVE_REMOTE 4 && Drive is remote/network drive.
#DEFINE DRIVE_CDROM 5 && The drive is a CD-ROM drive.
#DEFINE DRIVE_RAMDISK 6 && The drive is a RAM disk.

*** Get bitmap of legal drives ***
lnDrive = GetLogicalDrives()

lcDrive = CHR(ASC("A")+2)+":\" && translate to letter (C:)

* Set the defaults for floppies
lpVolumeNameBuffer = ""
lnDriveType = DRIVE_REMOVABLE

* Skip trying to obtain the name or drive type of
* floppies: this can bring up an untrappable error

* Obtain the Volume Name
STORE SPACE(255) TO lpRootPathName, ;
lpVolumeNameBuffer, ;
lpVolumeSerialNumber, ;
lpMaximumComponentLength, ;
lpFileSystemFlags, ;
lpFileSystemNameBuffer

STORE 255 TO nVolumeNameSize, nFileSystemNameSize

= GetVolumeInformation(lcDrive, ;
@lpVolumeNameBuffer, ;
@nVolumeNameSize, ;
@lpVolumeSerialNumber, ;
@lpMaximumComponentLength, ;
@lpFileSystemFlags, ;
@lpFileSystemNameBuffer, ;
@nFileSystemNameSize )



* Truncate the buffer to the CHR(0) end of string
* or to zero for blank volumes
lpVolumeNameBuffer = LEFT(lpVolumeNameBuffer, ;
AT(CHR(0),lpVolumeNameBuffer)-1)

* Get the volume's drive type
lnDriveType = GetDriveType(lcDrive)


cReturnHex = ""
FOR y = 1 TO LEN(ALLTRIM(lpVolumeSerialNumber))
cStreng = SUBSTR(lpVolumeSerialNumber,y,1)
cBin = Dec2Bin(ASC(cStreng))
cHex = Bin2Hex(cBin)
IF LEN(cHex) = 1
cHex = "0" + cHex
ENDIF
cReturnHex = cHex + cReturnHex
ENDFOR y

*!* WAIT WINDOW "Serialno. "+cReturnHex

RETURN cReturnHex




* Function Bin2Hex
*
* Function to convert BIN to HEX
*
FUNCTION Bin2Hex
PARAMETERS cBin
PRIVATE nBinLen, nZeroLen, cHexValue, nLoopX, cBit, cHex

nBinLen = LEN(cBin)
nZeroLag = ROUND((nBinLen/4)+.49,0)*4 - nBinLen
cBin = REPLICATE("0",nZeroLag)+cBin

cHexValue = ""
FOR nLoopX = 1 TO LEN(cBin) STEP 4
cBit = SUBSTR(cBin,nLoopX,4)
DO CASE
CASE cBit = "0000"
cHex = "0"
CASE cBit = "0001"
cHex = "1"
CASE cBit = "0010"
cHex = "2"
CASE cBit = "0011"
cHex = "3"
CASE cBit = "0100"
cHex = "4"
CASE cBit = "0101"
cHex = "5"
CASE cBit = "0110"
cHex = "6"
CASE cBit = "0111"
cHex = "7"
CASE cBit = "1000"
cHex = "8"
CASE cBit = "1001"
cHex = "9"
CASE cBit = "1010"
cHex = "A"
CASE cBit = "1011"
cHex = "B"
CASE cBit = "1100"
cHex = "C"
CASE cBit = "1101"
cHex = "D"
CASE cBit = "1110"
cHex = "E"
CASE cBit = "1111"
cHex = "F"
ENDCASE
cHexValue = cHexValue + cHex
NEXT

RETURN cHexValue

* End of Function * Bin2Hex() *


* Function Dec2Bin
*
* Function to convert Decimal to BIN
*
FUNCTION Dec2Bin
PARAMETERS nValue
PRIVATE nValue, cBinStr, nRest

cBinStr = ""
DO WHILE .T.
nRest = MOD(nValue,2)
nValue = INT(nValue/2)
cBinStr = STR(nRest,1) + cBinStr
IF nValue = 0
EXIT
ENDIF
ENDDO

RETURN cBinStr

* End of Function * Dec2Bin() *
*********************************
just save it to a prg, than call it

http://fox-id.org
the Indonesian FoxPro Community
:: 2Share,2Learn,2Act ::



COMPLETE THREAD
Disk volume, silinder, and serial number Posted by Sherina - @ 12/22/2005 11:32:18 PM
RE: Disk volume, silinder, and serial number Posted by Barbara Peisch @ 12/23/2005 1:30:00 AM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/23/2005 2:51:49 AM
RE: Disk volume, silinder, and serial number Posted by Barbara Peisch @ 12/23/2005 3:00:51 AM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/23/2005 3:36:48 AM
RE: Disk volume, silinder, and serial number Posted by Barbara Peisch @ 12/23/2005 5:53:31 AM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/23/2005 6:46:21 AM
RE: Disk volume, silinder, and serial number Posted by Barbara Peisch @ 12/23/2005 6:54:01 PM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/24/2005 12:15:56 AM
RE: Disk volume, silinder, and serial number Posted by Barbara Peisch @ 12/24/2005 12:40:22 AM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/24/2005 6:19:15 PM
RE: Disk volume, silinder, and serial number Posted by Taz @ 12/26/2005 8:21:49 AM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/26/2005 2:09:15 PM
RE: Disk volume, silinder, and serial number Posted by Stuart Dunkeld @ 12/23/2005 3:26:22 AM
RE: Disk volume, silinder, and serial number Posted by Barbara Peisch @ 12/23/2005 3:47:33 AM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/23/2005 5:18:01 AM
RE: Disk volume, silinder, and serial number Posted by Mike Gagnon @ 12/24/2005 2:23:13 PM
RE: Disk volume, silinder, and serial number Posted by Mike Gagnon @ 12/24/2005 2:47:39 PM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/24/2005 6:27:28 PM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/26/2005 2:27:22 PM
RE: Disk volume, silinder, and serial number Posted by Patrick McGreevy @ 12/24/2005 2:01:28 AM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/24/2005 6:23:41 PM
RE: Disk volume, silinder, and serial number Posted by Patrick McGreevy @ 12/27/2005 2:51:01 AM
RE: Disk volume, silinder, and serial number Posted by Sherina - @ 12/27/2005 8:12:13 AM