Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As LongPrivate Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Boolean End Type Const HKEY_CLASSES_ROOT = &H80000000 Const REG_SZ = 1 Const KEY_ALL_ACCESS = &H3F Public Sub AsProgram(FileType As String) Dim retval As Long Dim Result As Long Dim SA As SECURITY_ATTRIBUTES Dim sPath As String
retval = RegCreateKeyEx(HKEY_CLASSES_ROOT, App.Title, 0, vbNullString, 0, KEY_ALL_ACCESS, SA, Result, &H1) RegSetValueEx Result, "", 0, REG_SZ, ByVal App.Title, Len(App.Title)
retval = RegCreateKeyEx(HKEY_CLASSES_ROOT, FileType, 0, vbNullString, 0, KEY_ALL_ACCESS, SA, Result, &H1) RegSetValueEx Result, "", 0, REG_SZ, ByVal App.Title, Len(App.Title)
If Right(App.Path, 1) = "\" Then sPath = App.Path & App.EXEName & ".exe %1" Else sPath = App.Path & "\" & App.EXEName & ".exe %1" End If
retval = RegCreateKeyEx(HKEY_CLASSES_ROOT, App.Title & "\shell\open\command", 0, vbNullString, 0, KEY_ALL_ACCESS, SA, Result, &H1) RegSetValueEx Result, "", 0, REG_SZ, ByVal sPath, Len(sPath) End Sub Использование:
AsProgram ".doc"
Ответить
|