mciSendString

This is a discussion on mciSendString within the C++ Programming forums, part of the General Programming Boards category; Could anyone help me with this problem? I can't get it to run with VS C++ 6.0... Thanx Code: #include ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    10

    Question mciSendString

    Could anyone help me with this problem? I can't get it to run with VS C++ 6.0... Thanx

    Code:
    #include <iostream> 
    #include <windows.h> 
    #include <mmsystem.h>
    using namespace std;
    
    int main() 
    { 
    mciSendString("set cdaudio door open",NULL,0,NULL); 
    Sleep(5000); 
    mciSendString("set cdaudio door closed",NULL,0,NULL); 
    return 0; 
    }

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    What do you mean?...cant get it to compile??

    If so add winmm.lib

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    10
    Thanx! It compiled as soon as I added the winmm.lib.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Originally posted by waldis
    Thanx! It compiled as soon as I added the winmm.lib.
    Persoanlly I dont use this to open the CDROM.......you find that if you have 2 drives (as I do - 1 CDRW, 1 DVD), then you might want control over one of them.

    If you have WinNT or above, you can use CreateFile to open a handle the drive (as a device - not just a disk). Then you can control each device seperately

    For instance I have E drive and D Drive as CDROMs

    Code:
    #include <windows.h>
    #include <winioctl.h>
    
    
    int main()
    {
    	HANDLE hD = 0,
    		hE = 0;
    	enum DRIVE_{D_DRIVE = 0,E_DRIVE} e_drive = D_DRIVE;
    	DWORD dwDummy;
    
    	hD = CreateFile("\\\\.\\D:",GENERIC_READ,0,0,OPEN_EXISTING,
    		FILE_ATTRIBUTE_READONLY,0);
    	hE = CreateFile("\\\\.\\E:",GENERIC_READ,0,0,OPEN_EXISTING,
    		FILE_ATTRIBUTE_READONLY,0);
    
    	if(hD != INVALID_HANDLE_VALUE && hE != INVALID_HANDLE_VALUE)
    	{
    		for(int i = 0;i < 6;++i)
    		{
    			DeviceIoControl((e_drive ? hE : hD),
    				IOCTL_STORAGE_EJECT_MEDIA ,0,0,0,0,&dwDummy,0);
    			Sleep(3000);
    			DeviceIoControl((e_drive ? hE : hD),
    				IOCTL_STORAGE_LOAD_MEDIA,0,0,0,0,&dwDummy,0);
    			Sleep(3000);
    			e_drive = (e_drive ? D_DRIVE : E_DRIVE);
    		}
    	}
    
    	if(hD)CloseHandle(hD);
    	if(hE)CloseHandle(hE);
    	return 0;
    }

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    10
    Sounds like little too complicated for me as of right now... but i'll save your code and see how far i can get with it. Actually i will have only one cd/rw on the system, and it is will be either Win NT 4.0 (presently) or Win XP (in the near future).
    I already posted another thread with my next question that i have stuck with:

    Check for a blank cd-r

    Thanks, I'm learning a lot though all these posts.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with mciSendString...
    By Raigne in forum Windows Programming
    Replies: 2
    Last Post: 10-28-2006, 07:53 PM
  2. mcisendstring & gditext
    By Xterria in forum Game Programming
    Replies: 0
    Last Post: 08-05-2003, 10:26 PM
  3. mciSendString
    By GaPe in forum Windows Programming
    Replies: 9
    Last Post: 12-28-2002, 08:52 AM
  4. stopping midis with mciSendString()
    By Xterria in forum Game Programming
    Replies: 4
    Last Post: 05-20-2002, 06:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21