2

I have created a driver for a composite device (hardware ID with an MI_## part) based on WinUsbDriver.

The point is that "template" does not contains the [DefaultInstall] section, for that reason I can't P/Invoke InstallHinfSection function:

InstallHinfSection(NULL,NULL,TEXT("DefaultInstall 132 path-to-inf\infname.inf"),0);

I want to create the INF files and install them using the application code, before connecting the composite device for the first time.

How can I install the INF Driver without the [DefaultInstall] section from a .NET desktop application?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
denys-vega
  • 3,522
  • 1
  • 19
  • 24
  • Why don't you just add it? INF files are like cookies, you can simply bake another one. Do note the DeviceInstall subdirectory in the [.NET version](https://winusbnet.codeplex.com/), the DeviceInstall.cpp source code file shows you how to use SetupCopyOEMInf(). – Hans Passant Feb 28 '15 at 16:40
  • @HansPassant thanks for your comment. I'm using [LibUsbDotNet](http://libusbdotnet.sourceforge.net/V2/Index.html). The INF files are based on [WinUsbDriver](http://libusb-winusb-wip.googlecode.com/files/winusb%20driver.zip) template. I found a way to create a self-signed .cat files from .inf using [dpscat](https://code.google.com/p/usb-travis/source/browse/trunk/libusbK/src/dpscat/dpscat.txt) and then **dpint.exe**(from Windows) comes into _game_. – denys-vega Feb 28 '15 at 20:56
  • [https://stackoverflow.com/a/11751075/1948857](https://stackoverflow.com/a/11751075/1948857) May be this answer can help. I came acroos these problem these days and solved with these answer. – Mistrafantastic Mar 13 '15 at 09:25

1 Answers1

2

Your best bet (in Windows Vista and later) is to use a direct function that installs the inf into the Driver Store, then automatically installs it on matching hardware. This can be done with one function: DiInstallDriver.

For example...

[DllImport("newdev.dll")]
public static extern bool DiInstallDriver
(
    [In] IntPtr hwndParent,
    [In] string FullInfPath,
    [In] uint Flags,
    [Out] bool NeedReboot
);

DiInstallDriver(IntPtr.Zero, "full path to my inf", 0, false);
John Suit
  • 1,254
  • 12
  • 17