Detection of the CD in the drive 
Author Message
 Detection of the CD in the drive

Hi all!

How to detect if CD is in the drive? I want to force users to put the
CD in the drive in order to use the Clarion application which is
previously installed from the CD.

Any info is welcome.

Thanks

Miroslav



Mon, 11 Oct 2004 16:18:23 GMT  
 Detection of the CD in the drive
Hi Miroslav

Ideally, if you put a unique named file or directory on your CD, you can use
the following code:-

Firstly add the following api declaration to your global embed "Inside the
Global Map"

MODULE('Windows.DLL')
        GetDriveType(*CString),UNSIGNED,Pascal,RAW,NAME('GetDriveTypeA')
END

Add a global variable:-

GLO:CDDrive         CString(3)

This is then a procedure with a prototype of:-

(),Byte

Local Variables:-

DriveName            CString(3)
SavePath               CString(255)
Drives                    CString(25)
RetVal                   Byte

Then your code should read:-

  drives = 'CDEFGHIJKLMNOPQRSTUVWXYZ'
  GLO:CDDrive = ''
  Loop
    do CheckAllDrives        !Do an inital check
    if GLO:CDDrive = '' then
      Case Message('Please place your iMove CD in a CD Drive','iMove
CD',ICON:Asterisk,button:OK+Button:Cancel,Button:Ok,1)
      of Button:Cancel
        RetVal = false
        Break
      else
        Loop 3 times
          do CheckAllDrives
          if GLO:CDDrive = '' then
            Break
          end
        End
      end
    else
      RetVal = true
      Break
    end
  end

  Return(RetVal)

CheckAllDrives          Routine
    Loop x# = 1 to 24
      DriveName = Sub(drives,x#,1) & ':'
      if GetDriveType(DriveName) = 5 then   !Check that this is a CD drive
        SavePath = Path()                   !Save the current path name
        setpath(DriveName & '\Solace')    !Checks for a directory called
Solace
        if ~error() then
          SetPath(SavePath)                 !Restore to the current path
          GLO:CDDrive = DriveName
          break
        end
      end
    end

Hope this helps
Cheers
Simon Burrows
VariView templates. - Display your variables and fields as you run your
application
WordSpell templates. - Seamlessly use MS Word's Spell checker in your apps.
Screen Redesigner templates - Let your customers change your screen layouts
and control properties to suit their needs at runtime.
List & Label Templates - Unlimited report layouts, defined by your user at
runtime in your Clarion application
Free template sets
http://www.solace-software.demon.co.uk



Mon, 11 Oct 2004 18:06:05 GMT  
 Detection of the CD in the drive
On Thu, 25 Apr 2002 11:06:05 +0100, "Simon Burrows"

Quote:

>Cheers
>Simon Burrows

Hi Simon!

Thank you for the code. I'll try it.

Best regards

Miroslav



Tue, 12 Oct 2004 00:28:32 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Cross-Platform CD Publishing - best CD-R drive/sw

2. Distinguishing CD-ROM from CD/RW drives?

3. ZIP Drive Detection

4. DASD detection problem (5.25 inch drive)

5. HELP: DRIVE DETECTION

6. CD ROM Detection

7. Selecting a CD Drive at Run Time

8. Selecting a CD drive at Runtime

9. Detecting CD Rom Drive

10. All my CD Drives are Missing

11. cannot find device or file error when installing 6.1 from cd or from hard drive

12. CD Drive

 

 
Powered by phpBB® Forum Software