|
first tell me what is infrgistics UltraWinGrid control
|
|
|
|
|
Its a good tool to work on. It got various options in the grid more than the traditional Microsoft Gird control. Karthick now tell me how to achieve my task..
|
|
|
|
|
Hi,
I am wondering is there a way to check if a specific key exists in the registry, to perform certain task if it does, and does not.
Thanks, Andrew.
|
|
|
|
|
Try looking at the functions in the Microsoft.Win32.Registry class.
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Use the Registry.GetValue method to get the value. From the return value you can determine if the key existed or not.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
Sorry, I didn't explain myself very well, so here gooes:
RegistryKey rk = Registry.ClassesRoot.OpenSubKey("Directory\\Background\\shellex\\ContextMenuHandlers", false);<br />
string aticcc = rk.GetValue("(Default)", "Not Installed");<br />
if (aticcc == "Not Installed")<br />
ultraGroupBoxDisplayRightClickTwoChildOne.Enabled = false;
I get the following error when compiling:
Error 1 Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?) C:\Users\Andrew\Documents\Visual Studio 2005\Projects\AR Utilities\Tweak Master\frmMain.cs 137 29 Tweak Master
Thanks, Andrew.
|
|
|
|
|
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
|
|
|
|