Вот такой код, для всех типов файлов, можно добавить пункт меню, а конкретно для .vbp файлов не получается, в чем проблема? Никак не могу понять
- Код: Выделить всё
#Compile Exe '#Win 8.03#
#Register None
#Dim All
#Include "Win32Api.Inc" '#2005-01-14#
$AppName = "Windows Explorer - Right-click"
%LabelCommand = 101
%ButtonDrive = 201
%ButtonFolder = 202
%ButtonFile = 203
%ButtonExe = 204
$ButtonDriveAdd = "Add right-click to ""Windows Explorer"" for drives"
$ButtonDriveClean = "Clean registry for ""Windows Explorer"" with drives"
$ButtonFolderAdd = "Add right-click to ""Windows Explorer"" for folders"
$ButtonFolderClean = "Clean registry for ""Windows Explorer"" with folders"
$ButtonFileAdd = "Add right-click to ""Windows Explorer"" for files"
$ButtonFileClean = "Clean registry for ""Windows Explorer"" with files"
$ButtonExeAdd = "Add right-click to ""Windows Explorer"" for .vbp files"
$ButtonExeClean = "Clean registry for ""Windows Explorer"" with .vbp files"
'______________________________________________________________________________
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
'______________________________________________________________________________
CallBack Function DlgProc
Local TextAdd As String
Local TextClean As String
Local KeyPrefix As String
Local hKey As Dword
Local RetVal As Long
Local szKeyValue As Asciiz * %MAX_PATH
Local szKeyData As Asciiz * %MAX_PATH
Select Case CbMsg
Case %WM_COMMAND
Select Case LoWrd(CbWParam)
Case %ButtonDrive : KeyPrefix = "Drive"
TextAdd = $ButtonDriveAdd
TextClean = $ButtonDriveClean
GoSub RegSet
Case %ButtonFolder : KeyPrefix = "Folder"
TextAdd = $ButtonFolderAdd
TextClean = $ButtonFolderClean
GoSub RegSet
Case %ButtonFile : KeyPrefix = "*" 'All files
TextAdd = $ButtonFileAdd
TextClean = $ButtonFileClean
GoSub RegSet
Case %ButtonExe : KeyPrefix = ".vbp"
TextAdd = $ButtonExeAdd
TextClean = $ButtonExeClean
GoSub RegSet
End Select
End Select
Exit Function
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RegSet:
If RegCreateKeyEx(%HKEY_CLASSES_ROOT, KeyPrefix & "\Shell\" & $AppName & "\Command", _
ByVal %NULL, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, _
ByVal %NULL, hKey, RetVal) = %ERROR_SUCCESS Then
If Retval = %REG_CREATED_NEW_KEY Then 'Nothing found so create it
szKeyValue = ""
szKeyData = $Dq & ExeName & $Dq & " %L"
'%L : Long path, ex: C:\Program Files
'%1 : Short path, ex: c:\progra~1
'%I : Unique ID, need /IDLIST as a flag
'Also any environment variables as %?SystemRoot% or
'%?ProgramFiles% or %UserProfile% or %AllUsersProfile%
RegSetValueEx hKey, szKeyValue, ByVal %NULL, %REG_SZ, szKeyData, Len(szKeyData)
Control Set Text CbHndl, LoWrd(CbWParam), TextClean
Else 'Retval = %REG_OPENED_EXISTING_KEY, already exist so delete it
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName & "\command"
RegDeleteKey %HKEY_CLASSES_ROOT, KeyPrefix & "\shell\" & $AppName
Control Set Text CbHndl, LoWrd(CbWParam), TextAdd
End If
End If
RegCloseKey hKey
Return
'Also: AllFilesystemObjects * Directory exefile drvfile fndfile
'Also: folder hlpfile inifile lnkfile txtfile regfile wrifile
End Function
'______________________________________________________________________________
Function regKeyExist(sKeyName As String)As Long
Local hKey As Dword
If RegOpenKeyEx(%HKEY_CLASSES_ROOT, ByVal StrPtr(sKeyName), _
ByVal %NULL, %KEY_READ, hKey)= %ERROR_SUCCESS Then
RegCloseKey(hKey)
Function = 1 'Key exist
End If
End Function
'______________________________________________________________________________
Function PBMain()
Local hDlg As Dword
Local Buffer As String
Dialog New %HWND_DESKTOP, $AppName, , , 200, 100, %WS_CAPTION Or _
%WS_MINIMIZEBOX Or %WS_SYSMENU, 0 To hDlg
SetClassLong hDlg, %GCL_HICON, LoadIcon(ByVal %NULL, ByVal %IDI_INFORMATION)
Buffer = IIf$(regKeyExist("Drive\Shell\" & $AppName & "\Command"), _
$ButtonDriveClean, $ButtonDriveAdd)
Control Add Button, hDlg, %ButtonDrive, Buffer, 5, 5, 190, 12
Buffer = IIf$(regKeyExist("Folder\Shell\" & $AppName & "\Command"), _
$ButtonFolderClean, $ButtonFolderAdd)
Control Add Button, hDlg, %ButtonFolder, Buffer, 5, 25, 190, 12
Buffer = IIf$(regKeyExist("*\Shell\" & $AppName & "\Command"), _
$ButtonFileClean, $ButtonFileAdd)
Control Add Button, hDlg, %ButtonFile, Buffer, 5, 45, 190, 12
Buffer = IIf$(regKeyExist(".vbp\Shell\" & $AppName & "\Command"), _
$ButtonExeClean, $ButtonExeAdd)
Control Add Button, hDlg, %ButtonExe, Buffer, 5, 65, 190, 12
Control Add Label, hDlg, %LabelCommand, "%L = " & Command$, 5, 83, 190, 17
Dialog Show Modal hDlg Call DlgProc
End Function