windows driver 枚举串口
来源:互联网 发布:淘宝两钻买家号多少钱 编辑:程序博客网 时间:2024/06/06 08:59
//枚举串口NTSTATUS status;HANDLE hKey = NULL;OBJECT_ATTRIBUTES oa;UNICODE_STRING strPath = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\SERIALCOMM");//ULONG ResultLength = 0;PKEY_FULL_INFORMATION PKFI;PKEY_VALUE_PARTIAL_INFORMATION pkvpi;UNICODE_STRING strOutPut;wchar_t strTemp[ArrayLength] = {0};ULONG i = 0;ULONG nSubKeys = 0;RtlInitEmptyUnicodeString(&strOutPut, strTemp, ArrayLength);InitializeObjectAttributes(&oa, &strPath, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);status = ZwOpenKey(&hKey, KEY_ALL_ACCESS, &oa);if (!NT_SUCCESS(status)){KdPrint(("ZwOpenKey failed"));return status;}ZwQueryKey(hKey, KeyFullInformation, NULL, 0, &ResultLength);PKFI = (PKEY_FULL_INFORMATION)ExAllocatePool(PagedPool, ResultLength);if (PKFI == NULL){KdPrint(("ExAllocatePool failed"));ZwClose(hKey);ExFreePool(PKFI);return STATUS_INSUFFICIENT_RESOURCES;}status = ZwQueryKey(hKey, KeyFullInformation, PKFI, ResultLength, &ResultLength);if (!NT_SUCCESS(status)){KdPrint(("ZwEnumerateKey failed with error %I32X", status));ZwClose(hKey);ExFreePool(PKFI);return status;}nSubKeys = PKFI->Values;KdPrint(("子键个数: %I32d", PKFI->Values));ExFreePool(PKFI);for (; i < nSubKeys; i++){ZwEnumerateValueKey(hKey, i, KeyValuePartialInformation, NULL, 0, &ResultLength);pkvpi = (PKEY_VALUE_PARTIAL_INFORMATION)ExAllocatePool(PagedPool, ResultLength);if (pkvpi == NULL){KdPrint(("ExAllocatePoolWithTag failed"));ZwClose(hKey);ExFreePool(pkvpi);return STATUS_INSUFFICIENT_RESOURCES ;}status = ZwEnumerateValueKey(hKey, i, KeyValuePartialInformation, pkvpi, ResultLength, &ResultLength);if (!NT_SUCCESS(status)){KdPrint(("ZwEnumerateValueKey failed with error %I32X", status));ZwClose(hKey);ExFreePool(pkvpi);return status;}RtlStringCbPrintfW(strOutPut.Buffer, ArrayLength, L"%s", pkvpi->Data);KdPrint(("%ws", strOutPut.Buffer));ExFreePool(pkvpi);}ZwClose(hKey);return STATUS_SUCCESS;
0 0
- windows driver 枚举串口
- 枚举windows串口(1)
- windows下C语言枚举串口端口
- 枚举windows下的串口(2)
- 枚举串口
- 枚举串口
- 枚举串口
- 枚举串口
- 串口枚举
- 枚举Driver和FileSystem
- vc串口枚举类
- 枚举串口2
- 通过注册表枚举串口
- 枚举串口四法
- 枚举串口号函数
- 枚举系统中的串口
- 枚举串口方法
- 枚举串口端口
- 查看持有行锁的SQL
- phonegap开发android应用中启动图片设置
- zoj 3494 BCD Code(AC自动机+数位dp)
- 把EXCEL用程序导入到ORACLE中(SpringMVC+MyBatis)
- 《用GNS3 路由器 模拟 PC 实现访问外网》
- windows driver 枚举串口
- 第十二周项目3-用递归方法求解(2)求1*3*...*n的递归式
- 整理音乐
- windows driver 映射小文件
- Codeforces 486E. LIS of Sequence
- windows driver 映射大文件
- 不同域的SqlServer 如何用hostname访问服务器
- 【SQL Server】 表值参数(Table-Valued Parameter)的使用
- 进程与线程的区别(转)