potrei avere un esempio di come creare una chiave di registro in:
concodice:("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect\")
Imports Microsoft.Win32
potrei avere un esempio di come creare una chiave di registro in:
concodice:("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect\")
Imports Microsoft.Win32
Comincia a guardare questo
http://forum.html.it/forum/showthrea...readid=1041212
ciao oregon,Originariamente inviato da oregon
Comincia a guardare questo
http://forum.html.it/forum/showthrea...readid=1041212
ho letto, ma li si parla di verificare se la chiave esiste, d'accordo... ma il problema resta come creare la chiave?
codice:Dim key As RegistryKey = Registry.LocalMachine.CreateSubKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect\" QUI SUPPONGO IL PERCORSO?) key.SetValue(????, ????)
Beh ... asterix ... pensavo che suggerendoti la classe tu andassi a vedere sull'help quali sono i metodi usati per creare chiavi! La documentazione esiste (MSDN) ... una volta capita qual e' la classe, leggiamola!
Classe RegistryKey
http://msdn2.microsoft.com/it-it/lib...32.registrykey(VS.80).aspx
il problema stà qui,
allora se eseguo:
mi viene creata, ma se cambio:codice:Imports System.Security.Permissions Imports Microsoft.Win32 <Assembly: RegistryPermissionAttribute( _ SecurityAction.RequestMinimum, ViewAndModify:="HKEY_CURRENT_USER")> Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Create a subkey named Test9999 under HKEY_CURRENT_USER. Dim test9999 As RegistryKey = Registry.CurrentUser.CreateSubKey("Test9999") ' Create two subkeys under HKEY_CURRENT_USER\Test9999. test9999.CreateSubKey("TestName").Close() Dim testSettings As RegistryKey = test9999.CreateSubKey("TestSettings") ' Create data for the TestSettings subkey. testSettings.SetValue("Language", "French") testSettings.SetValue("Level", "Intermediate") testSettings.SetValue("ID", 123) testSettings.Close() End Sub
non crea nullacodice:<Assembly: RegistryPermissionAttribute( _ SecurityAction.RequestMinimum, ViewAndModify:="HKEY_CURRENT_USER")> in <Assembly: RegistryPermissionAttribute( _ SecurityAction.RequestMinimum, ViewAndModify:="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect")>
Ma qui va messa solo la radice
SecurityAction.RequestMinimum, ViewAndModify:="HKEY_LOCAL_MACHINE")>
... il resto va scritto nel codice!
allora credo di avere capito il problema:
allora come faccio a puntare incodice:Dim test9999 As RegistryKey = Registry.LocalMachine .CreateSubKey("Test9999")
codice:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect
Con i metodi messi a disposizione ... guarda l'esempio e adattalo ...
OK!
codice:Imports Microsoft.Win32 Imports System.Security.Permissions <Assembly: RegistryPermissionAttribute( _ SecurityAction.RequestMinimum, ViewAndModify:="HKEY_LOCAL_MACHINE")>codice:Dim PDA As RegistryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect") PDA.SetValue("PDA", Application.StartupPath & "\PDA.exe") PDA.Close()
adesso ho il problema inverso,
praticamente voglio eliminare la chiave creata, però credo che sbaglio qualcosa, perchè così elimino tutte la subkey, come faccio a puntare solo a chiave da eliminare?
cioè la chiave "PDA"codice:Registry.LocalMachine.DeleteSubKey("SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect", True)