Detecting CD Insert or Autorun?

VagabondSW

Well-known member
Joined
Feb 19, 2005
Messages
66
Id like to capture the CD Insert or Autorun (if enabled) if possible.

Here is the scenario. I am developing MyApp 2.0 that reads content distributed on CDs or DVDs. Unfortunately, the content CDs used with MyApp 1.0 included an autorun file that either installed MyApp 1.0 or launched an existing MyApp 1.0 installation. If the end-user already has MyApp 2.0 installed, I do not want old CDs containing MyApp 1.0 to attempt to install the legacy application when inserted into the drive.

Is there a way to detect and prevent that from happening?
 
Hmm... seems like it would just be easier to store the current version of YourApp somewhere on the computer (registry?) and then, when you want to install your app, check to make sure that CurrentVersion is < this version.

It would be kind of hair-raising trying to continually scan for a CD or Autorun.exe while your app is running... and then to kill it... :-\.
 
Iceplug said:
Hmm... seems like it would just be easier to store the current version of YourApp somewhere on the computer (registry?) and then, when you want to install your app, check to make sure that CurrentVersion is < this version.

It would be kind of hair-raising trying to continually scan for a CD or Autorun.exe while your app is running... and then to kill it... :-\.
Thanks for the suggestion, and it is a good one, but unfortunately the folks that wrote MyApp 1.0 had no such scheme in place. When the end-user inserts a MyApp 1.0 CD, the autorun will install version 1.0 of the application unless the user cancels out at some point.

The good part is that the end-user would probably insert the old CD only at the prompting of the new application. Therefore, I could scan for the Insert/Autorun event only until the end-user inserts the legacy media or cancels the request.

Any other suggestions are still needed and welcome.
 
I try to keep track of where the cd is in my burning app with this:

Code:
    Private Const WM_DEVICECHANGE As Integer = 537
    Private Const DBT_DEVICEREMOVECOMPLETE As Integer = 32772
    Private Const DBT_DEVICEARRIVAL As Integer = 32768
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Handle the CD messages
        Select Case m.Msg
            Case WM_DEVICECHANGE
                If (m.WParam.ToInt32() = DBT_DEVICEREMOVECOMPLETE) Then
                    CDIsInserted = False
                    Me.TextBox1.Text &= "CD ejected/unavailable/burning" & vbCrLf
                ElseIf (m.WParam.ToInt32() = DBT_DEVICEARRIVAL) Then
                    CDIsInserted = True
                    Me.TextBox1.Text &= "CD Inserted/finished burning" & vbCrLf
                End If
            Case Else
                Call base WndProc for default handling
                MyBase.WndProc(m)
        End Select
    End Sub

might be of use...
 
Back
Top