Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

You'll want to use the Registry object. For instance, to see if there's a key exists:

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Microsoft2");
if(key==null)
Debug.WriteLine("Key does not exist");
else
Debug.WriteLine("Key does exist");

 

To see if a value exists:

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Microsoft");
if(key!=null)
{
if(key.GetValue("hello")==null)
	Debug.WriteLine("Value does not exist");
else
	Debug.WriteLine("Value does exist");
}

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • Leaders
Posted (edited)

Dim strKey As Microsoft.Win32.RegistryKey
strKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\MSNChat\4.0")
'This retreives the registry key ( just have to add as nessecary to it )

thats just an example of opening a registry key

Edited by dynamic_sysop

Guest mutant
Posted

This should do it.

 

Imports Microsoft.Win32
...
dim key as RegistryKey = Registry.LocalMachine 'Of course you can pick anything 
'instead of Local Machine

'This will delete the subkey and it wont work if you have
'any subkeys to that given subkey.
key.deletesubkey("path to whatever you wish to delete") 

'or

'This will delete that subkey and all subkeys of that subkey
key.deletesubkeytree("path to whatever you wish to delete") 

Guest mutant
Posted
Its easy and its better. Save setting doesnt allow you to choose the location of key i think.
  • Leaders
Posted
SaveSetting doesnt allow you to tell it the location as far as "HKEY_CURRENTUSER" etc..., only allows you to create a named key, in the default place (eg: hkey_currentuser\software\visual basic\YOUR PROGRAMME NAME )

Posted

hmmmm i cant quite get it to work mutant

 

i used this code u gave a while back ago where u save ur app into load up with windows

 

but now i duno how to delete it

 

 

 

heres the saving code

 

 

Dim key As RegistryKey
               Dim subkey As RegistryKey
               key = Registry.LocalMachine
               subkey = key.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run\")
               subkey.SetValue(Application.ProductName, Application.StartupPath & "\Task Schedular.exe")

               Call subkey.Close()
               Call key.Close()

Guest mutant
Posted

You didnt put the slashes in the path.

 

Change the code to:

 

Dim key As RegistryKey
Dim subkey As RegistryKey
key = Registry.LocalMachine
subkey = key.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run\putthenameofapphere")'or whatever you want to call the key
subkey.SetValue(Application.ProductName, Application.StartupPath & "Task Schedular.exe")
subkey.Close()
key.Close()

 

I tried this and it works OK.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...