WDK(Windows 驱动程序套件)和 VC++标题问题

发布于 2024-09-11 03:41:54 字数 1410 浏览 12 评论 0原文

我正在尝试从 USB HID 设备读取数据,我知道如何使用 DLLImport hid.dll 在 C# 中执行此操作,但我想从 C++ 执行此操作,这样我就不必声明所有结构等,并且只包含头文件。

所以我下载了 WDK 然后在包含头文件并链接库时我收到很多错误:

#include <windows.h>

extern "C" {
    #include <hidsdi.h>
}

int main(){

}

错误(163 中的 6 个):

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升级?

非常感谢您的帮助,

谢谢, 卡洛斯

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.

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(){

}

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

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 very much appreciate your help,

Thanks,
Carlos

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

堇色安年 2024-09-18 03:41:54

我找到了一个解决方案,不知道为什么它有效,但它确实有效!:

在 Visual Studio 中转到:

工具->选项->项目->VC++ 目录,然后显示目录:包含文件。

添加此文件夹:

C:\WinDDK\7600.16385.1\inc\ddk 和 C:\WinDDK\7600.16385.1\inc\api

现在这是为我解决问题的技巧,我不知道为什么,因为似乎奇怪,但它是:

C:\WinDDK\7600.16385.1\inc\ddk ->该目录必须是列表中的第一个目录!

C:\WinDDK\7600.16385.1\inc\api ->该目录必须位于“$(WindowsSdkDir)\include”上方但位于“$(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

Carlos

I found a solution, don't know why this is working, but it is!:

In Visual Studio go to:

Tools->Options->Projects->VC++ Directories and then Show directories for: include files.

Add this folders:

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 -> This directory have to be the first directory in the list!

C:\WinDDK\7600.16385.1\inc\api -> This directory have to be ABOVE "$(WindowsSdkDir)\include" BUT BELOW "$(VCInstallDir)include"

Example:

C:\WinDDK\7600.16385.1\inc\ddk
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
C:\WinDDK\7600.16385.1\inc\api
$(WindowsSdkDir)\include
$(FrameworkSDKDir)include

Carlos

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文