Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Foxpro 2.5b for DOS
Message
From
26/11/1999 04:45:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00295572
Message ID:
00295664
Views:
13
>This maybe not the right category to post but I could not find one for Foxpro DOS.
>
>Anyone has a DOS or a Foxpro routine to read the serial number of any Hard Disk that would also work with DOS in every Windows O/S?
>
>Thanks in advance.


Doing assembly level things are easier in FP for DOS. It supports loading and executing of BIN files. If you're talking about format generated serial number than it's done using DOS function 69h subservice 0 like this :
******************
ASM ROUTINE
******************
.MODEL LARGE
.CODE
        Org 0h                ; FP needs bins absolutely execute from address 0
main:
        push bx               ; save bx
        mov ax,6900h          ; get disk serial number function
        mov dx,bx             ; our return buffer offset
        mov bx,ds:[bx]        ; drive passed as parameter
        int 21h               ; execute dos interrupt
        pop bx                ; restore bx
        retf                  ; return far to FP
        end main
******************
ASM ROUTINE
******************

* This code generates corresponding bin file - run once
handle=fcreate("serial.bin")
=fwrite(handle, ;
    chr(83)+chr(184)+chr(0)+chr(105)+;
    chr(139)+chr(211)+chr(139)+chr(31)+;
    chr(205)+chr(33)+chr(91)+chr(203),12)
=fclose(handle)
* This code generates corresponding bin file - run once


function getserialtest
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))
If you're talking about factory serial number it needs access to controller and I'm afraid the code is somewhere that I cannot find anymore.
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