|
try will obviously do it. Otherwise, break down your registry code so that you check that you find a key, for example, before looking for a subkey or value.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am relatively new to vb.net and c#, do you know of any source that could help me do the above??
|
|
|
|
|
Take your existing code, and break it down. Every part that has a return value, take it and check it for Nothing ( null in C# ) before using it in the next step. If you post your line of code, I'll show you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
k what I first did was:
Dim rk as RegistryKey = {Key Goes Here}
Dim value as rk.GetValue("Value To Get")
Now i would normally do this before showing the form. So i would put this above the Windows Designer Code.
I think that might be where my problem is, but am unsure what other code to use. I use vb.net but may try and move to c++ or c#, as I need to be able to access hardware.
|
|
|
|
|
andyr2005 wrote:
Dim rk as RegistryKey = {Key Goes Here}
if rk is not nothing
Dim value as rk.GetValue("Value To Get")
end if
something like that ( I don't do VB ). Your problem is that rk is nothing, because the key is not there, and you're trying to access it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
So if i do something on the form load like
Try
Dim rk as RegistryKey = {Key Goes Here}
if rk is not nothing
then
Do something
elsedim value as rk.getvalue(value to get)
end if
would i be heading in the right direction?
|
|
|
|
|
Yes, your core problem would be that 'value' is scoped inside the if/else, so if you use it outside, declare it before the if/else so it's in scope.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
dim value as byte()
Try
Dim rk as RegistryKey = {Key Goes Here}
if rk is not nothing
then
Do something
else
byte = rk.getvalue(value to get)
end if
Better??
|
|
|
|
|
It's backwards. Remove the not
dim value as byte()
Try
Dim rk as RegistryKey = {Key Goes Here}
if rk is nothing
then
Do something
else
byte = rk.getvalue(value to get)
end if
If it's NOT nothing, then you can use it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Cheers for that.
When I read a value that is binary, i cant out put to a label, but is it possible to check the value against 5 or 6 others and set a list box value depending on the outcome?
|
|
|
|
|
andyr2005 wrote:
When I read a value that is binary, i cant out put to a label, but is it possible to check the value against 5 or 6 others and set a list box value depending on the outcome?
I'm not sure what you're asking ? A binary value is a bool, or do you mean a value that is data other than a string ? You can certainly compare a value to a collection of values, if they are all of the same type or there is an acceptable conversion.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
K for example i read a value which is 'REG_BINARY' and the value can be 01 28 00 08 or 01 00 40 0a. I need to compare the current value to like a list of available values that can be set. Now if i need to convert, that is the part that i will definetly get lost in.
|
|
|
|
|
What sort of variable are you storing that in ? It looks like a byte [] to me.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i just used byte as an example, am not sure what to store it in
|
|
|
|
|
OK, well it looks like a byte [] to me, not sure how else you're store it. But if it's in the registry, the registry API will assign a return type. Whatever it is, store your values to compare as the same type, then you can compare them.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Cheers for the help, i use the following code now which works:
Try
audiospeakersrightclick = Registry.CurrentUser.OpenSubKey("SOFTWARE\NVIDIA Corporation\NvMixer\Profiles", True)
If audiospeakersrightclick Is Nothing Then
combospeaker1.SelectedIndex = 0
combospeaker2.SelectedIndex = 0
audiospeakers.CreateSubKey("Profiles")
End If
Catch ex As Exception
End Try
Many thanks again.
|
|
|
|
|
k sorry bout this but I am having the same problem when reading binary values from the registry. Here's the code I am attempting to use:
Dim showadvanced, showfirewall As Byte
Try
nvmixersettings = audiospeakers.OpenSubKey("Settings", True)
showadvanced = nvmixersettings.GetValue("ShowAdvanced")
showfirewall = nvmixersettings.GetValue("ShowFirewall")
If showfirewall = Nothing Then
soundstormadvancedenable.Checked = False
soundstormadvanceddisable.Checked = True
soundstormfirewallenable.Enabled = False
soundstormfirewalldisable.Enabled = False
GroupControl13.Visible = True
End If
If showfirewall = 10000000 Then
soundstormadvancedenable.Checked = True
soundstormadvanceddisable.Checked = False
soundstormfirewallenable.Enabled = True
soundstormfirewallenable.Enabled = True
GroupControl13.Visible = False
End If
Catch ex As Exception
End Try
Now i have tried to Declare the variable type to string and byte and still no good, any other ideas??
|
|
|
|
|
Hi, how can I use MS Scan Wizard in my app?
Can I use and assign parameters to it?
Thanks
|
|
|
|
|
hellow to all ..
i am trying to chain a textbox name ,
i is integer ..
like textbox&"i"&.text
how can i do it ?
|
|
|
|
|
Wow - that's bizarre. To do that, you need to build the string first, then use reflection to turn it into a textbox instance. The neater way would be to build a hash table of indexes to textboxes. Oh, and if you put i in quotes, you get i, not i as an integer variable value.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
that's cool ...
i can do this with assembler in 30sec !
|
|
|
|
|
I keep getting the following error when trying to delete a row from a dataset using a datagrid (specifically the last row in the datagrid) :
An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of an object.
Any ideas?
I know the err could be caused by a lot of things but..
Why just the last row?
If I start deleting records from the top, I can even delete the last row...but not just the last row ..
|
|
|
|
|
It would help to see the code...
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have written an application in VB.Net to be run in Windows CE. In it I have a combo box that is populated with numbers representing items that the user will select and use and are then removed from the list. Specifically, a file is maintained with all the numbers that could be in it and a flag is set that tells the program whether a particular number has been used or not. Every time we return to the screen with the combo box on it, it is repopulated.
When we get down to having only 3 selections or less available, the combo box opens when the down arrow is clicked and immediatley closes before a selection can be made.
Any suggestions as to how to correct this problem?
Also, the point at which this problem occurs changes when certain things are changed about the combo box. For example:
The font for the combo box is 9pt currently. If I change it to 12pt, the problem doesn't occur until we get down to only 2 items in the list.
I also moved the box to a different location on the screen and it started occurring with 4 items left.
Any help would be appreciated.
Thanks,
Tromba99
|
|
|
|
|
is there any way to, when adding subitems, to skip over a collum and put data in another. Say for example you have 6 collums and you already have data in the first 2 collums and want to skip the 3 and put data in every collums after 3. how would you do this?????
Check out my websites:
BugTrak Project Home
The New Space
The Simple Read
FeedMonster HomeFeedMonster --- The world's best free RSS feed reader....well..maybe not the best, but pretty darn close! (Beta 3 available soon!)
|
|
|
|