Announcement

Collapse
No announcement yet.

Drive C Serial Number

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Matthew Berg
    replied
    Here is code for an application that will display this information:
    Code:
    %AX = 1
    %BX = 2
    %CX = 3
    %DX = 4
    %SI = 5
    %DI = 6
    %BP = 7
    %DS = 8
    %ES = 9
    %FLAGS = 0
    %CF = 0
    %FALSE = 0
    %TRUE = NOT %FALSE
     
    TYPE structDiscInfo
       InfoLevel           AS WORD
       DiscSerialNumber    AS DWORD
       VolumeLabel         AS STRING * 11
       FileSystem          AS STRING * 8
    END TYPE
     
    DECLARE FUNCTION GetDiscSerialNumber( BYVAL sDrive AS STRING, nSerialNumber AS DWORD, sVolumeLabel AS STRING, sFileSystem AS STRING ) AS INTEGER
     
    StartHere:
    DIM nSerial AS DWORD
    DIM sDrive AS STRING
    DIM sLabel AS STRING
    DIM sFileSys AS STRING
    DIM sSerial AS STRING
     
    LET sDrive = UCASE$( TRIM$( COMMAND$ ) )
    IF GetDiscSerialNumber( sDrive, nSerial, sLabel, sFileSys ) THEN
       LET sSerial = RIGHT$( STRING$( 7, "0" ) + HEX$( nSerial ), 8 )
       STDOUT " Volume in drive " + sDrive + " is " + sLabel
       STDOUT " Serial number is " + LEFT$( sSerial, 4 ) + ":" + RIGHT$( sSerial, 4 )
       STDOUT " File system is " + sFileSys
    END IF
     
    END 0
     
    FUNCTION GetDiscSerialNumber( BYVAL sDrive AS STRING, nSerialNumber AS DWORD, sVolumeLabel AS STRING, sFileSystem AS STRING ) PRIVATE AS INTEGER
       DIM bRet AS INTEGER
       DIM nFlags AS WORD
       DIM oDiscInfo AS structDiscInfo
     
       LET bRet = %TRUE
     
       LET sDrive = TRIM$( UCASE$( sDrive ) )
       IF LEFT$( sDrive, 1 ) < "A" OR LEFT$( sDrive, 1 ) > "Z" THEN LET bRet = %FALSE
     
       IF ISTRUE bRet THEN
          REG %AX, &H6900
          REG %BX, ASC( sDrive ) - 64
          REG %DS, VARSEG( oDiscInfo )
          REG %DX, VARPTR( oDiscInfo )
          CALL INTERRUPT &H21
     
          LET nFlags = REG( %FLAGS )
          IF ISFALSE BIT( nFlags, %CF ) THEN
             LET nSerialNumber = oDiscInfo.DiscSerialNumber
             LET sVolumeLabel = oDiscInfo.VolumeLabel
             LET sFileSystem = oDiscInfo.FileSystem
          END IF
       END IF
     
       FUNCTION = bRet
    END FUNCTION
    N.B. The method used by this application to determine the file system type is not official, nor recommended. Also, it will only work on local drives.

    [This message has been edited by Matthew Berg (edited November 06, 2000).]

    Leave a comment:


  • Noble Bell
    started a topic Drive C Serial Number

    Drive C Serial Number

    Does anyone have any PB35 source code that will allow you to get
    the serial number of drive "C"?


    ------------------
    Noble D. Bell - Owner
    Noble Software Publishing
    http://www.noblesoftware.com
Working...
X