How to check if a drive exists

User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

In xHarbour, these two function bypass the OS messages. I have not tested on Vista

1) DiskReady( cDisk, .F. )
2)
SetErrorMode(1)
IsDisk( cDisk )


I do not know if Harbour has similar functions
Regards

G. N. Rao.
Hyderabad, India
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Hello NagesWaraRao,

thank you.
Yes, Set ErrorMode(1) with xHarbor is working.

local cDisk := "m"

// msginfo(DiskReady( cDisk, .F. ) )
Unresolved external '_HB_FUN_DISKREADY' referenced from


SetErrorMode(1)
msginfo(IsDisk( cDisk ) )

Regards,
Otto
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Post by Maurizio »

Hello Otto

Why you don't use

nFile := fCreate( cDrive + 'TEST.TXT',0)
if nFile == -1
lReturn := FALSE
MsgInfo("Driver not present " )
else
fClose(nFile)
endif

Maurizio
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Maurizio, with your code I get the same error msg.
Regards,
Otto
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Otto,

> Antonio, the result is the same

Then the error may come from GetDriveType()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

Otto wrote:Hello NagesWaraRao,

thank you.
Yes, Set ErrorMode(1) with xHarbor is working.

local cDisk := "m"

// msginfo(DiskReady( cDisk, .F. ) )
Unresolved external '_HB_FUN_DISKREADY' referenced from


SetErrorMode(1)
msginfo(IsDisk( cDisk ) )

Regards,
Otto
All the functions I gave are working here with xHarbour.

With Harbour IsDisk( "A" ) is returning .t. or .f. without giving any OS message on XP. I do not know if this works with Vista too with Harbour.
Regards

G. N. Rao.
Hyderabad, India
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post by StefanHaupt »

Otto,

why don´t you use the function aDrives(), that comes with Fwh ? It collects all mounted drives. See sample testdrvs.prg in the sample dir.

You can easily check if a drive is available

Code: Select all

FUNCTION IsDrive (cDrive) // cDrive -> a:, c:, ....

LOCAL aDrv := aDrives()

RETURN (AScan (aDrv, cDrive)!=0)
It´s working in XP and Vista without any exception dialog :D
kind regards
Stefan
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Hello Stefan, hello NagesWaraRao,

The aDrives-function executes the same exception dialog.

At the moment only xHarbour with ErrorMode(1) as NagesWaraRao suggested is working.

DiskReady( cDisk, .F. ) here gives a:
Unresolved external '_HB_FUN_DISKREADY' referenced from

But I don't use xHarbour in my project.

Regards,
Otto
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post by StefanHaupt »

Otto wrote: The aDrives-function executes the same exception dialog.
I can´t undestand this, here it´s working fine (with harbour and xHarbour), did you try the sample testdrvs.prg ?

Image

What OS do you use ?
kind regards
Stefan
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: How to check if a drive exists

Post by mgsoft »

Otto,

I have the same problem as you with Card readers.

How did you solve it?.


As this error, I have problems with protect.prg


thanks :D
Saludos,

Eduardo
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: How to check if a drive exists

Post by Otto »

Hello, if I remember well I have reinstalled the card reader.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: How to check if a drive exists

Post by mgsoft »

Hi,

Thanks for the reply.

It is not a question of drivers.

When a card reader is installed, it creates an USB letter drive for each slot. When there is NO card inserted, you can see the unit in My PC. If you click on it, the OS gives an error that there is not disk inserted in.

If you use GetDiskFreeSpaceEx of If file refering to the that Unit, the OS gives an error that there is not disk inserted in.

http://img40.imageshack.us/i/errorusb.png/


How did you solve that?.

thanks
Saludos,

Eduardo
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: How to check if a drive exists

Post by mgsoft »

Hi Entico,


Seterrormode and DiskReady() are only in xHarbour, but I use Harbour.

Thanks :D
Saludos,

Eduardo
Post Reply