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:

#If VBA7 Then
    Declare PtrSafe Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
    (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
    ByVal uReturnLength As Long, ByVal hwndCallback As LongPtr) As Long
#Else
    Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
    (ByVal lpCommandString As String, ByVal lpReturnString As String, _
    ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
#End If

.

.

Step3:

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

Private Sub Workbook_Open()
Dim retval As Long
retval = mciSendString("set CDAudio door open", "", 0, 0)
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.

 

 

RELATED STUFF

  1. Mocking the ‘Merge & Center’ Icon
  2. Highlighting the Active Row and Column
  3. Why Replace the DOM Interface
  4. Running an Access Parameter Query from Excel
  5. Fun with Custom Lists
  6. Sort by Color in Excel 2003
  7. Auto Adjust Chart Label Positions
  8. Recordset Tricks in Excel 1 – Filling a ComboBox with Unique Values
  9. Running Crosstab Queries in Excel
  10. Status Bar Fun – Show Cell Selection Info
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>