i was making a convenience program to open my D and E drives, what would the code be to do these tasks, and is there a way to make the program run and exit its self withouth having to hit a button? thanks alot
i was making a convenience program to open my D and E drives, what would the code be to do these tasks, and is there a way to make the program run and exit its self withouth having to hit a button? thanks alot
Would this be for a trojan of somesorts? It's not as if those buttons are that hard to press. The power button is way harder, because it is more springy, the CD buttons are just little objongs you have to tap. And making the drive go in is even easier, you just push it. You can also right click on the D drive in my computer and select eject.
no no i am using it because my d drive broke, it will not open manually using the open button, i need the use the windows cd player to open it and it gets to be annoying, and i just wanted to hit the button so it runs the program and opens it, then the program closes, so if anyone can help that would be great
This code doesn't work for me, could work for you..
Code:#define STRICT #include <windows.h> #include <mmsystem.h> int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) { // first find CD-ROM drive CHAR cCDRom = 'A'; CHAR szCDRomRoot[ 4 ]; while( cCDRom <= 'Z' ) { wsprintf( szCDRomRoot, "%c:", cCDRom ); if( ( GetDriveType( szCDRomRoot ) & DRIVE_CDROM ) == DRIVE_CDROM ) break; else cCDRom++; } if( cCDRom > 'Z' ) return 1; // apparently no CD-ROM on this machine! // open the CD-ROM MCI_OPEN_PARMS mop; memset( &mop, 0, sizeof( mop ) ); mop.lpstrDeviceType = (LPTSTR) MCI_DEVTYPE_CD_AUDIO; mop.lpstrElementName = szCDRomRoot; mop.lpstrAlias = ""; MCIERROR ret = mciSendCommand( 0, MCI_OPEN, MCI_WAIT | MCI_OPEN_TYPE | MCI_OPEN_ELEMENT | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE, (DWORD) &mop ); if( ret != 0 ) return 1; // could not open for some reason // open shop MCI_SET_PARMS msp; memset( &msp, 0, sizeof( msp ) ); mciSendCommand( mop.wDeviceID, MCI_SET, MCI_WAIT | MCI_SET_DOOR_OPEN, (DWORD) &msp ); // close shop memset( &msp, 0, sizeof( msp ) ); mciSendCommand( mop.wDeviceID, MCI_SET, MCI_WAIT | MCI_SET_DOOR_CLOSED, (DWORD) &msp ); // clean-up MCI_GENERIC_PARMS mgp; memset( &mgp, 0, sizeof( mgp ) ); mciSendCommand( mop.wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD) &mgp ); return 0; }
yeah i am getting 3 errors on that, one of which was 2 unresolved externals...
What compiler do you use?
microsoft visual c++ 6.0
This worked for me... check out the sample
just make sure you include the proper headers and the file
winmm.lib through your project settings if you are using VC++..
any feedback is appreciated....Code://** mci files for access to cd drive //** insure to include the winmm.lib in the links tab of the project settings #include "mmsystem.h" #include "vfw.h" void CCupHolderDlg::OnButton1() { MCIERROR i = mciSendString("open cdaudio alias cd2", 0, 0, 0); if( i ) ShowError( (DWORD)i ); MCIERROR error = mciSendString("set cd2 door open wait", 0, 0, 0); if( error ) ShowError( error ); // ::Sleep( 3000 ); // error = mciSendString("set cd2 door closed wait", 0, 0, 0); if( error ) ShowError( error ); error = mciSendString("close cd2", 0, 0, 0); if( error ) ShowError( error ); Invalidate( FALSE ); }
zMan
O by the way uncomment the lines
to have it close the tray...Code:// ::Sleep( 3000 ); // error = mciSendString("set cd2 door closed wait", 0, 0, 0);
zMan
just make sure you include the proper headers and the file
winmm.lib through your project settings if you are using VC++..
-
that is what is getting my right there, were do i need to add that in?
Project -> Settings (Alt + F7) -> Link -> Object/Library Modules
Add winmm.lib to the textbox.
alright thanks it works great!
ok, that is nice, now how would you do that on a network drive?im on the server machine and the other computer hooked to it is networked
LoL
are you trying to open someone's drive at school to freak them out or something?
thanks for the idea okiesmokie lol