My.Computer.Registry 物件會提供存取登錄的屬性和方法。

'建立登錄機碼 (Registry Key) 並設定其值
My.Computer.Registry.CurrentUser.CreateSubKey("ApMyTestKey")
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\ApMyTestKey", "MyTestKeyValue", "This is a test value.")

'判斷登錄機碼是否存在值 (讀取登錄機碼的值)
If My.Computer.Registry.GetValue("HKEY_CURRENT_USER\ApMyTestKey", "MyTestKeyValue", Nothing) Is Nothing Then
            MsgBox("Value does not exist.")
Else
            '刪除登錄機碼
            My.Computer.Registry.CurrentUser.DeleteSubKey("ApMyTestKey")
End If

所建立登錄機碼是位在 HKEY_CURRENT_USER 之下。

100224--1.jpg

 

請參考:

[MSDN] 一般登錄工作

arrow
arrow
    全站熱搜

    tsuozoe 發表在 痞客邦 留言(0) 人氣()