By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,573 Members | 3,017 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,573 IT Pros & Developers. It's quick & easy.

Registry Changes not being picked up

P: n/a
Hello, I was hoping someone could help me with a problem I'm having.
I've got a C# app that uses several DLL Imports from setupapi.dll and
others (Thanks again for the Help on those Willy). One import in
particular is SetupDiBuildDriverInfoList(), which builds a list of
potential drivers for a piece of hardware. This function uses the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion
\DevicePath value key to determine which directories to look for
drivers in. In my C# app, before I call the
SetupDiBuildDriverInfoList() method, I add some directories to the
DevicePath registry key. For some reason, the
SetupDiBuildDriverInfoList() does not pick up those changes to the
registry key. I've verified that they are there and both in the
application and by using regedit. However, if I close my app and re-
open it, it does pick up the changes.

Is this something strange going on with the dll imports or is it
something else all-together?

Any help would be appreciated.

Mar 14 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Rymfax" <cw*****@bigbangllc.comwrote in message
news:11**********************@p15g2000hsd.googlegr oups.com...
Hello, I was hoping someone could help me with a problem I'm having.
I've got a C# app that uses several DLL Imports from setupapi.dll and
others (Thanks again for the Help on those Willy). One import in
particular is SetupDiBuildDriverInfoList(), which builds a list of
potential drivers for a piece of hardware. This function uses the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion
\DevicePath value key to determine which directories to look for
drivers in. In my C# app, before I call the
SetupDiBuildDriverInfoList() method, I add some directories to the
DevicePath registry key. For some reason, the
SetupDiBuildDriverInfoList() does not pick up those changes to the
registry key. I've verified that they are there and both in the
application and by using regedit. However, if I close my app and re-
open it, it does pick up the changes.

Is this something strange going on with the dll imports or is it
something else all-together?

Any help would be appreciated.

My guess is that the registry is read when SetupDiCreateDeviceInfoList is called, that is,
the directory list is built before the list is enumerated by calling
SetupDiBuildDriverInfoList. Wonder why you are adding a new directory while you are
enumerating the current path though.

Willy.

Mar 15 '07 #2

P: n/a
On Mar 15, 5:22 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
"Rymfax" <cwal...@bigbangllc.comwrote in message

news:11**********************@p15g2000hsd.googlegr oups.com...


Hello, I was hoping someone could help me with a problem I'm having.
I've got a C# app that uses several DLL Imports from setupapi.dll and
others (Thanks again for the Help on those Willy). One import in
particular is SetupDiBuildDriverInfoList(), which builds a list of
potential drivers for a piece of hardware. This function uses the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion
\DevicePath value key to determine which directories to look for
drivers in. In my C# app, before I call the
SetupDiBuildDriverInfoList() method, I add some directories to the
DevicePath registry key. For some reason, the
SetupDiBuildDriverInfoList() does not pick up those changes to the
registry key. I've verified that they are there and both in the
application and by using regedit. However, if I close my app and re-
open it, it does pick up the changes.
Is this something strange going on with the dll imports or is it
something else all-together?
Any help would be appreciated.

My guess is that the registry is read when SetupDiCreateDeviceInfoList is called, that is,
the directory list is built before the list is enumerated by calling
SetupDiBuildDriverInfoList. Wonder why you are adding a new directory while you are
enumerating the current path though.

Willy.- Hide quoted text -

- Show quoted text -
My apologies, I probably wasn't clear on what I was doing. I'm not
adding to the Device Path during the enumarion or anytime after the
SetupDiGetClassDevs (which is what I'm using) is being called. I'm
doing it well before I do anything with the SetupDi classes. Look at
it like this...lets say I have two buttons on a form, button one adds
to the Device Path and button two starts the hardware scan. I always
press button first, then press button two (after button one has
completed). I've even not used button one but instead manually
changed the registry with Regedit (after the app was open) and then
pressed button two and it still doesn't pick up the changes. It's
almost as if there is some kind of machine state or something that is
stored as a snapshop for the DllImport functions at the time the
application is started. Does this make sense? It's strange behavior
and I'm not sure what to make of it. Any thoughts?

Mar 15 '07 #3

P: n/a
"Rymfax" <cw*****@bigbangllc.comwrote in message
news:11**********************@l75g2000hse.googlegr oups.com...
On Mar 15, 5:22 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
>"Rymfax" <cwal...@bigbangllc.comwrote in message

news:11**********************@p15g2000hsd.googleg roups.com...


Hello, I was hoping someone could help me with a problem I'm having.
I've got a C# app that uses several DLL Imports from setupapi.dll and
others (Thanks again for the Help on those Willy). One import in
particular is SetupDiBuildDriverInfoList(), which builds a list of
potential drivers for a piece of hardware. This function uses the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion
\DevicePath value key to determine which directories to look for
drivers in. In my C# app, before I call the
SetupDiBuildDriverInfoList() method, I add some directories to the
DevicePath registry key. For some reason, the
SetupDiBuildDriverInfoList() does not pick up those changes to the
registry key. I've verified that they are there and both in the
application and by using regedit. However, if I close my app and re-
open it, it does pick up the changes.
Is this something strange going on with the dll imports or is it
something else all-together?
Any help would be appreciated.

My guess is that the registry is read when SetupDiCreateDeviceInfoList is called, that
is,
the directory list is built before the list is enumerated by calling
SetupDiBuildDriverInfoList. Wonder why you are adding a new directory while you are
enumerating the current path though.

Willy.- Hide quoted text -

- Show quoted text -

My apologies, I probably wasn't clear on what I was doing. I'm not
adding to the Device Path during the enumarion or anytime after the
SetupDiGetClassDevs (which is what I'm using) is being called. I'm
doing it well before I do anything with the SetupDi classes. Look at
it like this...lets say I have two buttons on a form, button one adds
to the Device Path and button two starts the hardware scan. I always
press button first, then press button two (after button one has
completed). I've even not used button one but instead manually
changed the registry with Regedit (after the app was open) and then
pressed button two and it still doesn't pick up the changes. It's
almost as if there is some kind of machine state or something that is
stored as a snapshop for the DllImport functions at the time the
application is started. Does this make sense? It's strange behavior
and I'm not sure what to make of it. Any thoughts?

DllImport is just a function declaration, the library will be delay-loaded when the function
is called for the first time, so this doesn't explain the current behavior.
"SetupDiGetClassDevs" implicitly reads from the registry and returns an handle to the device
infoset, that means that all changes to the registry path after this point won't be
reflected in the list. I would suggest you to get a copy of "process monitor" <
http://www.microsoft.com/technet/sysinternals/utilities/processmonitor.mspx and use it to
watch the exact point the registry path is opened.

Also, you must take care to call SetupDiDestroyDeviceInfoList when done with the device
info.
Willy.
Mar 15 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.