如何制作我们自己的文件类型

How to make our own file type

我想知道我们能否创建一个带有扩展名和我们自己的图标的自己的文件类型,例如
当我单击一个按钮时,它会将文本框中的数据保存为 check.myextension .

        Dim writer As System.IO.StreamWriter = System.IO.File.CreateText("check.myextension ")
        Timer1.Stop()
        writer.Write(ControlChars.Quote)
        writer.Write(GlobalVariables.string)
        writer.Write(ControlChars.Quote)
        writer.Write(",")
        writer.Write(ControlChars.Quote)
        writer.Write(GlobalVariables.var)
        writer.Write(ControlChars.Quote)

这是有效的,我可以使用它加载它

    Dim reader As System.IO.StreamReader = System.IO.File.OpenText("check.myextension")
    Timer1.Stop()
    Dim contents As String = reader.ReadToEnd
    reader.Close()

    Dim items() As String = contents.Split(",")
    GlobalVariables.string = items(0).Replace(ControlChars.Quote, String.Empty)
    GlobalVariables.var= items(1).Replace(ControlChars.Quote, String.Empty)

这些都可以正常工作,但我想为其添加图标和文件类型描述,我该怎么做?如果有人知道请告诉我... Visual Basic .net 形式 我不知道 c#,c++。
Example image

您需要在注册表中注册新的文件类型

这应该让你开始:

Dim rk As RegistryKey
Dim path As String
path = Application.StartupPath & "\myextension.ico"
rk = Registry.ClassesRoot.CreateSubKey(".myentension\DefaultIcon")
rk.SetValue("DefaultIcon", path)