调用流驱动的时候,creatfile在初始化里么?
自己写一个对话框,想用按钮触发事件,是应该在应用程序初始化的时候,使用creatfile 和Deviceiocontrol么?
还是要在按钮事件里添加?
我现在用按钮里添加似乎没有效果,代码如下,大侠看看问题出在哪里
void CjusttestDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
//reslt =CjusttestDlg::SetBrightness(IOCTL_PWM_SET_PRESCALER);
HANDLE hDevice; // handle to the drive to be examined
BOOL bResult;
hDevice = CreateFile(TEXT("PWM1:"), // drive to open
GENERIC_READ|GENERIC_WRITE, // no access to the drive
0, // share mode
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // do not copy file attributes
if (hDevice == INVALID_HANDLE_VALUE) // cannot open the drive
{
return ;
}
bResult =DeviceIoControl(hDevice, // device to be queried
IOCTL_PWM_SET_LEVEL_1, // operation to perform
NULL, 0, // no input buffer
NULL, 0, // output buffer
NULL, // # bytes returned
NULL); // synchronous I/O
CloseHandle(hDevice);
return ;
}