apptest.cpp
来自「驱动编程菜鸟入门——3」· C++ 代码 · 共 36 行
CPP
36 行
// AppTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <conio.h>
int main()
{
HANDLE hDevice =
CreateFile("\\\\.\\TestDevice",
GENERIC_READ | GENERIC_WRITE,
0, // share mode none
NULL, // no security
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL ); // no template
if (hDevice == INVALID_HANDLE_VALUE)
{
printf("设备打开失败!\n");
return 1;
}
printf("设备打开成功!\n");
printf("Press any key to continue....\n");
getch();
printf("关闭设备!\n");
CloseHandle(hDevice);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?