Пример как добавлять свои пункты в меню проводника.
Для использования запустить один раз, для удаления пунктов меню запустить из командной строки с параметром 0
- Код: Выделить всё
#Compile Exe
#Dim All
#Include "Win32Api.Inc"
$AppName = "Register Dll Server"
$AppName2 = "UnRegister Dll Server"
Function ExeName() As String
Local FileName As Asciiz * %Max_Path
Local FileNameLen As Long
FileNameLen = GetModuleFileName(ByVal %NULL, FileName, %Max_Path)
Function = Left$(FileName, FileNameLen)
End Function
Function Extension(ByVal SHELL_EXT As Long) As Long
Local KeyPrefix As String
Local hKey As Dword
Local RetVal As Long
Local szKeyValue As Asciiz * %MAX_PATH
Local szKeyData As Asciiz * %MAX_PATH
KeyPrefix = "ocxfile"
If SHELL_EXT=1 Then
RegCreateKeyEx(%HKEY_CLASSES_ROOT, KeyPrefix & "\Shell\" & $AppName & "\Command", _
ByVal %NULL, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, _
ByVal %NULL, hKey, RetVal)
szKeyValue = ""
szKeyData = $Dq & ExeName & $Dq & " %L"
RegSetValueEx hKey, szKeyValue, ByVal %NULL, %REG_SZ, szKeyData, Len(szKeyData)
RegCloseKey hKey
RegCreateKeyEx(%HKEY_CLASSES_ROOT, KeyPrefix & "\Shell\" & $AppName2 & "\Command", _
ByVal %NULL, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, _
ByVal %NULL, hKey, RetVal)
szKeyValue = ""
szKeyData = $Dq & ExeName & $Dq & " %L -u"
RegSetValueEx hKey, szKeyValue, ByVal %NULL, %REG_SZ, szKeyData, Len(szKeyData)
RegCloseKey hKey
Else
RegCreateKeyEx(%HKEY_CLASSES_ROOT, KeyPrefix & "\Shell\" & $AppName & "\Command", _
ByVal %NULL, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, _
ByVal %NULL, hKey, RetVal)
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName & "\command"
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName
RegCloseKey hKey
RegCreateKeyEx(%HKEY_CLASSES_ROOT, KeyPrefix & "\Shell\" & $AppName2 & "\Command", _
ByVal %NULL, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, _
ByVal %NULL, hKey, RetVal)
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName2 & "\command"
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName2
RegCloseKey hKey
End If
KeyPrefix = "dllfile"
If SHELL_EXT=1 Then
RegCreateKeyEx(%HKEY_CLASSES_ROOT, KeyPrefix & "\Shell\" & $AppName & "\Command", _
ByVal %NULL, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, _
ByVal %NULL, hKey, RetVal)
szKeyValue = ""
szKeyData = $Dq & ExeName & $Dq & " %L"
RegSetValueEx hKey, szKeyValue, ByVal %NULL, %REG_SZ, szKeyData, Len(szKeyData)
RegCloseKey hKey
RegCreateKeyEx(%HKEY_CLASSES_ROOT, KeyPrefix & "\Shell\" & $AppName2 & "\Command", _
ByVal %NULL, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, _
ByVal %NULL, hKey, RetVal)
szKeyValue = ""
szKeyData = $Dq & ExeName & $Dq & " %L -u"
RegSetValueEx hKey, szKeyValue, ByVal %NULL, %REG_SZ, szKeyData, Len(szKeyData)
RegCloseKey hKey
Else
RegCreateKeyEx(%HKEY_CLASSES_ROOT, KeyPrefix & "\Shell\" & $AppName & "\Command", _
ByVal %NULL, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, _
ByVal %NULL, hKey, RetVal)
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName & "\command"
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName
RegCloseKey hKey
RegCreateKeyEx(%HKEY_CLASSES_ROOT, KeyPrefix & "\Shell\" & $AppName2 & "\Command", _
ByVal %NULL, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, _
ByVal %NULL, hKey, RetVal)
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName2 & "\command"
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName2
RegCloseKey hKey
End If
End Function
Function PBMain()
Local cstr As String
Extension 1
Select Case Trim$(Command$)
Case "0"
Extension 0
Exit Function
Case ""
Exit Function
End Select
cstr=Trim$(Command$)
If Mid$(cstr, Len(cstr)-1,2)="-u" Then
cstr=Mid$(cstr,1,Len(cstr)-2)
Shell "regsvr32.exe /u " & Chr$(34) & cstr & Chr$(34)
Else
Shell "regsvr32.exe " & Chr$(34) & cstr & Chr$(34)
End If
End Function