2

I'm working with drivers and recently I ran to this problem. Before performing some operations, our software checks if specific driver is preinstalled using this function

  SetupCopyOEMInf(sourceInf, NULL, SPOST_NONE,
                  SP_COPY_REPLACEONLY | SP_COPY_NOOVERWRITE,
                      NULL, 0, NULL, NULL);

It was copying the inf and if we got ERROR_FILE_EXISTS error, we assumed that driver was preinstalled.

For some reason this function doesn't work on recent windows 10, Even if inf file already exist in Windows/inf, it returns true every time.

I'm curious if there is some other way of checking if driver is preinstalled using winapi? Thanks.

P.S

I've checked this question and it didn't help me because, I don't have a device to plug in, my driver creates virtual network adapters.

Ojs
  • 924
  • 1
  • 12
  • 26
  • Possible duplicate of [How to find the names of the installed drivers in my computer in C?](https://stackoverflow.com/questions/10538050/how-to-find-the-names-of-the-installed-drivers-in-my-computer-in-c) – Agnius Vasiliauskas Nov 15 '17 at 07:19
  • How could it be duplicate of that, if they are trying to enumerete the hardware devices, while my question is about if the driver is preinstalled? – Ojs Nov 15 '17 at 07:23
  • Seems you don't read comments at all. There was useful comment about winapi [EnumDeviceDrivers](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682619(v=vs.85).aspx). Method is - enumerate all drivers and find yours in the list. – Agnius Vasiliauskas Nov 15 '17 at 08:13
  • It gives the list of drivers, but my driver is not in the list. I've checked and my driver is in `System32/drivers` directory, what conditions need to be met to have my driver in the list? It only appears there if I create device associated with the driver. – Ojs Nov 15 '17 at 09:01
  • Hm..., seems that this api enumerates *loaded* drivers in memory - for active devices. Yes, you need something different - to get driver if device was active at some point in the past. Probably [this thread](https://stackoverflow.com/questions/27144063/check-if-a-windows-driver-exists-for-a-given-device-id) will help you – Agnius Vasiliauskas Nov 15 '17 at 10:36
  • Thanks for your help, but that's not the point. How can I check if driver is preinstalled on clean windows? In clean windows I mean OS which had never had my software (and of course my driver) installed before? – Ojs Nov 15 '17 at 11:50
  • How about checking the registry under the services key? Not sure how reliable it is, but I recall drivers are typically registered there... – kvr Nov 15 '17 at 22:39
  • Sounds like an [XY Problem](http://xyproblem.info). What are you *really* trying to accomplish? – IInspectable Nov 15 '17 at 23:43
  • `I'm curious if there is some other way of checking if driver is preinstalled using winapi?` why do you think its `XY Problem`? @kvr which registry keys cointain such information? – Ojs Nov 16 '17 at 06:34
  • @Ojs Check HKLM\System\CurrentControlSet\Services and check each subkey, and look at the ImagePath, and Type values etc. – kvr Nov 16 '17 at 18:47

0 Answers0