Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get Disk Serial Number in fpw26
Message
From
27/11/2001 13:29:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00586409
Message ID:
00586478
Views:
18
Jorge,
If your concern is to get format serial number fox2x could load and call a binary file.ie:
lcBytes = '83,184,0,105,139,211,142,31,205,33,91,203'
lcStr = 'chr('+strtran(lcBytes,',',')+chr(')+')'
handle=fcreate('serial.bin')
=fwrite(handle,&lcStr, 12)
=fclose(handle)
Would create a binary file that reads serial number of passed drive letter (fox call ready). Sample prg using it :
function ShowSerial
parameters driveletter
set talk off
clear
mp = chr(asc(upper(driveletter))-ASC("A")+1)+chr(0)+;
	space(22) && 24 bytes total
load serial
call serial with mp    && execute asm
? substr(mp,2+1) && First two bytes are always chr(0)
cSerial1 = substr(mp,1+2,1)
cSerial2 = substr(mp,2+2,1)
cSerial3 = substr(mp,3+2,1)
cSerial4 = substr(mp,4+2,1)

? asc(cSerial4)  && Disk serial number
? asc(cSerial3)  && is a doubleword
? asc(cSerial2)  && So read in reverse order
? asc(cSerial1)  && as shown in dir
* Now print in hex format just like dir
? "Disk serial number is "
?? padl(dec2hex(asc(cSerial4)),2,"0")
?? padl(dec2hex(asc(cSerial3)),2,"0")
?? ":"
?? padl(dec2hex(asc(cSerial2)),2,"0")
?? padl(dec2hex(asc(cSerial1)),2,"0")
?

function Dec2Hex
parameters nDecimal
n=0
do while floor(nDecimal/16^n) > 15
 n = n+1
enddo
cHEX = ""
for ix=n to 0 step -1
	cHEX = cHex + DecDigit2HexDigit(floor(nDecimal/16^ix))
	nDecimal = nDecimal % 16
endfor
return cHex

function DecDigit2HexDigit
parameters nDecimal
return iif(ndecimal>9,chr(asc("A")+nDecimal%10),str(nDecimal,1))
Cetin


>Hi
>i'm trying to get Disk Serial No in FPW26 usin WIndows API GetVolumenInformation
>and using West Wind Tech declare32 approach. BUt not succeed.
>
>Can someone help me with this code
>***rutina para averiguar serie de disco duro
>SET CONFIRM OFF
>SET BELL ON
>SET ECHO OFF
>SET DELE ON
>SET TALK OFF
>SET SAFETY OFF
>SET HEADING OFF
>SET DELIMITER OFF
>SET DEVICE TO SCREEN
>SET ESCAPE Off
>SET CENTURY ON
>SET DATE TO BRITISH
>SET INTENSITY ON
>SET BLINK ON
>SET SYSMENU to
>SET STATUS BAR OFF
>*
>*pantalla principal
>*_screen.windowstate=2
>*_screen.closable=.t.
>*_screen.caption="GetVolInfo"
>
>*local inret, icstring, lpvolname,nvolsize,lpvolnumber,;
>*lpmaxcomp, lpflags,lpfsname,nfssize,lproot
>
>*if empty(lproot)
> lproot="c:\"
>*endif
>lpvolname=space(256)
>nvolsize=256
>lpvolnumber=0
>lpmaxcomp=256
>lpflags=0
>lpfsname=space(256)
>nfssize=256
>set library to "c:\WINDOWS\foxtools" additive
> uno = regfn("Declare32","CCC","L","CALL32.DLL")
>? UNO
>WAIT "PAUSA 1"
> dos=callfn(uno,"GetVolumeInformation","winapi32.dll","ppiiiipi")
>? DOS
>WAIT "PAUSA 2"
>tres=regfn("Call32","@C@CI@I@I@I@I@CL","L","CALL32.DLL")
>? TRES
>WAIT "PAUSA 3"
>CUAT = callfn(tres,@lproot,@lpvolname,nvolsize,@lpvolnumber,@lpmaxcomp,@lpflags,@lpfsname,@nfssize,dos)
>
>*declare integer GetVolumeInformation in win32api as getvolinfo;
>*string @lproot,;
>*string @lpvolname,;
>*integer nvolsize,;
>*integer @lpvolnumber,;
>*integer @lpmaxcomp,;
>*integer @lpflags,;
>*string @lpfsname,;
>*integer nfssize
>
>*inret=getvolinfo(@lproot,@lpvolname,nvolsize,@lpvolnumber,@lpmaxcomp,@lpflags,@lpfsname,nfssize)
>
>if CUAT>0
>lcstring="drive name:"+alltrim(lproot)+chr(13)+;
>"vol name:"+left(alltrim(lpvolname),len(alltrim(lpvolname))-1)+chr(13)+;
>"max#/chars in vol name:"+alltrim(str(nvolsize))+chr(13)+;
>"vol serial#:"+alltrim(str(lpvolnumber))+chr(13)+;
>"max #/chars in dir/file names:"+alltrim(str(lpmaxcomp))+chr(13)+;
>"file sys flags:"+alltrim(str(lpflags))+chr(13)+;
>"file sys type:"+ left(alltrim(lpfsname),len(alltrim(lpfsname))-1)+chr(13)+;
>"file size name:"+alltrim(str(nfssize))
>else
>lcstring="no sepudo ver informacion"
>endif
>*=messagebox(lcstring,"Informacion del volumen")
>? "drive name:"+alltrim(lproot)
>? "vol name:"+left(alltrim(lpvolname),len(alltrim(lpvolname))-1)
>? "max#/chars in vol name:"+alltrim(str(nvolsize))
>? "vol serial#:"+alltrim(str(lpvolnumber))
>? "max #/chars in dir/file names:"+alltrim(str(lpmaxcomp))
>? "file sys flags:"+alltrim(str(lpflags))
>? "file sys type:"+ left(alltrim(lpfsname),len(alltrim(lpfsname))-1)
>? "file size name:"+alltrim(str(nfssize))
>wait window "pausa"
>
>return
>Thank in advance
>Jorge Matheus
Ç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
Next
Reply
Map
View

Click here to load this message in the networking platform