June 16, 2024, 03:38:08 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


IsReady

Started by ckoehn, March 21, 2010, 05:40:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ckoehn

How would this be translated into EBASIC?

Function ShowDriveInfo(drvpath)
   Dim fso, d, s, t
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set d = fso.GetDrive(drvpath)
   Select Case d.DriveType
      Case 0: t = "Unknown"
      Case 1: t = "Removable"
      Case 2: t = "Fixed"
      Case 3: t = "Network"
      Case 4: t = "CD-ROM"
      Case 5: t = "RAM Disk"
   End Select
   s = "Drive " & d.DriveLetter & ": - " & t
   If d.IsReady Then
      s = s & "<BR>" & "Drive is Ready."
   Else
      s = s & "<BR>" & "Drive is not Ready."
   End If
   ShowDriveInfo = s
End Function

Copex

March 22, 2010, 04:20:06 AM #1 Last Edit: March 22, 2010, 04:22:21 AM by Copex
dot net is not supported you would have to use the windows API

a quick search of the forms turned up this http://www.ionicwind.com/forums/index.php/topic,3880.msg30598.html#msg30598
-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/

ckoehn

Copex,

Thanks for your response, but that was the problem I had.  That code will not let me know if a disk is inserted in a removable drive like a CDROM or DVD.  I am searching for a particular file on a removable disk, if it doesn't find it, it waits for a few seconds and searches again.  My problem is an error is generated when there is no disk in the drive.  EBASIC doesn't have error trapping and there doesn't appear any way to see if there is a disk in a drive.  It is VERY unprofessional to have an error message pop up every time it runs through its routine searching for a file.

Isn't there anyway to find if a disk is installed with API calls?  IsReady seemed like a good idea.  :)

LarryMc

search the windows sdk for  IOCTL_STORAGE_CHECK_VERIFY DeviceIoControl
that should provide some help.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

REDEBOLT

I searched the api for "ready" and found this:
DlgDirSelectComboBoxEx

I searched the api for "cd" and got about 67 hits.
There may be something in there you can use.
Regards,
Bob

sapero

QuoteMy problem is an error is generated when there is no disk in the drive
$include "windowssdk.inc"
SetErrorMode(SEM_NOOPENFILEERRORBOX)

ckoehn

I want to thank all of you for your help.  I still am getting that annoying error "There is no disk in the drive.  Please insert a disk in Drive D:".

sapero:  I entered what you sent which looked like it should work, but I'm still getting that error.  Looking up the command says that the "process will handle the error".  Is there something I need to do in my window handled to deal with that error?

sapero

No, the function you use for accessing the removable device will just fail, without unwanted system alerts. I have picked the SEM_NOOPENFILEERRORBOX flag without checking it, but I see now that in my ISO maker, I have used another flag: SEM_FAILCRITICALERRORS.
I can't even reproduce this error now, using openfile/loadlibrary/findopen.
...
Ah, I need to mount an .iso, open a file, unmount it, then reading the opened file will pop an error box.
The SEM_FAILCRITICALERRORS flag seems to help, no error box is shown:
$include "windowssdk.inc"

SetErrorMode(SEM_FAILCRITICALERRORS) /* try with and without this line*/

MessageBox 0, "mount iso, or insert a cdrom", ""
bfile f
int buffer

if (!openfile(f, "\\\\.\\F:", "r")) /* or any existing file, fike F:\\autorun.inf */
MessageBox 0, "unmount iso, or eject the cdrom", ""
read f, buffer
closefile f
else
MessageBox 0, "drive not found", ""
endif

ckoehn

Thanks as always sapero, that did the trick.

Later,
Clint