|
There are a few things wrong with this code that would be answered if you look at the MSDN documentation[^].
First of all, to retrieve the unnamed value (which is displayed in the registry editor as the string "(Default)", you need to use either a null reference (Nothing in Visual Basic) or the empty string ("") for name (the first parameter).
Second, the GetValue method actually returns an object, so you should cast the result to a string.
Third, registry access makes use of unmanaged resources, so you should dispose/close the keys when you are done with them.
Fourth, you should probably be doing culture aware, case insensitive string comparisons.
You're code should look something like this:
using (RegistryKey rk = Registry.ClassesRoot.OpenSubKey("Directory\\Background\\shellex\\ContextMenuHandlers", false))
{
string aticcc = (string)rk.GetValue(String.Empty, "Not Installed");
if (String.Compare(aticcc, "Not Installed", StringComparison.CurrentCultureIgnoreCase) == 0)
ultraGroupBoxDisplayRightClickTwoChildOne.Enabled = false;
}
|
|
|
|
|
string aticcc = rk.GetValue("(Default)", "Not Installed");
Shwam a .ToString() at the end:
string aticcc = rk.GetValue("(Default)", "Not Installed").ToString();
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Hi,
Sorry, I seem to have confused things a tad here.
I'll try again. I am wanting to see if the key ACE exists under HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers.
If this ACE key does not exist, then I want to to something, otherwise, something else is done.
Would I have to get a array/list of Keys under HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers, the enumerate through them to see if any are ACE and if so, do something etc.
Any help is appreciated.
Thanks, Andrew.
|
|
|
|
|
andyr2005 wrote: I am wanting to see if the key ACE exists under HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers
Is ACE an actual key (meaning it shows up in the left tree of regedit) or is it a value under the HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers key (meaning it shows up in the list on the right side of regedit)?
|
|
|
|
|
Hi,
ACE is actually a Sub Key on the left in Regedit, when a user has installed the ATI Catalyst Control Center, as discussed here[^].
Any further help is appreciated.
Thanks, Andrew.
|
|
|
|
|
Since ACE is a subkey, you should be able to do this:
RegistryKey rk = Registry.ClassesRoot.OpenSubKey(@"Directory\Background\shellex\ContextMenuHandlers\ACE", false); If the key doesn't exist, rk will be null .
|
|
|
|
|
Scott Dorman wrote: Since ACE is a subkey, you should be able to do this:
RegistryKey rk = Registry.ClassesRoot.OpenSubKey(@"Directory\Background\shellex\ContextMenuHandlers\ACE", false);
If the key doesn't exist, rk will be null.
Thanks, it worked >
|
|
|
|
|
You're welcome. Glad you got it working.
|
|
|
|
|
I copied a piece of sample code dealing with cookies from MS site here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetHttpWebRequestClassCookieContainerTopic.asp
But this code doesn't work for some reason, no matter which URL I use, there is no cookies come back. Am I insane or what? Here is my code:
string L_URL = @"http://www.yahoo.com"; //@"http://www.amazon.com";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(L_URL);
request.CookieContainer = new CookieContainer();
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
response.Cookies = request.CookieContainer.GetCookies(request.RequestUri);
//this line always return 0
MessageBox.Show(response.Cookies.Count.ToString());
This is such a straight forward piece of sample code from microsoft, anyone can tell me what is wrong with it?
|
|
|
|
|
The cookies from the server is in the response, not the request.
---
single minded; short sighted; long gone;
|
|
|
|
|
CookieContainer from request object suppose to hold all the cookies from response, besides I checked the response object in run time and the cookies is empty too.
|
|
|
|
|
atj885 wrote: CookieContainer from request object suppose to hold all the cookies from response
Why do you think that?
From MSDN Library:
"CookieContainer is a null reference (Nothing in Visual Basic) by default. You must assign a CookieContainer object to the property to have cookies returned in the Cookies property of the HttpWebResponse returned by the GetResponse method."
atj885 wrote: I checked the response object in run time and the cookies is empty too.
Then the site didn't set any cookies. Try another site, now that you know where to look for the cookies.
---
single minded; short sighted; long gone;
|
|
|
|
|
Stop quoting facts at people. It only confuses them.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Don't you see I assign a New object to cookie container on the second line?
request.CookieContainer = new CookieContainer();
Both Yahoo and Amazon send cookies back for sure, if you don't know the subject, please don't comment and waste both of our time. Besides this is the exact code from microsoft site, any one have experience?
|
|
|
|
|
atj885 wrote: Don't you see I assign a New object to cookie container on the second line?
request.CookieContainer = new CookieContainer();
Yes, I see that. You put the CookieContainer in the request object. The cookies that the server sets are returned in the response object. I have already told you this twice.
atj885 wrote: if you don't know the subject, please don't comment and waste both of our time.
I know the subject, but I really feel that I am wasting my time. It's like talking to a wall. A very ungrateful wall.
atj885 wrote: Besides this is the exact code from microsoft site
Where? If it really is, then they have really screwed up.
Here is the page in MSDN Library where you can find the text that I quoted earlier:
MSDN Library: CookieContainer property[^]
Take a look at the example code on the page. Notice how they read the cookie values from the response object, not the request object.
---
single minded; short sighted; long gone;
|
|
|
|
|
Here is the code from MSDN libarary form your link:
if (args == null || args.Length != 1)
{
Console.WriteLine("Specify the URL to receive the request.");
Environment.Exit(1);
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(args[0]);
request.CookieContainer = new CookieContainer();
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
//response.Cookies = request.CookieContainer.GetCookies(request.RequestUri);
// Print the properties of each cookie.
foreach (Cookie cook in response.Cookies)
{
....
}
Here is my code:
string L_URL = "http://www.amazon.com"
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(L_URL);
request.CookieContainer = new CookieContainer();
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
//response.Cookies = request.CookieContainer.GetCookies(request.RequestUri);
//This always return 0
MessageBox.show(response.Cookies.count.ToString());
Tell me what's the difference? The line I commented out does not make any difference.
Can you copy this code to a simple window project and try yourself, and tell me you got
the cookies count > 0? no matter from the request or response object, it is always 0. You may change the URL to any site, Amazon.com is the one I am 100% sure they return cookies.
|
|
|
|
|
Now you are getting the cookies from the response object, which is correct.
I copied your code, made the neccesary corrections to make it compile, and ran it. Amazon returns one cookie.
---
single minded; short sighted; long gone;
|
|
|
|
|
I'll 5 you for solving the problem of the ungrateful little troll.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all,
I'm trying to create a custom Wizard that generate C# project.
Can I use the C++ custom project? Or is there other way to do it in C#?
Any information may be helpful
Thanks
|
|
|
|
|
Check out this[^]. There is a link to a VS2005 version in the comments.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi,
I am using CD_ripper where cd insertion removal events fires successfully on
Win XP and Win2K but it is not working on vista. Please can any one guide me.
Thanks
Sumedh
|
|
|
|
|
hi , im working on a script writing program which highlights certain words in the text.
i use the RichTextBox control and it's property selectioncolor in order to apply a color to the text. the problem is that the selection of the text changes the value of the scroll bars and it causes the scroll bar to jump. so my question is : how can i get/set the value of the scroll bar of the richtextbox control?
or if someone has a alternative solution for my problem.
sorry for any english mistakes.
:P
|
|
|
|
|
Hi all,
I tried to write a mail queuer with C#.
At the Mail Sending step, I am using smtpClient.Send(mailMessage) call.
The call is not throwing exception.
The application is made to wait by a Console.Read() call after sending all the mails in a loop. [I have tried with 10, 100, 2500 mails at different shots]
But 100% of the mails I have sent do not reach my mailbox when the application waits at the Console.Read().
However, as soon as I hit enter, all the pending mails are sent.
But I need this app to run on a webserver. While testing the same code as WebService, I had to restart the server [ASP.NET Development Server] to send those pending mails.
Now I am at a fix, because my smtpClient.Send() methods are fired nicely without any exception, but probably the mails are queued at some other end, which I don't know how to flush.
Please help.
Thanks in advance.
Deb
|
|
|
|
|
Try using the async version of the Read method. And you should also treat the SendCompleted event. It's better using the async version because your application doesn't hang while the mails are being sent.
Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Hi,
Thanks for the reply.
"Try using the async version of the Read method." -- I hope you meant SendAsync method.
I have already tried with the SendAsync method, and handled the callback.
But it was of no help. So I have implemented another part of the application with asynchronous delegate invoke, to release the caller/client instantly, while the Send operation part is synchronous.
I think either the Framework, or the OS is maintaining a buffer somewhere, which is getting flushed when the process terminates. However this is what I think, and I can't solve this problem right now.
Thanks,
Deb
|
|
|
|