Public Function CreateFileType(Expanding As String, Class As String, _
Icon As String, Explain As String, Shell As String, _
Command As String, ShellNew As Boolean, Optional Overlay = False) As Boolean
'文件类型
Dim cr As Boolean
cr = RegCreateKey(HKEY_CLASSES_ROOT, Expanding) '.txt
If cr = False And Overlay = False Then GoTo ne '主键存在并不覆盖
If ShellNew Then
RegCreateKey HKEY_CLASSES_ROOT, Expanding & "\ShellNew" '新建
RegSetValue HKEY_CLASSES_ROOT, Expanding & "\ShellNew", "NullFile", REG_SZ, ""
End If
cr = RegCreateKey(HKEY_CLASSES_ROOT, Class) 'txtfile
If cr = False And Overlay = False Then GoTo ne '主键存在并不覆盖
cr = RegCreateKey(HKEY_CLASSES_ROOT, Class & "\DefaultIcon")
cr = RegCreateKey(HKEY_CLASSES_ROOT, Class & "\shell")
cr = RegCreateKey(HKEY_CLASSES_ROOT, Class & "\shell\" & Shell) 'open
cr = RegCreateKey(HKEY_CLASSES_ROOT, Class & "\shell\" & Shell & "\command")
RegSetValue HKEY_CLASSES_ROOT, Expanding, "", REG_SZ, Class 'txtfile
RegSetValue HKEY_CLASSES_ROOT, Class, "", REG_SZ, Explain '文本文件
RegSetValue HKEY_CLASSES_ROOT, Class & "\DefaultIcon", "", REG_SZ, Icon 'a.ico
RegSetValue HKEY_CLASSES_ROOT, Class & "\shell\" & Shell & "\command", "", REG_SZ, Command 'explorer.exe %1
CreateFileType = True
Exit Function
ne:
CreateFileType = False
End Function