Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

eject cd

any1 made a windows utility to eject cds thru software?
(similar to the cd player eject button)

Comments

  • Stoic JokerStoic Joker Member Posts: 84
    : any1 made a windows utility to eject cds thru software?
    : (similar to the cd player eject button)
    :

    Greetings
    I've used this in MSVC++.

    #include "stdafx.h"
    #include "mmsystem.h"
    #include "resource.h"

    int Spl=0;
    BOOL CALLBACK MainProc(HWND, UINT, WPARAM, LPARAM);
    int APIENTRY WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,int)
    {
    //**********************************************************************************
    DialogBoxParam(hInst,(LPCTSTR)MAKEINTRESOURCE(IDD_SPLASH),
    NULL,(DLGPROC)MainProc,SW_HIDE);
    //**********************************************************************************
    MCI_OPEN_PARMS op;
    DWORD flags;
    int nPos = 0;
    TCHAR szDrive[4];
    strcpy(szDrive, "?:\");
    DWORD dwDriveList = ::GetLogicalDrives ();
    while(dwDriveList)
    {
    if(dwDriveList & 1)
    {
    szDrive[0] = 0x41 + nPos;
    if(GetDriveType(szDrive) == DRIVE_CDROM)
    {
    op.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
    op.lpstrElementName = szDrive;
    flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE;
    mciSendCommand(0,MCI_OPEN,flags,(unsigned long)&op);
    mciSendCommand(op.wDeviceID,MCI_SET,MCI_SET_DOOR_OPEN,0);
    }
    }
    dwDriveList >>= 1;
    nPos++;
    }
    return 0;
    }


    BOOL CALLBACK MainProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    switch(uMsg)
    {
    case WM_INITDIALOG:
    {
    SetTimer(hDlg,1,1000,NULL);
    }
    case WM_TIMER:
    { Spl++;
    if(Spl>2)
    {
    KillTimer(hDlg,1);
    EndDialog(hDlg,0);
    }
    }
    }
    return FALSE;
    }


    The code loops & opens ALL of the CD-ROMs on a Machine(some people have 2). I've seen a lot of Open the CD-ROM door pranks but none that would check for a 2nd device, So... (hehe)

    Stoic Joker

    www.stoicjoker.com

Sign In or Register to comment.