Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:14:27+00:00 2026-05-27T17:14:27+00:00

I have a signed driver and I need to install it programmatically for a

  • 0

I have a signed driver and I need to install it programmatically for a specific USB device using C# (targeting Vista and 7 64-bit).

I found very easy the use of the DriverPackagePreinstall function within the DIFx API (here is how to P/Invoke it): by calling it before the device is plugged into the USB, Windows is able to associate the driver to the device once this is detected.

The problems arise when the device is plugged into the USB without having pre-installed the driver. It can happen that another driver is installed for that device (in one test PC I found that a generic driver has been installed and that the device is listed under “Other devices” in Device Manager).

Trying to solve this problem, up to now I’ve been able to detect that the device is there by using the SetupDiGetClassDevs, the SetupDiEnumDeviceInfo and the SetupDiGetDeviceRegistryProperty functions in order to identify the device by its VID and PID (vendor and product identifier). Now that I have the SP_DEVINFO_DATA for my device I guess I’ve to call the InstallSelectedDriver function, isn’t it? If yes, could you please tell me how to P/Invoke that function (I cannot find it on pinvoke.net) and how to use it by specifying the driver I want to install for my device (supposing I’ve the INF path)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:14:27+00:00Added an answer on May 27, 2026 at 5:14 pm

    I found a sample for exactly what I was searching for here. The P/Invoke for InstallSelectedDriver works for me as:

    [DllImport("newdev.dll", SetLastError = true, CharSet = CharSet.Auto)]
    [return: MarshalAs(UnmanagedType.Bool)]
    protected static extern bool InstallSelectedDriver(
          IntPtr HwndParent,
          IntPtr DeviceInfoSet,
          string Reserved,
          [MarshalAs(UnmanagedType.Bool)] bool Backup,
          out UInt32 Reboot);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have need to pack four signed bytes into 32-bit integral type. this is
I need to install the libusb-win32 driver on Windows 7 64 bit machines. This
I have signed numbers (2s complement) stored in 32-bit integers, and I want to
I have written a device driver for a device but each time I connect
OK, I am working on developing a USB device. I have created a custom
I have signed out from the store in device settings. I entered user credentials
I have Installed ActiveX control on windows vista.. using Internet Explorer and cab file..
I have signed them using the export wizared but when i transfer them onto
I have signed my app using netbeans and exported it, uploaded to android market,
I have an inf file for a user-mode driver for a device. Does windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.