Search code examples
visual-studiodllsolutioncross-reference

Visual studio: How to setup dll solution, which can refer to winusb


I've been trying for some days now to make an solution which compiles and links a dll, which is able to call functions from winusb. I started with the example from Microsoft, which is pretty straight forward to make an winusb app. https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/how-to-write-a-windows-desktop-app-that-communicates-with-a-usb-device Now I have some source code, which would work with my device and I would like to make that accesible through an dll. I tried: -Create an new dll project, add my files with the matching #include directives but it won't compile. -2nd approach was to add an dll project to the win usb app solution and try to call the functions of the winusb app project from the dll project. That doesn't work. I tried to set a reference from the dll project to the winusb app project, but that didn't help. So, what is the correct way, to make these functions accessible in my dll project?

Best regards!


Solution

  • This is what I did to make it work:
    Configuration Properties>VC++ Directories:
    -Add $(WDKBinRoot_x86),$(WDKContentRoot)tools\tracing\x86
    Configuration Properties>Library Directories:
    -Add $(VCToolsInstallDir)lib\Spectre\onecore$(DDKPlatform);$(LibraryPath)
    Linker>Input: -Add onecoreuap.lib;winusb.lib;

    Under c/c++>Preprocessor where also a lot of preprocessor definitions different. I added these, but I do not know if they are needed. Here is the list: WIN32;WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP;WINAPI_PARTITION_DESKTOP=1;WINAPI_PARTITION_SYSTEM=1;WINAPI_PARTITION_APP=1;WINAPI_PARTITION_PC_APP=1;