Open CD Rom – The Most Useless API Call

November 28, 2011 by datapig Leave a reply »

Over the Thanksgiving holiday, I was ignoring the family and puttering around on the internet. There, I found a list of all the cool API calls you can do through VBA. An API call is essentially a piece of code you can use to make the Windows operating system do things – like open a directory, freeze the system, open a dialog box, etc.

.

Well, there is an API Call that essentially opens your CD Rom drive. That's right – you can implement code so you don't have to go through the painstaking task of pressing the Open button for your CD Rom drive. Wow …. AUTOMATION IS THE BEST!

.

OK…this gets my vote for the most useless API call. Second place is the API call to close the CD Rom Drive.

.

That being said, you could use this useless API to prank your coworkers.

The trick is to implement the Open CD Rom API call so that every time they open Excel, the CD Rom pops so life. Definitely good for weeks of annoyance and confusion.

.

Step 1:

Go to their computer and navigate to the Visual Basic Editor in Excel and find their Personal Macro Workbook.

.

Step2:

In a new module, copy and paste this code:

Visual Basic:
  1. #If VBA7 Then
  2.     Declare PtrSafe Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
  3.     (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
  4.     ByVal uReturnLength As Long, ByVal hwndCallback As LongPtr) As Long
  5. #Else
  6.     Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
  7.     (ByVal lpCommandString As String, ByVal lpReturnString As String, _
  8.     ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
  9. #End If

.

.

Step3:

In the Workbook Open Event, copy and paste this code:

Visual Basic:
  1. Private Sub Workbook_Open()
  2. Dim retval As Long
  3. retval = mciSendString("set CDAudio door open", "", 0, 0)
  4. End Sub

.

 

.

.

Step4:

Save the changes to the Personal Macro Workbook and close Excel.

.

The Evil deed has been done. Every time Excel is opened, the CD Rom drive will pop to life.

Now you can sit back and see how long your victim will live with this crazy opening CD Drive before either fixing it or re-imaging the machine.

 

 

Advertisement

One Response

  1. Arlyn says:

    This is pure genius. Although, I will just have to send them one of my special spreadsheets with this in the background. Very difficult to get access to someone else's computer in a health insurance company.

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>