Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Eject CD/DVD

Posted on December 14, 2013October 26, 2015 By David Kittell
Public Sub ejectCDRom()
        Dim i As Integer

        'code to eject cdrom ok
        Dim owmp As Object
        Dim colCDROMs As Object
        owmp = CreateObject("WMPlayer.OCX.7")
        colCDROMs = owmp.cdromCollection
        If colCDROMs.Count >= 1 Then
            For i = 0 To colCDROMs.Count - 1
                colCDROMs.Item(i).eject()
            Next
        End If
    End Sub
Public Class Form1

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim CDTrayOpen As Boolean = False 'this is global

'this is in the click event
If CDTrayOpen Then
	'Close CD tray
	mciSendString("set CDAudio door closed", 0, 0, 0)
	CDTrayOpen = False
Else
	'Open CD tray
	mciSendString("set CDAudio door open", 0, 0, 0)
	CDTrayOpen = True
End If
End Sub
End Class
Originally Posted on December 14, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code VB.NET

Post navigation

Previous post
Next post

Related Posts

Excel – Find Comma Replace With LineBreak

Posted on August 11, 2015October 26, 2015

Selected the range of cells you need to replace. Go to Home > Find & Select > Replace or Ctrl + H Find what: , Replace with: CTRL + SHIFT + J Click Replace All Somehow CTRL + SHIFT + J is registered as a linebreak. Reference: http://stackoverflow.com/questions/14856501/substitute-a-comma-with-a-break-link-in-a-cell Originally Posted…

Read More

Ektron Find Replace In Library

Posted on October 23, 2013October 26, 2015

This script will search and replace specific library links SET XACT_ABORT ON DECLARE @currurl NVARCHAR(500) DECLARE @newurl NVARCHAR(500) DECLARE @search NVARCHAR(500) DECLARE @replace VARCHAR(500) SET @search = ” –string to find SET @replace = ” –replacement string DECLARE @pos INT DECLARE @id BIGINT BEGIN TRAN DECLARE curs CURSOR LOCAL FAST_FORWARD…

Read More

Show Stored Procedures

Posted on July 30, 2013October 26, 2015

SELECT so.NAME ,created ,last_altered ,specific_catalog ,routine_definition ,sql_data_access FROM sys.objects so LEFT OUTER JOIN information_schema.routines sr ON so.NAME = sr.specific_name WHERE objectproperty(object_id, N’IsMSShipped’) = 0 AND objectproperty(object_id, N’IsProcedure’) = 1 ORDER BY created DESC ,NAME SELECT * FROM information_schema.routines WHERE routine_type = ‘PROCEDURE’ ORDER BY specific_name SELECT * FROM sys.objects WHERE…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes