views:

249

answers:

1

Hi, 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

A: 

Hi, 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

Carlos Dubus