|
There are actually two separate problems here.
1) You're using the RegistryKey from the OpenRemoteBaseKey call to get the value of the subkey when the OpenSubKey returned the RegistryKey you need to use.
2) You need to specify permissions (using the RegistryPermission class) to work with the remote registry.
Here's a quick example I just typed up and ran on my home network. Obviously, you'll need to change your machine name:
using System;
using Microsoft.Win32;
using System.Security.Permissions;
namespace RegExlorer
{
class RegExplorer
{
public static void Main()
{
try
{
RegistryPermission f = new RegistryPermission(
RegistryPermissionAccess.Read,
"\\cosette\\HKEY_CURRENT_USER\\Volatile Environment\\0");
RegistryKey remoteUserHive;
RegistryKey volatileEnvKey;
object myObj;
remoteUserHive = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentUser, "COSETTE");
if (remoteUserHive != null)
{
volatileEnvKey = remoteUserHive.OpenSubKey("Volatile Environment");
if (volatileEnvKey != null)
{
myObj = volatileEnvKey.GetValue("LOGONSERVER");
Console.WriteLine(myObj.ToString());
}
}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}
}
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Further testing seems to indicate that the permissions is not needed and that your only problem was not using the RegistryKey returned from the GetSubKey method. You might want to play around with this, but this code works and should get you pointed in the right direction.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Thanks for the swift reply Tom the code that you have provided me worked.
-Koby
P.S.: I just ordered a copy of your book
|
|
|
|
|
Very cool on both issues
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
I want to convert a colored bitmap to a Grayscaled one...
so we wonder if there is function doing this in C#....
Thanks in advance..
|
|
|
|
|
Yes, I've written a series of articles on image processing in C#, the first one has a greyscale function.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Well, I finally got the C# books that were recommended by CP users (or maybe I should say book). I bought "Inside C#" by Tom Archer, and "C# and the .NET Platform, by Andrew Troelsen. The second book was supposed to Charles Petzold's latest. Could anyone give me a comparison on what they thought between Charles Petzold and Andrew Troelson? I'm not sure if it's worth returning the book and getting the one that I was supposed to.
TIA
Mark Donkers
A witty saying proves nothing.
-- Voltaire
|
|
|
|
|
They are totally different - C# and the .NET platform is a whirlwind tour of C# and .NET, and the Petzold book covers in depth GDI+ and all the aspects of writing client apps in C#. I'd return it, you're going to have heaps of double up with Tom's book.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
I was afraid of that Hopefully returning it won't be too painful. Thanks for the help Christian.
Mark Donkers
A witty saying proves nothing.
-- Voltaire
|
|
|
|
|
Mark, did you get my first or second edition?
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Tom,
I got the second edition. I haven't had a chance to get into yet I just got off work so I'm going to take a nap, then put on some java and start readin'.
Mark
Mark Donkers
A witty saying proves nothing.
-- Voltaire
|
|
|
|
|
Mark Donkers wrote:
I got the second edition
Cool! I just wanted to make sure you got the latest and greatest.
Mark Donkers wrote:
...then put on some java...
You trying to be funny, Mark?
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Tom Archer wrote:
Mark Donkers wrote:
...then put on some java...
You trying to be funny, Mark?
You caught that one. I can C you're quite #.
MD
Mark Donkers
A witty saying proves nothing.
-- Voltaire
|
|
|
|
|
Oh Mark. You are tired. Get some sleep, mate
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
By the way, in conjunction with what Christian said, since both Charles and I write for MS Press, our books are intentionally designed to complement one another. This is why he only has a few pages on C# syntax (while that is almost my entire book) and I don't cover GDI+ at all (where that's the focus of his book). That way, there is little to no overlap. In addition, to mine and Charles' books, you will definitely want to get Jeffrey Richter's book as it goes into a lot of detail with regards to the .NET runtime.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
By the way, Tom, Amazon stitched me up with your book, in that they shipped me the Richter book, but have yet to ship Inside C# 2nd ed ( which frankly was the main one I wanted ). So I don't think they have it to ship yet, I dunno about anyone else though.
I'm sure I'll get it eventually, but I was a bit miffed because I asked them to ship them all at once.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
I hate that when you pay someone to screw up Oh well, you should have it shortly as I just got mine in the post.
Thanks for the support!
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Tom Archer wrote:
Thanks for the support!
Well, I think I'll be thanking *you* for the support shortly. I'm still a little lost C# wise, at least compared to C++.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
I'll be here
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
When I last checked Amazon.co.uk (Tuesday) was still listing the first edition and not the second. I can't wait to get my hands on the second edition too.
Michael
Communication is the first step towards enlightenment.
|
|
|
|
|
Absolutely agree, Jeffrey Richter's book is awesome! Really teaches you an awful lot, I'm quite looking forward to getting my hands of Jeff Prosise's .NET book when its eventually in the shops -- the MFC book had to be the best one I've read particularly when I was first starting with VC++.
Anyone got any kind of insider knowledge about how good it is?
|
|
|
|
|
Can anyone help with this question - i'm trying to trap the MouseWheel event of a scrollbar control placed on a form, and although this doesn't appear as an event at design-time i can create an event at run-time to handle it, ie:
vScrollBar1.MouseWheel += new System.Windows.Forms.MouseEventHandle(WheelEventHandler);
Problem is that this doesn't trap the wheel scroll event at all even although i'm convinced this is how to do it.
I know it ain't a visible event at design time and similarly it's a MouseEventHandler instead of just an EventHandler (used for MouseDown/Hover/Leave etc) and bearing this in mind how do i trap it?
Cheers
Martin D
|
|
|
|
|
Have you tried to override the event?
<code>
protected override void OnMouseWheel(System.Windows.Forms.MouseEventArgs e)
{
MessageBox.Show("I moved the mousewheel");
}
</code>
Nick Parker
|
|
|
|
|
Yeah i've tried overriding it but nothing. I've also tried creating a UserControl (Windows Control Library) and inheriting my class from "System.Windows.Forms.VScrollBar" but this doesn't do anything for the MouseWheel event, although it does seem to work for SystemEventHandlers as i suggested earlier.
Another point to note is that this is only a problem on our Win2000 boxes - we've got an XP box and the original "vScrollBar1.MouseWheel += New etc etc..." works fine on that, even although MSDN suggests Win2000 should be OK as well - a bug....?
Martin D
|
|
|
|
|
OK now for the most bizarre solution of the day....if ur Wheel Settings on Control Panel / Mouse Properties has 'Enable Enhanced Scrolling' checkbox then Uncheck it and hey presto - it works again.
Seems that even although you have to check this to modify the no. of 'scroll by' lines, it has to be Unchecked to allow the scrolling wheel facility in the first place!
Not only does this seem a bit back-to-front but not all mouse devices have them so watch out - also it's not something that can be found by interrogating the SystemInformation options in the code either...
|
|
|
|