none
How do I use WDK with Visual Studio 2008?

    Question

  • I just installed WDK, but trying to include the headers isn't working for me. I'm trying to #include <hidsdi.h>. hidsdi.h is in C:\WinDDK\6000\inc\api, and if I do #include "C:\WinDDK\6000\inc\api\hidsdi.h" is works just fine. However if I add C:\WinDDK\6000\inc\api in Tools -> Options -> Projects and Solutions -> VC++ Directories -> Include Files, I get tons of error when I try to use #include <hidsdi.h>. Here are just a few of them:

    Code Snippet

    Error    1    error C2065: '_In_' : undeclared identifier    c:\program files\microsoft visual studio 9.0\vc\include\excpt.h    60    USB2
    Error    2    error C2144: syntax error : '_EXCEPTION_RECORD' should be preceded by ')'    c:\program files\microsoft visual studio 9.0\vc\include\excpt.h    60    USB2
    Error    3    error C2448: '_except_handler' : function-style initializer appears to be a function definition    c:\program files\microsoft visual studio 9.0\vc\include\excpt.h    60    USB2
    Error    4    error C2144: syntax error : 'void' should be preceded by ';'    c:\program files\microsoft visual studio 9.0\vc\include\excpt.h    61    USB2
    Error    5    error C2144: syntax error : '_CONTEXT' should be preceded by ';'    c:\program files\microsoft visual studio 9.0\vc\include\excpt.h    62    USB2




    Do I need to add some other directories to the Include Files?

    Thursday, March 20, 2008 6:58 AM

Answers

  • I figured out what the problem is. You need to include windows.h to use hidsdi.h, and you have to use extern "C" when including hidsdi.h like this:

    Code Snippet

    #include <windows.h>

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


    Saturday, March 22, 2008 12:53 AM

All replies

  • Anyone know? I spent an hour googling this and still can't figure out what directories I should add to the include path.
    Friday, March 21, 2008 8:25 AM
  • Does Visual Studio 2008 not search sub-directories when a directory is added to Include Files path?
    Friday, March 21, 2008 10:56 PM
  • No.

     

     

    Friday, March 21, 2008 11:27 PM
  • I figured out what the problem is. You need to include windows.h to use hidsdi.h, and you have to use extern "C" when including hidsdi.h like this:

    Code Snippet

    #include <windows.h>

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


    Saturday, March 22, 2008 12:53 AM
  • Hello,

    I'm experiencing the same troubles (I'm using <hidsdi.h> and get "C2065: '_In_' : undeclared identifier" errors).
    I tried including the headers as you said, but I still get the errors.

    I'm Building on Windows Vista x64 (Business) with VS 2008 and latest WDK installed.

    Does anyone know how to solve this?

    • Proposed as answer by dzsoni Sunday, June 07, 2009 9:33 AM
    Saturday, November 01, 2008 3:23 PM
  • Huh? WDK is always intended to use with Visual Studio.  How else do you suggest the drivers will be built?  The WDK provides new functionality that the OS kernel provide to the low-level software components - driver, service, etc.   - It is just a bug in VS2008.       
    Coder
    Wednesday, November 12, 2008 6:15 PM
  • Sorry - I don't think you know what you are talking about.  The Visual Studio with C/C++ compiler and linker with the WDK will build any driver for Windows.  I used them daily like thousand others so what you said is complete false.
      
    Don't post misleading information if you don't know.   

    Coder
    Thursday, November 13, 2008 7:05 PM
  • The problem is caused by a mixture of header files between DDK and VC 2008

    My solution:
    - In VS 2008 project,
    - In the "C/C++ -> Preprocessor" - Set ignore default standard library to YES
    - In the "General->Additional Include Directories" specified
    the DDK path "C:\WinDDK\6000\inc\api; C:\WinDDK\6000\inc\crt"

    - compile and it works - Hope this help
    Coder
    • Proposed as answer by codemaniac Thursday, November 13, 2008 8:33 PM
    Thursday, November 13, 2008 8:32 PM

  • I had a same problem. My solution was:

    Add two WDK paths into the include path: Tools->Options->project and solutions->vc++ directories->show directories for include files->add

    In my case:
    C:\WINDDK\6001.18001\inc\ddk
    C:\WINDDK\6001.18001\inc\api

    And the most important:put these lines at the end of the list.

    I hope I could help someone.
    • Proposed as answer by dzsoni Sunday, June 07, 2009 9:45 AM
    Sunday, June 07, 2009 9:44 AM
  • Thank you very mush, dzsoni
    Tuesday, June 30, 2009 8:47 AM
  • Hi dzsoni.

    Just ran into the same problem. You were right. Putting those two lines at the end of the includes list solved the problem.

    Thanks...
    Sunday, December 27, 2009 6:21 PM
  • Thank you dzoni! :-)  You just spared me 2 hours of work.
    Thursday, January 14, 2010 8:31 PM
  • The problem is caused by a mixture of header files between DDK and VC 2008

    My solution:
    - In VS 2008 project,
    - In the "C/C++ -> Preprocessor" - Set ignore default standard library to YES
    - In the "General->Additional Include Directories" specified
    the DDK path "C:\WinDDK\6000\inc\api; C:\WinDDK\6000\inc\crt"

    - compile and it works - Hope this help
    Coder
    This works, thax.
    Thursday, March 04, 2010 11:48 AM
  • Codemaniac,

    Thanks very much ! It works perfect.

    Anyway, in .NET 2010 there is no way to add by

    Tools->Options->project and solutions->vc++ directories->

    no such options. I had to add from Project -> Options

    All the very best,

    Wednesday, December 19, 2012 12:44 PM