VS2010新建win32空工程,加入C++代码:

#include <Windows.h>
#include <Mmsystem.h>

#pragma comment (lib, "Winmm")

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	mciSendString(L"set cdaudio door open", NULL, 0, NULL);
	mciSendString(L"set cdaudio door closed", NULL, 0, NULL);
	return 0;
}



运行,可以弹出光驱,但是不能关闭。