调用流驱动的时候,creatfile在初始化里么?

llaotang llaotang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
自己写一个对话框,想用按钮触发事件,是应该在应用程序初始化的时候,使用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 ;
}
...全文
评论 13
收藏 已收藏
分享
返回顶部
llaotang
嵌入开发(WinCE) 19,524 成员 41,565 内容