Greetings,
I'm creating a little program that acts as a glorified Registry explorer.
The TreeView doesn't allow you to show a plus sign unless a node has child
nodes, so I need to determine whether a registry key has subkeys and add a
dummy childnode. The way I'm doing this is to populate the child nodes as
the parent is expanded.
However, there are some serious performance implications. First, when I
pouplate the HKEY_CLASSES_RO OT, it takes 3 seconds to add all the subkeys to
the hive. But if I determine whether those subkeys have subkeys, it takes
49 minutes to populate the HIVE. This is obviously unacceptable. So I'm
left with two choices: 1) figure out a more efficient way to determine and
populate the data, or 2) use C++. Every reg explorer I've ever seen takes
milliseconds to populate the nodes as you expand them, and neither of these
programs are written in C#.
Does anyone here know a better approach? Keep in mind, I'm not populate the
subkeys. I'm only determing whether the subkeys have subkeys (at the level
currently visible) and adding a dummy node so you can get the [+] / [-]
symbol to expand/contract the nodes in the TreeView.
Is it the TreeView that's so slow or the Registry objects in the Win32
namespace? I don't have access to a decent profiler so its hard for me to
tell.
Thanks,
Shawn 8 4638
There must be something in your code that causes it to take that long. I
wrote a similar application some time ago in C# running on .NET 1.1. I tried
it out right now and it took about 4 seconds to list all keys in HKCR\CLSID,
and I expect that this is the largest one. Note that I'm also doing the
check for subkeys and use the same approach - insert a dummy node if there's
at least one subkey and add the subkeys in the BeforeExpand event.
Could you post the actual code populating the tree view?
Michael
"Shawn B." <le****@html.co m> schrieb im Newsbeitrag
news:uM******** ******@TK2MSFTN GP09.phx.gbl... Greetings,
I'm creating a little program that acts as a glorified Registry explorer. The TreeView doesn't allow you to show a plus sign unless a node has child nodes, so I need to determine whether a registry key has subkeys and add a dummy childnode. The way I'm doing this is to populate the child nodes as the parent is expanded.
However, there are some serious performance implications. First, when I pouplate the HKEY_CLASSES_RO OT, it takes 3 seconds to add all the subkeys to the hive. But if I determine whether those subkeys have subkeys, it takes 49 minutes to populate the HIVE. This is obviously unacceptable. So I'm left with two choices: 1) figure out a more efficient way to determine and populate the data, or 2) use C++. Every reg explorer I've ever seen takes milliseconds to populate the nodes as you expand them, and neither of these programs are written in C#.
Does anyone here know a better approach? Keep in mind, I'm not populate the subkeys. I'm only determing whether the subkeys have subkeys (at the level currently visible) and adding a dummy node so you can get the [+] / [-] symbol to expand/contract the nodes in the TreeView.
Is it the TreeView that's so slow or the Registry objects in the Win32 namespace? I don't have access to a decent profiler so its hard for me to tell.
Thanks, Shawn
Money says he's using Nodes.Add() instead of Nodes.AddRange( ). That
would be key in this kind of situation.
Jason Newell
Michael Höhne wrote: There must be something in your code that causes it to take that long. I wrote a similar application some time ago in C# running on .NET 1.1. I tried it out right now and it took about 4 seconds to list all keys in HKCR\CLSID, and I expect that this is the largest one. Note that I'm also doing the check for subkeys and use the same approach - insert a dummy node if there's at least one subkey and add the subkeys in the BeforeExpand event.
Could you post the actual code populating the tree view?
Michael
"Shawn B." <le****@html.co m> schrieb im Newsbeitrag news:uM******** ******@TK2MSFTN GP09.phx.gbl...
Greetings,
I'm creating a little program that acts as a glorified Registry explorer. The TreeView doesn't allow you to show a plus sign unless a node has child nodes, so I need to determine whether a registry key has subkeys and add a dummy childnode. The way I'm doing this is to populate the child nodes as the parent is expanded.
However, there are some serious performance implications. First, when I pouplate the HKEY_CLASSES_RO OT, it takes 3 seconds to add all the subkeys to the hive. But if I determine whether those subkeys have subkeys, it takes 49 minutes to populate the HIVE. This is obviously unacceptable. So I'm left with two choices: 1) figure out a more efficient way to determine and populate the data, or 2) use C++. Every reg explorer I've ever seen takes milliseconds to populate the nodes as you expand them, and neither of these programs are written in C#.
Does anyone here know a better approach? Keep in mind, I'm not populate the subkeys. I'm only determing whether the subkeys have subkeys (at the level currently visible) and adding a dummy node so you can get the [+] / [-] symbol to expand/contract the nodes in the TreeView.
Is it the TreeView that's so slow or the Registry objects in the Win32 namespace? I don't have access to a decent profiler so its hard for me to tell.
Thanks, Shawn
> Money says he's using Nodes.Add() instead of Nodes.AddRange( ). That would be key in this kind of situation.
Yes I am. I'll have to redo the code for AddRange() if its really that much
more efficient. My code is very simple, the relevant part is:
if (canContinue == true)
{
string[] names = regKey.GetSubKe yNames();
tvwRegistryKeys .BeginUpdate();
foreach (string key in names)
{
regKey.OpenSubK ey(path + @"\" + key);
TreeNode child = new TreeNode(key);
if (regKey.SubKeyC ount > 0)
{
TreeNode childNode = new TreeNode("*");
child.Nodes.Add (childNode);
}
regKey.Close();
node.Nodes.Add( child);
}
regKey.Close();
tvwRegistryKeys .EndUpdate();
}
Thanks,
Shawn
Hi Shawn,
I agree with Jason that AddRange is preferable, but your problem clearly is
different. In your foreach loop you do a call to RegistryKey.Ope nSubKey but
don't store the result in any variable: foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key);
Now that means that the next block will always operate on the same registry
key:
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
If this registry key is HKEY_CLASSES_RO OT, then regKey.SubKeyCo unt will take
an enormous amount of time to complete and you're calling it over and over.
Try the following and I'm quite sure that your tree is populated in a few
seconds. After you've verified that, you should go for AddRange to improve
it furhter.
if (canContinue == true)
{
string[] names = regKey.GetSubKe yNames();
tvwRegistryKeys .BeginUpdate();
foreach (string key in names)
{
RegistryKey regSubkey = regKey.OpenSubK ey(path + @"\" + key);
TreeNode child = new TreeNode(key);
if (regSubkey.SubK eyCount > 0)
{
TreeNode childNode = new TreeNode("*");
child.Nodes.Add (childNode);
}
node.Nodes.Add( child);
regSubkey.Close ();
}
regKey.Close();
}
Michael
"Shawn B." <le****@html.co m> schrieb im Newsbeitrag
news:OH******** ******@TK2MSFTN GP14.phx.gbl... Money says he's using Nodes.Add() instead of Nodes.AddRange( ). That would be key in this kind of situation.
Yes I am. I'll have to redo the code for AddRange() if its really that much more efficient. My code is very simple, the relevant part is:
if (canContinue == true) { string[] names = regKey.GetSubKe yNames();
tvwRegistryKeys .BeginUpdate();
foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key); TreeNode child = new TreeNode(key);
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
regKey.Close(); node.Nodes.Add( child); }
regKey.Close();
tvwRegistryKeys .EndUpdate(); }
Thanks, Shawn
Michael,
If you're interested, I threw together a little C# 2005 regedit program
to show you what I'm talking about. I compared it to the Windows
regedit and it's slightly slower but nothing like what you described. I
don't know that you can get much faster with .NET. Let me know if you
have any questions.
You can download the source from my website. www.jasonnewell.net/public/Examples/Regedit.zip
Jason Newell
Michael Höhne wrote: Hi Shawn,
I agree with Jason that AddRange is preferable, but your problem clearly is different. In your foreach loop you do a call to RegistryKey.Ope nSubKey but don't store the result in any variable:
foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key);
Now that means that the next block will always operate on the same registry key:
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
If this registry key is HKEY_CLASSES_RO OT, then regKey.SubKeyCo unt will take an enormous amount of time to complete and you're calling it over and over.
Try the following and I'm quite sure that your tree is populated in a few seconds. After you've verified that, you should go for AddRange to improve it furhter.
if (canContinue == true) { string[] names = regKey.GetSubKe yNames(); tvwRegistryKeys .BeginUpdate();
foreach (string key in names) { RegistryKey regSubkey = regKey.OpenSubK ey(path + @"\" + key); TreeNode child = new TreeNode(key);
if (regSubkey.SubK eyCount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
node.Nodes.Add( child); regSubkey.Close (); }
regKey.Close(); } Michael
"Shawn B." <le****@html.co m> schrieb im Newsbeitrag news:OH******** ******@TK2MSFTN GP14.phx.gbl...
Money says he's using Nodes.Add() instead of Nodes.AddRange( ). That would be key in this kind of situation.
Yes I am. I'll have to redo the code for AddRange() if its really that much more efficient. My code is very simple, the relevant part is:
if (canContinue == true) { string[] names = regKey.GetSubKe yNames();
tvwRegistryKe ys.BeginUpdate( );
foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key); TreeNode child = new TreeNode(key);
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
regKey.Close(); node.Nodes.Add( child); }
regKey.Close( );
tvwRegistryKe ys.EndUpdate(); }
Thanks, Shawn
Sorry, I meant Shawn in my last post.
Jason Newell
Jason Newell wrote: Michael,
If you're interested, I threw together a little C# 2005 regedit program to show you what I'm talking about. I compared it to the Windows regedit and it's slightly slower but nothing like what you described. I don't know that you can get much faster with .NET. Let me know if you have any questions.
You can download the source from my website.
www.jasonnewell.net/public/Examples/Regedit.zip
Jason Newell
Michael Höhne wrote:
Hi Shawn,
I agree with Jason that AddRange is preferable, but your problem clearly is different. In your foreach loop you do a call to RegistryKey.Ope nSubKey but don't store the result in any variable:
foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key); Now that means that the next block will always operate on the same registry key:
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); } If this registry key is HKEY_CLASSES_RO OT, then regKey.SubKeyCo unt will take an enormous amount of time to complete and you're calling it over and over.
Try the following and I'm quite sure that your tree is populated in a few seconds. After you've verified that, you should go for AddRange to improve it furhter.
if (canContinue == true) { string[] names = regKey.GetSubKe yNames(); tvwRegistryKeys .BeginUpdate();
foreach (string key in names) { RegistryKey regSubkey = regKey.OpenSubK ey(path + @"\" + key); TreeNode child = new TreeNode(key);
if (regSubkey.SubK eyCount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
node.Nodes.Add( child); regSubkey.Close (); }
regKey.Close(); } Michael
"Shawn B." <le****@html.co m> schrieb im Newsbeitrag news:OH******** ******@TK2MSFTN GP14.phx.gbl...
Money says he's using Nodes.Add() instead of Nodes.AddRange( ). That would be key in this kind of situation.
Yes I am. I'll have to redo the code for AddRange() if its really that much more efficient. My code is very simple, the relevant part is:
if (canContinue == true) { string[] names = regKey.GetSubKe yNames();
tvwRegistryKeys .BeginUpdate();
foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key); TreeNode child = new TreeNode(key);
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
regKey.Close(); node.Nodes.Add( child); }
regKey.Close();
tvwRegistryKeys .EndUpdate(); }
Thanks, Shawn
Everytime I run it I keept getting "Object reference not set to an instance
of an object when it tries to return an instance by OpenSubKey(...) ; The
key path looks valid, I'm not sure what to do.
Thanks,
Shawn
"Michael Höhne" <mi************ @nospam.nospam> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. . Hi Shawn,
I agree with Jason that AddRange is preferable, but your problem clearly is different. In your foreach loop you do a call to RegistryKey.Ope nSubKey but don't store the result in any variable:
foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key);
Now that means that the next block will always operate on the same registry key:
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
If this registry key is HKEY_CLASSES_RO OT, then regKey.SubKeyCo unt will take an enormous amount of time to complete and you're calling it over and over.
Try the following and I'm quite sure that your tree is populated in a few seconds. After you've verified that, you should go for AddRange to improve it furhter.
if (canContinue == true) { string[] names = regKey.GetSubKe yNames(); tvwRegistryKeys .BeginUpdate();
foreach (string key in names) { RegistryKey regSubkey = regKey.OpenSubK ey(path + @"\" + key); TreeNode child = new TreeNode(key);
if (regSubkey.SubK eyCount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
node.Nodes.Add( child); regSubkey.Close (); }
regKey.Close(); } Michael
"Shawn B." <le****@html.co m> schrieb im Newsbeitrag news:OH******** ******@TK2MSFTN GP14.phx.gbl... Money says he's using Nodes.Add() instead of Nodes.AddRange( ). That would be key in this kind of situation.
Yes I am. I'll have to redo the code for AddRange() if its really that much more efficient. My code is very simple, the relevant part is:
if (canContinue == true) { string[] names = regKey.GetSubKe yNames();
tvwRegistryKeys .BeginUpdate();
foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key); TreeNode child = new TreeNode(key);
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
regKey.Close(); node.Nodes.Add( child); }
regKey.Close();
tvwRegistryKeys .EndUpdate(); }
Thanks, Shawn
Works like a champ. Now I'll just have to figure out what I'm doing wrong.
Thanks,
Shawn http://www.zenofdotnet.com
"Jason Newell" <no****@nospam. com> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. . Michael,
If you're interested, I threw together a little C# 2005 regedit program to show you what I'm talking about. I compared it to the Windows regedit and it's slightly slower but nothing like what you described. I don't know that you can get much faster with .NET. Let me know if you have any questions.
You can download the source from my website.
www.jasonnewell.net/public/Examples/Regedit.zip
Jason Newell
Michael Höhne wrote: Hi Shawn,
I agree with Jason that AddRange is preferable, but your problem clearly is different. In your foreach loop you do a call to RegistryKey.Ope nSubKey but don't store the result in any variable:
foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key);
Now that means that the next block will always operate on the same registry key:
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
If this registry key is HKEY_CLASSES_RO OT, then regKey.SubKeyCo unt will take an enormous amount of time to complete and you're calling it over and over.
Try the following and I'm quite sure that your tree is populated in a few seconds. After you've verified that, you should go for AddRange to improve it furhter.
if (canContinue == true) { string[] names = regKey.GetSubKe yNames(); tvwRegistryKeys .BeginUpdate();
foreach (string key in names) { RegistryKey regSubkey = regKey.OpenSubK ey(path + @"\" + key); TreeNode child = new TreeNode(key);
if (regSubkey.SubK eyCount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
node.Nodes.Add( child); regSubkey.Close (); }
regKey.Close(); } Michael
"Shawn B." <le****@html.co m> schrieb im Newsbeitrag news:OH******** ******@TK2MSFTN GP14.phx.gbl...
Money says he's using Nodes.Add() instead of Nodes.AddRange( ). That would be key in this kind of situation.
Yes I am. I'll have to redo the code for AddRange() if its really that much more efficient. My code is very simple, the relevant part is:
if (canContinue == true) { string[] names = regKey.GetSubKe yNames();
tvwRegistryK eys.BeginUpdate ();
foreach (string key in names) { regKey.OpenSubK ey(path + @"\" + key); TreeNode child = new TreeNode(key);
if (regKey.SubKeyC ount > 0) { TreeNode childNode = new TreeNode("*"); child.Nodes.Add (childNode); }
regKey.Close(); node.Nodes.Add( child); }
regKey.Close ();
tvwRegistryK eys.EndUpdate() ; }
Thanks, Shawn
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: lauren quantrell |
last post by:
So many postings on not to use the treeview control, but nothing
recently. Is it safe to swim there yet with Access 2000-Access 2003?
|
by: SoKool |
last post by:
Can anyone point me to a site where I can get a free treeview control to use in ASP .NET or any tutorial that can help me build my own treeview control.
I intend to use a treeview to generate a dynamic menu by collating data from a Sql Server Table.
Many thanks.
|
by: Steve Teeples |
last post by:
Is there a way to pull up a windows registry editor within the propertygrid?
I only want to look at the keys and values, not change them.
--
Steve
|
by: Peter |
last post by:
Hello,
We are inserting a side menu to our application using a class that is
writing HTML on all our pages. This is a part of the code as an
example:
writer.Write(" <table WIDTH=""100%"" BORDER=""0"" CELLSPACING=""0""
CELLPADDING=""0"" ID=""Table1""> " & vbNewLine)
writer.Write(" <tr>" & vbNewLine)
writer.Write(" <td>" & vbNewLine)
|
by: L.M |
last post by:
Hello,
I knew how to use the treeview under VB6. After migrating to .NET, well, I'm
lost.
I try to add a new node, either to the same level or as a child to a
selected node in the treeview.
However, either it only add it to the root level or it only add it on level
below, doesn't matter what I select. And in some case, I just get an
exception.
| |
by: Mr.D |
last post by:
How do I save/load the contents of a Treeview to a file?
I have found several good examples written i VB6, but not a single one for
VB.NET.
Please help.
----
Tim
|
by: Matt MacDonald |
last post by:
Hi All,
I have a form that displays hierarchical categories in a treeview. Ok so
far so good. What I was to do is have users be able to select a node in the
treeview as part of filling out the form. I only want to allow single
selection, so using checkboxes is out of the question. It works as is, but
it makes the form very cumbersome if every time that a user selects a node,
the whole page has to reload. Is there a way to have a node...
|
by: eSolTec, Inc. 501(c)(3) |
last post by:
Thank you in advance for any and all assistance, it is GREATLY appreciated.
I'm wondering if there is a way to duplicate a function in regedit of find
and find next for keywords programmatically, then to list them in a treeview
or listbox?
If so, could someone point me to some code?
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
|
by: ross m. greenberg |
last post by:
I'm trying to emulate the look and feel of "RegEdit" under Visual Basic/VB.Net using Visual Studio 2005.
Can anybody give me a pointer in the right direction: for example, what name spaces must I import, and what methods are available to me?
Thanks!
Ross
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |