阅读:2040回复:0
用DeviceIoControl获得openvpn tap 虚拟网卡信息失败
用DeviceIoControl获得openvpn tap 虚拟网卡信息失败,DeviceIoControl调用失败GetLastError()返回1 不知道是什么原因。。。
以下是代码 char buf[1024]; DWORD nRead; ULONG status = TRUE, len; HANDLE hICDriver = CreateFile("\\\\.\\{E00D9A99-2A50-47F6-9B6C-FCD17739CCE5}", GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING, FILE_ATT RIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, NULL); if (hICDriver==INVALID_HANDLE_VALUE) { printf("打开设备失败 ErrorCode=%d\n", GetLastError()); goto err; } printf("成功打开设备\n"); ULONG info[3]; memset(info, 0, sizeof(ULONG)*3); if (!DeviceIoControl (hICDriver, TAP_IOCTL_GET_VERSION, &info, sizeof (info), &info, sizeof (info), &len, NULL)) { printf("DeviceIoControl ErrorCode=%d\n", GetLastError()); //运行到这里,,返回1 goto err; } err: Sleep(5000); return 0; |
|