Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hard Disk?
Message
From
01/03/1999 03:49:04
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00192296
Message ID:
00192568
Views:
17
>Cetin,
>
>Have you found a way to access track 0 on your hard disk?
>
>Or what utilities do you use to get drive serial number in software?
Hi Eric,
To access track 0 or any other absolute sector I use different strategies based on version (ASM if FP 2.x, FLL if VFP). To just read serial number I use win32api :
function GetVolInfo
lparameters lcRoot, taInfo && Root of drive ie: "c:\", InfoArray passed by ref
DECLARE SHORT GetVolumeInformation IN Win32API;
  STRING @lpRootPathName, STRING @lpVolumeNameBuffer,;
  INTEGER nVolumeNameSize, INTEGER @lpVolumeSerialNumber,;
  INTEGER @lpMaximumComponentLength, INTEGER @lpFileSystemFlags,;
  STRING @lpFileSystemNameBuffer, INTEGER nFileSystemNameSize
STORE 0 TO lnserialno, lncomplen, lnsysflags
STORE SPACE(260) TO lcvolname, lcsysname
STORE LEN(lcvolname) TO lnvolsize, lnnamesize
if (GetVolumeInformation(@lcroot, @lcvolname,;
  lnvolsize, @lnserialno, @lncomplen, @lnsysflags,;
  @lcsysname, lnnamesize) # 0)
  dimension taInfo[3]
  taInfo[1] = substr(lcVolName, 1, at(chr(0),lcVolName)-1) && Volume name
  taInfo[2] = substr(lcSysName, 1, at(chr(0),lcSysName)-1) && System
  taInfo[3] = dec2hex(lnSerialNo) && Serial in hex format
else
  taInfo = ""
endif    
return

function dec2hex
PARAMETER nDecimal, nDigits
**  Converts from base 10 to base 16.  Returns Hex notation in a string whose length
**  is always a multiple of 2, unless the nDigits parameter is specified to pad the
**  string with zeroes.
cHex = ""
DO WHILE nDecimal >= 16
	cHex = hexdigit(nDecimal % 16) + cHex	
	nDecimal = int(nDecimal/16)
ENDDO
cHex = hexdigit(nDecimal) + cHex	
RETURN PADL(cHex, ;
	iif( PARAMETERS() < 2, ;
		ceiling(len(cHex)/2)*2, nDigits ), "0")

function hexdigit
parameters nDecimal
return iif(ndecimal>9,chr(asc("A")+nDecimal%10),str(nDecimal,1))
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform