FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to check if a drive exists
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
How to check if a drive exists
Posted: Tue Apr 01, 2008 03:19 PM

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
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
How to check if a drive exists
Posted: Tue Apr 01, 2008 04:02 PM

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

Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
How to check if a drive exists
Posted: Tue Apr 01, 2008 04:34 PM

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

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
How to check if a drive exists
Posted: Tue Apr 01, 2008 05:40 PM

Maurizio, with your code I get the same error msg.
Regards,
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to check if a drive exists
Posted: Tue Apr 01, 2008 06:14 PM

Otto,

> Antonio, the result is the same

Then the error may come from GetDriveType()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
How to check if a drive exists
Posted: Wed Apr 02, 2008 04:00 AM
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
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
How to check if a drive exists
Posted: Wed Apr 02, 2008 07:43 AM
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

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 :-)
kind regards

Stefan
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
How to check if a drive exists
Posted: Wed Apr 02, 2008 10:39 AM

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

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
How to check if a drive exists
Posted: Wed Apr 02, 2008 11:32 AM
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 ?



What OS do you use ?
kind regards

Stefan
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: How to check if a drive exists
Posted: Sun May 02, 2010 01:23 PM

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
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: How to check if a drive exists
Posted: Sun May 02, 2010 02:34 PM

Hello, if I remember well I have reinstalled the card reader.
Best regards,
Otto

Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: How to check if a drive exists
Posted: Sun May 02, 2010 02:39 PM
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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to check if a drive exists
Posted: Sun May 02, 2010 03:30 PM
Try

Code (fw): Select all Collapse
SETERRORMODE( 1 )


EMG
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: How to check if a drive exists
Posted: Sun May 02, 2010 10:29 PM

Hi Entico,

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

Thanks :D

Saludos,



Eduardo
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to check if a drive exists
Posted: Sun May 02, 2010 11:19 PM

It is called WAPI_SETERRORMODE() in Harbour.

EMG