1. determine volume serial number
- Posted by Michael J Doscher <mdoscher at JUNO.COM> Dec 31, 1997
- 719 views
I am using Euphoria v1.5 and would like help in writing code to determine the volume serial number of c:\
2. Re: determine volume serial number
- Posted by Craig Gilbert <cgilbert at CENNET.MC.PEACHNET.EDU> Jan 02, 1998
- 671 views
At 11:37 AM 12/31/97 EST, Michael J Doscher wrote: >I am using Euphoria v1.5 and would like help in writing code to >determine the volume serial number of c:\ Has anyone given you info on that yet, Michael? I would like to know how to do that myself; I have some code for getting and setting the volume _label_ on a drive, but nothing for the volume serial number. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- J. Craig Gilbert cgilbert at mc.peachnet.edu "Positing infinity, the rest is easy." Roger Zelazny, in 'Creatures of Light and Darkness' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
3. Re: determine volume serial number
- Posted by David Cuny <dcuny at DSS.CA.GOV> Jan 02, 1998
- 746 views
I've run across the information requested in BASIC, but am too stupid to make th e translation: --- START OF FILE ------------------------ ' DISKID.BAS reports disk volume and serial number from boot sector ' ' Author: Christy Gemmell (christy.gemmell at almac.co.uk) ' Date: 12/4/1992 ' ' Captured from alt.lang.basic newsgroup on July 20, 1995 and converted ' to PowerBASIC by Dave Navarro, Jr. (dave at powerbasic.com) TYPE ParaBlock Info AS INTEGER ' Call information level SerNo AS LONG ' Disk serial number Label AS STRING * 11 ' Volume label FlSys AS STRING * 8 ' File system type END TYPE INPUT "Which drive - <Enter> for default"; D$ GetDiskID D$, S$, V$, F$ PRINT PRINT "Disk information for drive "; D$ PRINT "----------------------------" PRINT "Volume label : "; V$ PRINT "Serial number : "; S$ PRINT "File system : "; F$ END SUB GetDiskID (Drive$, Serial$, Volume$, FileSys$) DIM Para AS ParaBlock ' Buffer for drive parameter block Para.Info = 0 ' Information level always zero REG 1, &H440D ' Generic IOCTL device request IF Drive$ = "" THEN ' If no drive specified REG 2, 0 ' then use default ELSE ' Otherwise convert REG 2, ASC(UCASE$(Drive$)) - 64 ' drive letter to number END IF ' A: = 1, B: = 2 etc REG 3, &H866 ' Subfunction: get drive ID REG 8, VARSEG(Para) ' Segment of buffer REG 4, VARPTR(para) ' Offset of buffer CALL INTERRUPT &H21 ' Invoke DOS Serial$ = HEX$(Para.SerNo) ' Get serial number Volume$ = Para.Label ' Get volume label FileSy$ = Para.FlSys ' Get file system type END SUB --- END OF FILE ------------------------ Here's a version that does a DIR command. Note that it only has minimal error ch ecking: --- START OF FILE ------------------------ include file.e function read_serial( sequence from ) -- read the serial number from a given disk integer handle sequence text -- do a DIR command and dump it to a file system( "dir " & from & " > junk.tmp", 2 ) -- open the file handle = open( "junk.tmp", "r" ) -- success? if sequence( dir("junk.tmp") ) then -- skip the blank line text = gets( handle ) -- skip the volume name text = gets( handle ) -- read volume serial number text = gets( handle ) -- slice off the preceeding text text = text[26..length(text)] -- close the file close( handle ) -- delete the temp file system( "del junk.tmp > NUL", 2 ) end if return text end function -- try it out puts( 1, read_serial( "c:" ) ) --- END OF FILE ------------------------ -- David Cuny
4. Re: determine volume serial number
- Posted by Craig Gilbert <cgilbert at CENNET.MC.PEACHNET.EDU> Jan 02, 1998
- 688 views
Here is a translation of the Power Basic file David Cuny contributed. It seems to work okay on my computer. ------------------cut here---------- include machine.e include wildcard.e ------------------------------------------------------------------------------ global function GetDiskID(sequence Drive) -- return volume label, serial number, and filesystem in sequence -- translated from PowerBasic code supplied by David Cuny atom ParaBlock, serNo sequence reg, Serial, Volume, FileSy object retVal -- here's the parameter block layout; -- note that you can't really index ParaBlock this way . . . -- TYPE ParaBlock -- Info AS INTEGER ParaBlock[1..2] -- SerNo AS LONG ParaBlock[3..6] -- Label AS STRING * 11 ParaBlock[7..17] -- FileSys AS STRING * 8 ParaBlock[18..25] -- END TYPE ParaBlock = allocate_low(25) -- Buffer for drive parameter block lock_memory(ParaBlock,25) -- can't remember if this is necessary -- with low memory but it doesn't seem -- to hurt poke(ParaBlock,repeat(0,25)) -- Information level always zero, -- plus clear rest of block reg = repeat(0,10) reg[REG_AX] = #440D -- Generic IOCTL device request if length(Drive) != 1 then -- If no drive specified reg[REG_BX] = 0 -- then use default else -- Otherwise convert reg[REG_BX] = upper(Drive[1]) - '@'-- drive letter to number end if -- A: = 1, B: = 2 etc reg[REG_CX] = #866 -- Subfunction: get drive ID reg[REG_DS] = floor(ParaBlock/16) -- Segment of buffer reg[REG_DX] = remainder(ParaBlock,16) -- Offset of buffer reg = dos_interrupt(#21,reg) -- Invoke DOS if and_bits(1, reg[REG_FLAGS]) != 1 then -- everything OK serNo = bytes_to_int(peek({ParaBlock+2,4})) Serial = sprintf("%x",{serNo}) -- Get serial number Volume = peek({ParaBlock+6,11}) -- Get volume label FileSy = peek({ParaBlock+17,8}) -- Get file system type retVal = {Serial, Volume, FileSy} else retVal = reg[REG_AX] -- DOS error code end if free_low(ParaBlock) return retVal end function ------------------------------------------------------------------------------ procedure test() object ret ret = GetDiskID("c") if atom(ret) then printf(1,"Sorry, an error occurred:Dos Error Code = %d\n",{ret}) abort(1) else puts(1,"Disk information for drive C\n") puts(1,"----------------------------\n") printf(1,"Volume label : %s\n",{ret[2]}) printf(1,"Serial number : %s\n",{ret[1]}) printf(1,"File system : %s\n",{ret[3]}) end if end procedure ------------------------################## test() =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- J. Craig Gilbert cgilbert at mc.peachnet.edu "Positing infinity, the rest is easy." Roger Zelazny, in 'Creatures of Light and Darkness' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-