You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
As far as I know, disks don't have serial numbers, per-sey, but
they do have (optional) volume labels. VL's could be used as
serial numbers if needed. There are no published functions that
I know of to extract a disks VL. To get it, you have to use
DIR$ and it is always located in the root directory. Bit 3 of
the ATTR byte, if set, indicates a VL and only one is allowed.
The easiest way is to use: >>> VL$ = dir$("c:\*.*",8) <<<
There is another,indirect way, by using int21 to get a files
DTA segment and offset information. Won't publish here since
the dir$ above should do the trick.
Hope this helps
------------------
There are no atheists in a fox hole or the morning of a math test.
If my flag offends you, I'll help you pack.
Matthias--
I've dusted off the following, which does what you're looking for.
$IF 0
+--------------------------------------------------------------------------+
| WESTFORD CUSTOM PC/FX -*- DISK_ID.BAS -*- 4/11/94 |
| CIS: 76470,2417 |--------------------------------------------------------+
| 978-692-8163 |--+ rev 2/01
+--------------+
NOTE: The routines contained in this file are intended for use with
PB/DOS only.
This file contains the routine DiskID(Drive%, MIDType AS MediaIDType),
which returns the volume name (if any), serial number, and disk FAT type
(12-bit or 16-bit entries) of the specified logical drive. The DOS call
which is used (21h/6900h) is available only with DOS 4.0+, so before
calling DiskID, verify the existence of DOS 4.0+ by using the function
DOSversion% (also enclosed in this file).
$ENDIF
$OPTIMIZE SPEED
$LIB ALL OFF
'============
DEFINT A-Z
TYPE MediaIDType
InfoLevel AS INTEGER
SerialNum AS DWORD
VolLabel AS STRING * 11
FileSysType AS STRING * 8
ErrorCode AS INTEGER
END TYPE
DIM MIDType AS MediaIDType
OSver% = DOSversion%
major$ = trim$(str$(OSver% AND 255)) : minor$ = trim$(str$(OSver% \ 256))
print
print "DOS version: "; major$; "."; minor$
if (OSver% AND 255) < 4 then
print "Volume and serial number ID requires DOS 4.0+"
end
end if
drive% = 0 '0=default drive, 1=A:, 2=B:, 3=C:, etc.
call DiskID(drive%, MIDType)
if istrue(MIDType.ErrorCode) then
print "DiskID error: DOS error code"; MIDType.ErrorCode
end
end if
if isfalse(drive%) then
d$ = "default"
else
d$ = chr$(drive%+64)
end if
print "drive: "; d$
highword?? = MidType.SerialNum \ 65536
lowword?? = MidType.SerialNum AND 65535
print "serial number: "; hexword$(highword??);":"; hexword$(lowword??)
print "volume: "; MIDType.VolLabel
print MIDType.FileSysType
END
'======================
SUB DiskID(BYVAL Drive%, MIDType AS MediaIDType)
LOCAL pMIDType???, ecode%
MIDType.InfoLevel = 0 'DOS requires 0
pMIDType??? = varptr32(MidType)
! push ds
! mov bx, Drive% ;drive to check
! mov ch, &h08
! mov cl, &h66 ;get media info
! lds dx, pMIDType???
'-- ! mov ax, &h440D ;requires DOS 3.2+ but can trip critical error
! mov ax, &h6900 ;requires DOS 4.0+
! int &h21
! pop ds
! jnc DiskIDdone
! mov ecode%, ax ;if error, save error code to MIDtype
DiskIDdone:
MIDType.ErrorCode = ecode%
END SUB
'======================
FUNCTION DOSversion% PUBLIC
'-- Returns minor/major DOS version in high/low bytes of DOSversion%
'-- Tries 21h/3306h (DOS 5+) to retrieve the true DOS version;
'-- if not available, uses 21h/3001h, although this function can
'-- be fooled by SETVER
'-- NOTE: WIN NT and 2000 return DOS ver 5.5
'-- DOS 4.01 returns DOS 4.00
! mov ax, &h3306
! xor bx, bx ;zero bx before call
! int &h21
! or bx, bx ;is bx changed?
! jz Try213001 ;if no, then DOS < 5.0, so try old call
! mov ax, bx ;if call was good (DOS >= 5.0), take & go
! jmp GotVersion
Try213001:
! mov ax, &h3001
! int &h21
GotVersion:
! mov function, ax
END FUNCTION
'======================
FUNCTION HexWord$(BYVAL WordVar??)
LOCAL h$
h$ = hex$(WordVar??)
do until len(h$) = 4
h$ = "0" + h$
loop
function = h$
END FUNCTION
[This message has been edited by Greg Turgeon (edited March 11, 2001).]
Matthias--
This is interesting. I've tried the code on a straight DOS
7.1 setup, and it works properly, including with FAT32
drives. Error 26 reports an unknown media type (a non-DOS
disk). What are the details of the setup you're working
with?
[This message has been edited by Greg Turgeon (edited March 12, 2001).]
Matthias--
This one remains a mystery. I've tried the code on a Win
95a system, and it's returned the correct data from every
floppy disk I've tried reading, including 1.4M and 720K
3.5" disks, old 5.25" disks, and disks formatted under two
older versions of DOS.
However, you now say, "my system is exactly: Win95 Version
4.00.1111." This is Win 95b--the OSR2 version. That might
have some relevance, but what version of DOS is reported by
the PB code? The DOS version reported by Win 95a is 7.0,
yet you said earlier, "I use the winDos 7.10."
[This message has been edited by Greg Turgeon (edited March 12, 2001).]
A serial number is only present on a disk if the format program put one there.
Disks created before MS-DOS 4.0 or so won't have them. Disks formatted by custom
format utilities may well not have them either.
If all fails and your DOS can use Int13 or Int25, do an absolute
disk sector read of the boot sector. The serial number (formerly
known as volume label) starts at offset 40d. On my system, the
serial number is stored on disk in reverse order of what's shown
on the screen.
------------------
There are no atheists in a fox hole or the morning of a math test.
If my flag offends you, I'll help you pack.
Matthias--
"Any idea´s to do ??? with those disk´s ???"
Can you reformat them? I don't know the exact
circumstances that you're dealing with.
This is probably just a coincidence, but I've had trouble
with bad sectors on new floppy disks right out of the box
only once. Same brand: Fuji. This was quite a few years
ago.
. . .
"The serial number (formerly known as volume label)..."
Formerly? Serial numbers and volume labels have been
distinct since at least DOS 3.2. Before that?
. . .
"A serial number is only present on a disk if the format
program put one there. Disks created before MS-DOS 4.0 or
so won't have them. Disks formatted by custom format
utilities may well not have them either."
In this particular case, the PB code returns a post-4.0
version of DOS, but the second point--about custom format
utilities--offers a rich set of possibilities for
world-class screwiness.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment