Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Dirve

ConstantinConstantin Posts: 10Member
I need a routine to find out how many drives has a pc and which is the drive letter.

Thank you

Comments

  • zibadianzibadian Posts: 6,349Member
    : I need a routine to find out how many drives has a pc and which is the drive letter.
    :
    : Thank you
    :
    :
    Here is a function, which checks if a drive exists, taken from one of the TP units itself. You can use this function to create a string of valid drive letters. I cannot give you any help on this function itself, bacause I know very little assembly.
    [code]
    function DriveValid(Drive: Char): Boolean; near; assembler;
    asm
    MOV AH,19H { Save the current drive in BL }
    INT 21H
    MOV BL,AL
    MOV DL,Drive { Select the given drive }
    SUB DL,'A'
    MOV AH,0EH
    INT 21H
    MOV AH,19H { Retrieve what DOS thinks is current }
    INT 21H
    MOV CX,0 { Assume false }
    CMP AL,DL { Is the current drive the given drive? }
    JNE @@1
    MOV CX,1 { It is, so the drive is valid }
    MOV DL,BL { Restore the old drive }
    MOV AH,0EH
    INT 21H
    @@1: XCHG AX,CX { Put the return value into AX }
    end;
    [/code]
  • Phat NatPhat Nat Posts: 757Member
    : I need a routine to find out how many drives has a pc and which is the drive letter.
    :
    : Thank you


    I've used this one. Not only does it tell you if the drive exists (Size > 0) but it tells you the drive size (up to 2.1 Gigs). Doesn't include CD-ROM drives (I don't know about burners).

    Phat Nat

    [code]
    {
    BO BENDTSEN

    Many people don't think about it, but DOS is limited to report more than
    1 gigabyte. I have a 1.3 and a 1.0 gig, and made these routines for my
    programs for knowing if the drive size is more than 1 gig. Using the normal
    DiskSize and DiskFree could get you strange result, sometimes it could report
    maybe 100MB when it is really 1 gig.

    If the size of free space is 1 you can assume that the drive is more than 1
    gigabyte.
    }
    USES Dos;

    VAR
    X : Byte;

    Function DriveSize(d : byte) : Longint; { -1 not found, 1=>1 Giga }
    Var
    R : Registers;
    Begin
    With R Do
    Begin
    ah := $36;
    dl := d;
    Intr($21, R);
    If AX = $FFFF Then
    DriveSize := -1 { Drive not found }
    Else
    If (DX = $FFFF) or
    (Longint(ax) * cx * dx = 1073725440) Then
    DriveSize := 1
    Else
    DriveSize := Longint(ax) * cx * dx;
    End;
    End;

    Function DriveFree(d : byte) : Longint; { -1 not found, 1=>1 Giga }
    Var
    R : Registers;
    Begin
    With R Do
    Begin
    ah := $36;
    dl := d;
    Intr($21, R);
    If AX = $FFFF Then
    DriveFree := -1 { Drive not found }
    Else
    If (BX = $FFFF) or (Longint(ax) * bx * cx = 1073725440) Then
    DriveFree := 1
    Else
    DriveFree := Longint(ax) * bx * cx;
    End;
    End;

    Begin
    For X := 3 to 26 Do
    If DriveSize(X) > 0 Then
    Begin
    WriteLn('Drive ',Chr(X+64),':');
    WriteLn(' ',DriveSize(X),' bytes');
    WriteLn(' ',DriveFree(X),' bytes');
    End;
    End.
    [/code]
  • ConstantinConstantin Posts: 10Member
    : : I need a routine to find out how many drives has a pc and which is the drive letter.
    : :
    : : Thank you
    :
    :
    : I've used this one. Not only does it tell you if the drive exists (Size > 0) but it tells you the drive size (up to 2.1 Gigs). Doesn't include CD-ROM drives (I don't know about burners).
    :
    : Phat Nat
    :
    : [code]
    : {
    : BO BENDTSEN
    :
    : Many people don't think about it, but DOS is limited to report more than
    : 1 gigabyte. I have a 1.3 and a 1.0 gig, and made these routines for my
    : programs for knowing if the drive size is more than 1 gig. Using the normal
    : DiskSize and DiskFree could get you strange result, sometimes it could report
    : maybe 100MB when it is really 1 gig.
    :
    : If the size of free space is 1 you can assume that the drive is more than 1
    : gigabyte.
    : }
    : USES Dos;
    :
    : VAR
    : X : Byte;
    :
    : Function DriveSize(d : byte) : Longint; { -1 not found, 1=>1 Giga }
    : Var
    : R : Registers;
    : Begin
    : With R Do
    : Begin
    : ah := $36;
    : dl := d;
    : Intr($21, R);
    : If AX = $FFFF Then
    : DriveSize := -1 { Drive not found }
    : Else
    : If (DX = $FFFF) or
    : (Longint(ax) * cx * dx = 1073725440) Then
    : DriveSize := 1
    : Else
    : DriveSize := Longint(ax) * cx * dx;
    : End;
    : End;
    :
    : Function DriveFree(d : byte) : Longint; { -1 not found, 1=>1 Giga }
    : Var
    : R : Registers;
    : Begin
    : With R Do
    : Begin
    : ah := $36;
    : dl := d;
    : Intr($21, R);
    : If AX = $FFFF Then
    : DriveFree := -1 { Drive not found }
    : Else
    : If (BX = $FFFF) or (Longint(ax) * bx * cx = 1073725440) Then
    : DriveFree := 1
    : Else
    : DriveFree := Longint(ax) * bx * cx;
    : End;
    : End;
    :
    : Begin
    : For X := 3 to 26 Do
    : If DriveSize(X) > 0 Then
    : Begin
    : WriteLn('Drive ',Chr(X+64),':');
    : WriteLn(' ',DriveSize(X),' bytes');
    : WriteLn(' ',DriveFree(X),' bytes');
    : End;
    : End.
    : [/code]
    :


    Thank you, but i need a function that checks if the drive exist.
    That means, that i want to know: Has the PC a disketten Drive or cdrom drive or a harddisk.
    And than i need the first driveletter.

    Ciao


Sign In or Register to comment.