艾利改色膜logo:如何用VC编程控制第二个光驱?

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 22:10:09
大侠们,我想控制第二个光驱的开关。
我只知道控制第一个主光驱的是:
mciSendString("set cdaudio door open", NULL, 0, NULL);
mciSendString("set cdaudio door closed",NULL,0,0);
我查MSDN的相关网页也没有发现我要找的控制第二个光驱的东西:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_set.asp
没找到,或者说不会找。麻烦大侠路过留意一下,帮帮忙。
.

还是不太明白你说的意思。为什么知道open函数的第三个参数,就是指出了要打开的第二个光驱?
麻烦请大侠解释一下,并给我举个例子。我再去试试。谢谢。。。
我用别的办法可以实现类似的功能,但是现在想找更简单的。就像打开第一个光驱那样只需要很少的代码就解决控制第二个光驱的问题。
麻烦了,希望大侠们走过不要错过~~~~

这个问题可以这样的解决:

我们看看mciSendString函数的原型:

MCIERROR mciSendString(
LPCTSTR lpszCommand,
LPTSTR lpszReturnString,
UINT cchReturn,
HANDLE hwndCallback
);

Parameters
lpszCommand
Pointer to a null-terminated string that specifies an MCI command string. For a list

lpszReturnString
Pointer to a buffer that receives return information. If no return information is needed, this parameter can be NULL.

cchReturn
Size, in characters, of the return buffer specified by the lpszReturnString parameter.

hwndCallback
Handle to a callback window if the "notify" flag was specified in the command string.

然后我们看函数的第一个参数LPCTSTR lpszCommand,

在这里你使用的是“set cdaudio door open”即是:open命令

我们现在看看open命令的函数原型:

wsprintf(
lpszCommand,
"open %s %s %s",
lpszDevice,
lpszOpenFlags,
lpszFlags
);
Parameters
lpszDevice
Identifier of an MCI device or device driver.

lpszOpenFlags
Flag that identifies what to initialize. The following table lists device types that recognize the open command and the flags used by each type.

这时候你可以发现open函数的第三个参数就指出了你要打开的设备,即是:第

二个光驱。

因为我的机子上面没有安装两个光驱,所以也就没法提供编译通过的源代码,

但是编程的思路是正确的,你可以试一试。