How to check if a drive exists
How to check if a drive exists
How to check if a drive exists.
Thanks in advance
Otto
Thanks in advance
Otto
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Otto,
Please modify James function this way to check where the GPF is coming from:
Please modify James function this way to check where the GPF is coming from:
Code: Select all
FUNCTION ISREADY( cDrive )
local cCurPath, lReady, lSuccess := .F.
MsgInfo( CurDrive(), "CurDrive()" )
MsgInfo( CurDir(), "CurDir()" )
cCurpath = CURDRIVE() + ":\" + CURDIR()
MsgInfo( lReady := lChDir( cDrive + "." ), "lChDir()" )
if lReady
MsgInfo( lSuccess := LCHDIR( cCurPath ), "LCHDIR( cCurPath )" )
endif
return lSuccess
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Antonio,
Here is a VB example that checks to see if the drive exists and if it is ready. Maybe this will help.
http://www.freevbcode.com/ShowCode.Asp?ID=70
James
Here is a VB example that checks to see if the drive exists and if it is ready. Maybe this will help.
http://www.freevbcode.com/ShowCode.Asp?ID=70
James
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
James,
Thanks! Here it is adapted to FWH:
Thanks! Here it is adapted to FWH:
Code: Select all
#include "FiveWin.ch"
function Main()
if GetDriveType( "C:\" ) != 1 // the drive exists
if GetDiskFreeSpace( "C:\" ) // the drive is ready
MsgInfo( "the drive is ready" )
endif
else
MsgAlert( "drive not exist" )
endif
return nil
//------------------------------------------------
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
HB_FUNC( GETDISKFREESPACE ) // cRootPathName, @nSectorsByCluster, @nBytesPerSector,
// @nNumberOfFreeClusters, @nTotalNumberOfClusters --> lResult
{
LPSTR lpRootPathName = hb_parc( 1 );
DWORD SectorsPerCluster;
DWORD BytesPerSector;
DWORD NumberOfFreeClusters;
DWORD TotalNumberOfClusters;
hb_retl( GetDiskFreeSpace( lpRootPathName, &SectorsPerCluster,
&BytesPerSector, &NumberOfFreeClusters,
&TotalNumberOfClusters ) );
hb_stornl( SectorsPerCluster, 2 );
hb_stornl( BytesPerSector, 3 );
hb_stornl( NumberOfFreeClusters, 4 );
hb_stornl( TotalNumberOfClusters, 5 );
}
#pragma ENDDUMP
Hello Antonio,
J:\ in my case is a cardreader. The test for other letters which do not
exist is working.
i found this msg on the internet:
>Here's a tip to save you hunting for the solution to fix this "Windows no disk" problem in Windows XP (UPDATE: a commenter says changing the drive letters works in Vista too), at least if it's to do with your card reader, or CD or DVD drive.
more
http://www.consumingexperience.com/2007 ... ssing.html
J:\ in my case is a cardreader. The test for other letters which do not
exist is working.
i found this msg on the internet:
>Here's a tip to save you hunting for the solution to fix this "Windows no disk" problem in Windows XP (UPDATE: a commenter says changing the drive letters works in Vista too), at least if it's to do with your card reader, or CD or DVD drive.
more
http://www.consumingexperience.com/2007 ... ssing.html
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Otto,
Please try it this way:
Please try it this way:
Code: Select all
#include "FiveWin.ch"
function Main()
if GetDriveType( "C:\" ) != 1 // the drive exists
if GetDiskFreeSpace( "C:\" ) // the drive is ready
MsgInfo( "the drive is ready" )
endif
else
MsgAlert( "drive not exist" )
endif
return nil
//------------------------------------------------
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
HB_FUNC( GETDISKFREESPACE ) // cRootPathName, @nSectorsByCluster, @nBytesPerSector,
// @nNumberOfFreeClusters, @nTotalNumberOfClusters --> lResult
{
LPSTR lpRootPathName = hb_parc( 1 );
DWORD SectorsPerCluster;
DWORD BytesPerSector;
DWORD NumberOfFreeClusters;
DWORD TotalNumberOfClusters;
__try
{
hb_retl( GetDiskFreeSpace( lpRootPathName, &SectorsPerCluster,
&BytesPerSector, &NumberOfFreeClusters,
&TotalNumberOfClusters ) );
}
__except ( ( hb_retl( FALSE ), TRUE ) )
{}
hb_stornl( SectorsPerCluster, 2 );
hb_stornl( BytesPerSector, 3 );
hb_stornl( NumberOfFreeClusters, 4 );
hb_stornl( TotalNumberOfClusters, 5 );
}
#pragma ENDDUMP