Option Explicit On
Option Strict On
Imports Microsoft.Win32
Imports System.IO
Public Class Form1
Private WithEvents Button1 As Button
Private WithEvents Button2 As Button
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Button1 = New Button With {.Text = "アイコン登録",
.Location = New Point(10, 10),
.Size = New Size(100, 30)}
Me.Button2 = New Button With {.Text = "アイコン登録解除",
.Location = New Point(10, 60),
.Size = New Size(100, 30)}
Me.Controls.AddRange({Button1, Button2})
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Ext As String = ".nau"
Dim FileType As String = "NetCommonsAutoUploader.0"
Dim Description As String = "NetCommons簡単記事作成&自動アップローダー"
Dim IconPath As String = Path.Combine(Application.StartupPath, "nau.ico")
Dim IconIndex As Integer = 0
Using RootKey As RegistryKey = Registry.ClassesRoot
Using SubKey As RegistryKey = RootKey.CreateSubKey(Ext)
SubKey.SetValue("", FileType)
End Using
Using SubKey As RegistryKey = RootKey.CreateSubKey(FileType)
SubKey.SetValue("", Description)
End Using
Using IconKey As RegistryKey = RootKey.CreateSubKey(FileType & "\DefaultIcon")
IconKey.SetValue("", IconPath & "," & IconIndex.ToString)
End Using
End Using
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim Ext As String = ".nau"
Dim FileType As String = "NetCommonsAutoUploader.0"
Using RootKey As RegistryKey = Registry.ClassesRoot
RootKey.DeleteSubKeyTree(Ext, False)
RootKey.DeleteSubKeyTree(FileType, False)
End Using
End Sub
End Class