Question

I am in the process of writing an application to communicate with Usb devices using WinUsb.dll. This is a user-mode library that allows communication with a device through winusb.sys installed as its driver in the kernel.

I am writing this application in C++ with Visual Studio 2008.

The header WinUsb.h is found in the Windows DDK so I add the include path "D:\WinDDK\7100.0.0\inc\ddk". I then get an error that Usb.h cannot be found which WinUsb.h includes, Usb.h is also in the ddk but in a different directory, so I add "D:\WinDDK\7100.0.0\inc\api" as an include dir.

Once I add that path then everything goes in the toilet and I start getting compile errors in stdio.h and a bunch of other weird places.

I really don't want to use the DDK build system and compiler in order to simply use this DLL, thats one of the main reasons I'm using WinUsb instead of writing a proper driver.

Has anyone built an application using WinUsb.dll and Visual Studio?

Was it helpful?

Solution

I am working on writing a cross-platform USB library and using the DDK build environment would make my build process much more complicated.

WinUsb is meant to be used by client applications for devices who load WinUsb.sys as their driver. However there doesn't seem to be a version of the WinUsb headers packaged for use in user-mode programs (not including UMDF drivers).

What I ended up doing was copying the few headers that support winusb.h out of the DDK and into a private directory, I then reference that directory as an include directory during the build.

These are the headers I needed to copy:

POPPACK.h
PSHPACK1.h
usb.h
usb100.h
usb200.h
winusb.h
winusbio.h

Once I had these included in a private directory and linked with winusb.lib in the DDK I was able to compile and run my project in Visual Studio.

I don't know if I'd recommend this method as it could be bad when the headers change between DDK releases, but I will open a CONNECT bug to see if I can get MS to create a package of WinUsb headers for use in client user-mode applications.

OTHER TIPS

Historically the DDK and the SDK haven't played well together, but that problem was fixed sometime before Vista was released. However, it seems like you might be mixing parts of one SDK with another, which isn't good. I'd either use the DDK build environment or at least take a look at the INCLUDE path the DDK environment sets up and replicate it exactly in the VS project settings.

Note that you can use the DDK build environment and still use the VS IDE by creating a 'makefile project' or you might be able to use something like OSR's or Hollistech's DDKBUILD tools:

I haven't used these, so I'm not sure how well they work, but note that in spite of their similar names and uses they are different tools.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top