How to check if a drive exists

Postby nageswaragunupudi » Tue Apr 01, 2008 3: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
User avatar
nageswaragunupudi
 
Posts: 10259
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Otto » Tue Apr 01, 2008 4: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
User avatar
Otto
 
Posts: 6033
Joined: Fri Oct 07, 2005 7:07 pm

Postby Maurizio » Tue Apr 01, 2008 4: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
User avatar
Maurizio
 
Posts: 797
Joined: Mon Oct 10, 2005 1:29 pm

Postby Otto » Tue Apr 01, 2008 5:40 pm

Maurizio, with your code I get the same error msg.
Regards,
Otto
User avatar
Otto
 
Posts: 6033
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Tue Apr 01, 2008 6:14 pm

Otto,

> Antonio, the result is the same

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41335
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Wed Apr 02, 2008 4: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
User avatar
nageswaragunupudi
 
Posts: 10259
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby StefanHaupt » Wed Apr 02, 2008 7: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

Code: Select all  Expand view
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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby Otto » 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
User avatar
Otto
 
Posts: 6033
Joined: Fri Oct 07, 2005 7:07 pm

Postby StefanHaupt » 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 ?

Image

What OS do you use ?
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: How to check if a drive exists

Postby mgsoft » Sun May 02, 2010 1: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
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: How to check if a drive exists

Postby Otto » Sun May 02, 2010 2:34 pm

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
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6033
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to check if a drive exists

Postby mgsoft » Sun May 02, 2010 2: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
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España


Re: How to check if a drive exists

Postby mgsoft » Sun May 02, 2010 10:29 pm

Hi Entico,


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

Thanks :D
Saludos,

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

Re: How to check if a drive exists

Postby Enrico Maria Giordano » Sun May 02, 2010 11:19 pm

It is called WAPI_SETERRORMODE() in Harbour.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8338
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 11 guests