WDK(Windows驱动程序工具包)和VC ++标头问题 [英] WDK (Windows Driver Kit) and VC++ headers problem
问题描述
我正在尝试从USB HID设备读取数据,我知道如何使用DLLImport hid.dll在C#中进行读取,但是我想从C ++中读取数据,因此不必声明所有结构等等,仅包含标头文件.
I'm trying to read from an USB HID device, I know how to do it in C# using DLLImport hid.dll, but I want to do it from C++, this way I don't have to declare all the structures, etc, and just include the headers files.
因此,我下载了 WDK ,然后下载了标头文件和链接库时出现很多错误:
So I downloaded the WDK and then when including the headers files and linking the libraries I'm getting a lot of errors:
#include <windows.h>
extern "C" {
#include <hidsdi.h>
}
int main(){
}
错误(共163个错误中的6个):
Errors (6 out of 163):
Error 1 error C2065: 'PASSIVE_LEVEL' : undeclared identifier c:\winddk\7600.16385.1\inc\api\hidpi.h 302 driver
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
Error 3 error C2146: syntax error : missing ';' before identifier 'NTSTATUS' c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
Error 4 error C2143: syntax error : missing ';' before '__stdcall' c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
Error 6 error C2377: 'NTSTATUS' : redefinition; typedef cannot be overloaded with any other symbol c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
好,所以我读到某个地方我也必须升级Windows SDK,我拥有Microsoft Windows SDK v6.0A,我下载并安装了Windows SDK v7.0.但是看起来我现在有两个SDK?如何在Visual Studio中正确升级SDK?
OK so I read somewhere that I have to upgrade the Windows SDK too, I had the Microsoft Windows SDK v6.0A, I downloaded and installed the windows SDK v7.0. But then looks like I have two SDK now? How I properly do the SDK upgrade in visual studio?
非常感谢您的帮助,
谢谢, 卡洛斯
推荐答案
我找到了一个解决方案,不知道它为什么起作用,但确实如此!
I found a solution, don't know why this is working, but it is!:
在Visual Studio中,转到:
In Visual Studio go to:
工具->选项->项目-> VC ++目录,然后显示目录:包括文件.
Tools->Options->Projects->VC++ Directories and then Show directories for: include files.
添加此文件夹:
C:\ WinDDK \ 7600.16385.1 \ inc \ ddk和C:\ WinDDK \ 7600.16385.1 \ inc \ api
C:\WinDDK\7600.16385.1\inc\ddk and C:\WinDDK\7600.16385.1\inc\api
现在这是为我解决了问题的把戏,我不知道为什么,因为看起来很奇怪,但是这里是:
Now here is the trick that solved the problem for me and I don't know why, because seems odd but here it is:
C:\ WinDDK \ 7600.16385.1 \ inc \ ddk->此目录必须是列表中的第一个目录!
C:\WinDDK\7600.16385.1\inc\ddk -> This directory have to be the first directory in the list!
C:\ WinDDK \ 7600.16385.1 \ inc \ api->此目录必须位于"$(WindowsSdkDir)\ include"上方,但必须位于"$(VCInstallDir)include"下方
C:\WinDDK\7600.16385.1\inc\api -> This directory have to be ABOVE "$(WindowsSdkDir)\include" BUT BELOW "$(VCInstallDir)include"
示例:
C:\WinDDK\7600.16385.1\inc\ddk
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
C:\WinDDK\7600.16385.1\inc\api
$(WindowsSdkDir)\include
$(FrameworkSDKDir)include
卡洛斯
这篇关于WDK(Windows驱动程序工具包)和VC ++标头问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!