473,395 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Registry Changes not being picked up

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
3 2143
"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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bob Olsson | last post by:
Hello all! I´m going to develop a windows smartclient and can´t find the information I need. Where do I store user-settings like paths, background colour and so on. I´ve read an article about...
1
by: rdavis7408 | last post by:
I have a database that has a form that opens a report using date parameters. I have been using it for six months and last week I began to get the following Error Message: "File sharing lock...
0
by: robmcdan | last post by:
Hi, I'm using RegNotifyChangeKeyValue() (via DllImport) to detect changes to registry keys and subkeys. However, in addition to catching changes, I would like to know what the changes were. ...
2
by: Ty Moffett | last post by:
Below is a set of insructions that changes the registry keys pertaining to Automatic Updates on my Windows XP box. I can make changes using the control panel applet and see the changes reflected...
1
by: UK1967 | last post by:
I wrote a ASP.NET application (Windows 2003 Enterprise Server, IIS, .NET Framework 1.1). This application use the Windows (AD) account and impersonation. Some functions in this application contact,...
6
by: ewolfman | last post by:
Hi, Is there any way in which I can monitor / hook the Registry, and upon a call to a specific key from a specific application - swap the returned value? I was thinking of using this method...
2
by: albert wong | last post by:
i have a problem. i am new to VB.net and need help with my project. i used a colordialog box to change the color of the background of the form and need to save this color change in registry so...
2
by: rodpolako | last post by:
Hi everyone, I am trying to write a program that can make some changes into a windows XP registry. My program works great when it is working on the local registry. What I want to do is to be...
4
by: =?Utf-8?B?U3RldmUgQmVobWFu?= | last post by:
I have a single integer that I wish to save from execution to execution of a simple application. Is there a way to save this persistent data in a registry key from a Visual C++ program?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.