Shell extension for Windows (Explorer context menu)

Post your FreeBASIC tips and tricks here. Please don’t post your code without including an explanation.
VANYA
Posts: 1522
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Shell extension for Windows (Explorer context menu)

Postby VANYA » May 28, 2015 5:54

Hi all!

This code represents a COM DLL server , which insert a context menu in Windows Explorer. It looks like this:

Image

For registration DLL (if the name dll "FB_CONTEXT"): regsvr32 FB_CONTEXT.dll
For remove registration: regsvr32 /u FB_CONTEXT.dll

Code: Select all

#define _UNICODE
#define ID_SHELLTEST_C 1

#Include Once "windows.bi"
#Include Once "crt.bi"
#Include Once "win/ocidl.bi"
#Include Once "win/shlobj.bi"
#Include Once "win/olectl.bi"

Static Shared CLSIDS_POINT As ZString*2048 = "{9D267B24-B27F-46E1-9062-6FC17716095E}"
Dim Shared  CLSID_POINT As IID=Type(&h9D267B24, &hB27F, &h46E1, {&h90, &h62, &h6F, &hC1, &h77, &h16, &h09, &h5E})

Dim Shared nRefDll As UINT
Dim Shared As Integer nNumberFileSelect
ReDim Shared As ZString*MAX_PATH ArrayFiles()
Dim Shared As IContextMenuVtbl pIContextMenuVtbl
Dim Shared As IShellExtInitVtbl  pIShellExtInitVtbl
extern data_1(0 to 1654-1) as UByte
Dim pBi as BITMAPINFO ptr
Dim Shared bmpMenu as HBITMAP           
Dim pBih as BITMAPFILEHEADER ptr = cast( any ptr, @data_1(0) )
pBi = cast(BITMAPINFO ptr, pBih + 1)
Dim as HDC hdc = GetDC( 0 )
bmpMenu = CreateDIBitmap( hdc, _
                            @pBi->bmiHeader, _
                            CBM_INIT, _
                            cast(byte ptr, pBih) + pBih->bfOffBits, _
                            pBi, _
                            DIB_RGB_COLORS )
ReleaseDC(0,hdc)                           

Type ConText_ClassFactory
   icf         As IClassFactory
   cRef        As Integer
End Type

Type ConTextMenu_Class
   cm As IContextMenu
   si As IShellExtInit
   cRef As Integer
End Type

Function IContextMenu_QueryInterface_(pIm As IContextMenu Ptr, iid As REFIID, ppv As LPVOID Ptr) As HRESULT
   Dim  pThis As ConTextMenu_Class  Ptr
   pThis   = Cast(ConTextMenu_Class  Ptr,pIm)
   If memcmp(iid, @IID_IUnknown, SizeOf(GUID))=0 Or memcmp(iid, @IID_IContextMenu, SizeOf(GUID))=0 Then
      *ppv = pThis
      pThis->cRef+=1
      Return  S_OK
   ElseIf memcmp(iid, @IID_IShellExtInit, SizeOf(GUID))=0 Then
      *ppv = @(pThis->si)
      pThis->cRef+=1
      Return  S_OK
   End If
   ppv = NULL
   Return  E_NOINTERFACE
End Function


Function IContextMenu_AddRef_(pIm As IContextMenu Ptr) As ULong
   Dim   pThis As ConTextMenu_Class  Ptr
   pThis = Cast(ConTextMenu_Class  Ptr,pIm)
   pThis->cRef +=1
   Return  pThis->cRef
End Function


Function IContextMenu_Release_(pIm As IContextMenu Ptr) As ULong
   Dim   pThis As ConTextMenu_Class  Ptr
   pThis = Cast(ConTextMenu_Class  Ptr,pIm)
   pThis->cRef-=1
   If pThis->cRef = 0 Then
      DeAllocate(pIm)
      nRefDll -=1
      Return 0
   End If
   Return pThis->cRef
End Function

Function IContextMenu_QueryContextMenu_( pIm As IContextMenu Ptr, hmenu As HMENU, indexMenu As UInteger, idCmdFirst As UInteger, idCmdLast As UInteger, uFlags As UInteger) As HRESULT
   If (uFlags And CMF_DEFAULTONLY) Then
      Return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,0)
   EndIf
   InsertMenu(hMenu,1, MF_STRING Or MF_BYPOSITION, (idCmdFirst + ID_SHELLTEST_C),("Test item FreebasicShell"))
   SetMenuItemBitmaps(hMenu,1,MF_BITMAP Or MF_BYPOSITION,bmpMenu,bmpMenu)
   Return MAKE_HRESULT(0, FACILITY_NULL, ID_SHELLTEST_C + 1)
End Function


Function IContextMenu_GetCommandString_( pIm As IContextMenu Ptr, idCmd As UInteger, uFlags As UInteger, pwReserved As PUINT, pszName As LPSTR, cchMax As UInteger) As Integer
   Return E_NOTIMPL
End Function

Function IContextMenu_InvokeCommand_( pIm As IContextMenu Ptr, pici As LPCMINVOKECOMMANDINFO) As HRESULT
   Select Case LoWord(pici->lpVerb)
      Case ID_SHELLTEST_C
         Dim As String szValue
         If nNumberFileSelect>=1 Then
            For i As Integer = 0 To nNumberFileSelect-1
               szValue &= (ArrayFiles(i) & !"\r\n" )
            Next
            MessageBox(NULL, szValue ,"Selected files", MB_OK + MB_ICONINFORMATION)
         EndIf
         Return S_OK
      Case Else
         Return E_FAIL
   End Select
End Function

Function  CShellInitExt_QueryInterface_(pThis As IShellExtInit Ptr, riid As REFIID , ppv As LPVOID Ptr) As HRESULT
   Return Cast(IContextMenu Ptr ,pThis - 1)->lpVtbl->QueryInterface(Cast(IContextMenu Ptr ,(pThis - 1)),riid,ppv)
End Function

Function CShellInitExt_AddRef_(pThis As IShellExtInit Ptr)As ULong
   Return Cast(IContextMenu Ptr ,pThis - 1)->lpVtbl->AddRef(Cast(IContextMenu Ptr ,(pThis - 1)))
End Function

Function  CShellInitExt_Release_( pThis As IShellExtInit Ptr) As ULong
   Return Cast(IContextMenu Ptr ,pThis - 1)->lpVtbl->Release(Cast(IContextMenu Ptr ,(pThis - 1)))
End Function

Function CShellInitExt_Initialize_(ByVal pIShell As IShellExtInit Ptr,ByVal pidlFolder As LPCITEMIDLIST,ByVal pdtobj As LPDATAOBJECT, ByVal hkeyProgID As HKEY)As HRESULT
   If pdtobj <>0 Then
      Dim fe As FORMATETC
      fe.cfFormat = CF_HDROP
      fe.dwAspect = DVASPECT_CONTENT
      fe.lindex = -1
      fe.tymed = TYMED_HGLOBAL
      Dim medium As STGMEDIUM

      If pdtobj->lpVtbl->GetData(pdtobj,@fe, @medium)=S_OK Then
         Var uCount = DragQueryFile(medium.hGlobal, -1, 0, 0)
         nNumberFileSelect = uCount
         ReDim As ZString*MAX_PATH ArrayFiles(uCount)
         If uCount>=1 Then
            For dd As Integer=0 To uCount-1
               Dim As ZString*MAX_PATH m_szFile
               DragQueryFile(medium.hGlobal, dd, m_szFile, MAX_PATH)
               If Len(m_szFile)=0 Then
                  uCount = 0
               Else
                  ArrayFiles(dd) = m_szFile
               EndIf
            Next
         EndIf
         ReleaseStgMedium(@medium)
         If uCount>=1 Then
            Return S_OK
         EndIf
      EndIf
   EndIf
   Return S_FALSE
End Function

pIShellExtInitVtbl = Type(@CShellInitExt_QueryInterface_, _
@CShellInitExt_AddRef_, _
@CShellInitExt_Release_, _
@CShellInitExt_Initialize_)

pIContextMenuVtbl = Type(@IContextMenu_QueryInterface_, _
@IContextMenu_AddRef_, _
@IContextMenu_Release_, _
@IContextMenu_QueryContextMenu_ , _
@IContextMenu_InvokeCommand_ , _
@IContextMenu_GetCommandString_ )

Function ClassFactory_CFQueryInterface(pCF As IClassFactory Ptr, iid As REFIID, ppvObject As LPVOID Ptr) As HRESULT
   Dim   pThis As ConText_ClassFactory Ptr
   pThis = Cast(ConText_ClassFactory Ptr,pCF)
   If IsEqualIID( iid, @IID_IUnknown) Or IsEqualIID( iid, @IID_IClassFactory) Then
      *ppvObject = pThis
      pThis->icf.lpVtbl->AddRef(pCF)
      Return  S_OK
   End If
   *ppvObject = NULL
   Return  E_NOINTERFACE
End Function

Function ClassFactory_CFAddRef(pCF As IClassFactory Ptr) As ULong
   Dim   pThis As ConText_ClassFactory Ptr
   pThis = Cast(ConText_ClassFactory Ptr,pCF)
   pThis->cRef +=1
   Return pThis->cRef
End Function

Function  ClassFactory_CFRelease( pCF As IClassFactory Ptr) As ULong
   Dim   pThis As ConText_ClassFactory Ptr
   pThis = Cast(ConText_ClassFactory Ptr,pCF)
   pThis->cRef -=1
   If pThis->cRef = 0 Then
      DeAllocate( pThis )
      pThis = 0
      nRefDll -=1
      Return  0
   End If
   Return pThis->cRef
End Function

Function ClassFactory_CFCreateInstance( pICF As IClassFactory Ptr, pUnkOuter As IUnknown Ptr, riid As REFIID, ppvObject As LPVOID Ptr) As HRESULT
   Dim   pThis As ConText_ClassFactory Ptr
   Dim   pCM As ConTextMenu_Class  Ptr

   pThis = Cast(ConText_ClassFactory Ptr,pICF)
   If pUnkOuter <> NULL Then
      Return  CLASS_E_NOAGGREGATION
   End If

   pCM = Cast(ConTextMenu_Class  Ptr,Callocate(SizeOf(ConTextMenu_Class)))
   If NULL = pCM Then
      Return  E_OUTOFMEMORY
   End If

   pCM->cm.lpVtbl = @pIContextMenuVtbl
   pCM->si.lpVtbl = @pIShellExtInitVtbl
   pCM->cRef = 1
   nRefDll +=1

   Var hr = pCM->cm.lpVtbl->QueryInterface(@(pCM->cm), riid, ppvObject)
   If hr <>  S_OK Then
      Deallocate( pCM )
      Return  E_NOINTERFACE
   End If

   pCM->cm.lpVtbl->Release(@(pCM->cm))
   Return hr
End Function

Function ClassFactory_CFLockServer( pICF As IClassFactory Ptr, fLock As BOOL) As HRESULT
   Return E_NOTIMPL
End Function

Static Shared As IClassFactoryVtbl pIClassFactoryVtbl = Type(@ClassFactory_CFQueryInterface, _
@ClassFactory_CFAddRef, _
@ClassFactory_CFRelease, _
@ClassFactory_CFCreateInstance,  _
@ClassFactory_CFLockServer)

Extern "windows-ms"
#Undef DllRegisterServer
#Undef DllUnregisterServer
Function DllRegisterServer() As Long   Export
   Dim As HKEY hKey1
   If RegCreateKeyEx(HKEY_CLASSES_ROOT, "*\shellex\ContextMenuHandlers\FreeBasicShell", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, Null, @hKey1, 0)<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   RegSetValueEx(hKey1, "", 0, REG_SZ, @"{9D267B24-B27F-46E1-9062-6FC17716095E}", 38)
   If hKey1<>0 Then  RegCloseKey(hKey1):hKey1 = 0
   If RegCreateKeyEx(HKEY_CLASSES_ROOT, "FreeBasicShell\shellex\ContextMenuHandlers", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, Null, @hKey1, 0)<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   RegSetValueEx(hKey1, "", 0, REG_SZ, @"{9D267B24-B27F-46E1-9062-6FC17716095E}", 38)
   If hKey1<>0 Then RegCloseKey(hKey1):hKey1 = 0
   If RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, Null, @hKey1, 0)<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   RegSetValueEx(hKey1, "{9D267B24-B27F-46E1-9062-6FC17716095E}", 0, REG_SZ, @"FreeBasicShell", 15)
   If hKey1<>0 Then RegCloseKey(hKey1):hKey1 = 0
   Dim As ZString*MAX_PATH szBuffer
   Dim As HMODULE hmod
   GetModuleHandleEx(4,Cast(LPSTR,@DllRegisterServer) , @hMod)
   If GetModuleFileName(hMod, szBuffer, MAX_PATH)<>0 Then
      If RegCreateKeyEx(HKEY_CLASSES_ROOT, "CLSID\{9D267B24-B27F-46E1-9062-6FC17716095E}", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, Null, @hKey1, 0)<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
      RegSetValueEx(hKey1, "", 0, REG_SZ, @"FreeBasicShell", 15)
      If hKey1<>0 Then RegCloseKey(hKey1):hKey1 = 0
      If RegCreateKeyEx(HKEY_CLASSES_ROOT, "CLSID\{9D267B24-B27F-46E1-9062-6FC17716095E}\InProcServer32", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, Null, @hKey1, 0)<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
      RegSetValueEx(hKey1, "", 0, REG_SZ, @szBuffer, Len(szBuffer)+1)
      RegSetValueEx(hKey1, "ThreadingModel", 0, REG_SZ, @"Apartment", 10)
      If hKey1<>0 Then RegCloseKey(hKey1):hKey1 = 0
   Else
      Return SELFREG_E_CLASS
   EndIf
   Return S_OK
End Function

Function DllUnregisterServer()As HRESULT  Export
   Dim As HKEY hkey1
   If RegDeleteKey(HKEY_CLASSES_ROOT, "*\shellex\ContextMenuHandlers\FreeBasicShell")<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If RegDeleteKey(HKEY_CLASSES_ROOT, "FreeBasicShell\shellex\ContextMenuHandlers")<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If RegDeleteKey(HKEY_CLASSES_ROOT, "FreeBasicShell\shellex")<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If RegDeleteKey(HKEY_CLASSES_ROOT, "FreeBasicShell")<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", 0, KEY_ALL_ACCESS, @hKey1)<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If RegDeleteValue(hKey1, "{9D267B24-B27F-46E1-9062-6FC17716095E}")<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If hKey1<>0 Then RegCloseKey(hKey1):hKey1 = 0
   If RegOpenKeyEx(HKEY_CLASSES_ROOT, "CLSID\{9D267B24-B27F-46E1-9062-6FC17716095E}", 0, KEY_ALL_ACCESS, @hKey1)<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If RegDeleteKey(hKey1, "InProcServer32")<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If hKey1<>0 Then RegCloseKey(hKey1):hKey1 = 0
   If RegOpenKeyEx(HKEY_CLASSES_ROOT, "CLSID", 0, KEY_ALL_ACCESS, @hKey1)<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If RegDeleteKey(hKey1, "{9D267B24-B27F-46E1-9062-6FC17716095E}")<>ERROR_SUCCESS Then Return SELFREG_E_CLASS
   If hKey1<>0 Then RegCloseKey(hKey1):hKey1 = 0
   Return S_OK
End Function

#Undef DllCanUnloadNow
Function DllCanUnloadNow() As HRESULT  Export
   If nRefDll = 0 Then
      Return  S_OK
   End If
   Return S_FALSE
End Function

#Undef DllGetClassObject
Function DllGetClassObject(rclsid As REFCLSID, riid As REFIID , ppv As LPVOID Ptr) As HRESULT  Export
   Dim As ConText_ClassFactory Ptr  pCF = NULL

   If IsEqualCLSID( @CLSID_POINT, rclsid ) Then
      If pCF = NULL Then
         pCF = Callocate(SizeOf(pCF))
         If pCF = NULL Then
            Return E_OUTOFMEMORY
         End If
      End If
      pCF->icf.lpVtbl = @(pIClassFactoryVtbl)
      pCF->cRef = 0
      Return  ClassFactory_CFQueryInterface(Cast(IClassFactory Ptr,pCF), riid, ppv )
   End If
   Return  CLASS_E_CLASSNOTAVAILABLE
End Function

End Extern


dim shared data_1(0 to 1654-1) as ubyte = { _
&h42,&h4D,&h76,&h6,&h0,&h0,&h0,&h0,&h0,&h0,&h36,&h4,&h0,&h0,&h28,&h0,&h0,&h0,&h18,&h0,&h0,&h0,&h18,&h0,&h0,&h0,&h1,&h0,&h8,&h0,&h0, _
&h0,&h0,&h0,&h0,&h0,&h0,&h0,&hC4,&hE,&h0,&h0,&hC4,&hE,&h0,&h0,&h0,&h1,&h0,&h0,&h0,&h1,&h0,&h0,&h0,&h0,&h0,&hFF,&h1,&h1,&h4,&hFF, _
&h4,&h4,&h8,&hFF,&h6,&h6,&hC,&hFF,&h8,&h9,&h10,&hFF,&hA,&hC,&h14,&hFF,&hD,&hD,&h18,&hFF,&hF,&h10,&h1C,&hFF,&h11,&h12,&h20,&hFF,&h13,&h15,&h24, _
&hFF,&h16,&h18,&h28,&hFF,&h18,&h1A,&h2C,&hFF,&h1A,&h1C,&h30,&hFF,&h1D,&h1E,&h34,&hFF,&h1F,&h21,&h38,&hFF,&h21,&h24,&h3C,&hFF,&h23,&h26,&h40,&hFF,&h26,&h28, _
&h44,&hFF,&h2A,&h2D,&h4C,&hFF,&h2C,&h30,&h50,&hFF,&h2F,&h32,&h54,&hFF,&h31,&h34,&h58,&hFF,&h33,&h37,&h5C,&hFF,&h36,&h39,&h60,&hFF,&h3A,&h3E,&h68,&hFF,&h3C, _
&h40,&h6C,&hFF,&h3F,&h43,&h70,&hFF,&h41,&h45,&h74,&hFF,&h43,&h48,&h78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,&h0,&h0,&h0,&h0, _
&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0, _
&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0,&h0 }
Last edited by VANYA on May 30, 2021 7:56, edited 1 time in total.
Iczer
Posts: 67
Joined: Jul 04, 2017 18:09

Re: Shell extension for Windows (Explorer context menu)

Postby Iczer » May 29, 2021 12:59

It seems menu-image expired/lost... can i have some tips for using this code for creating menu item ("main info" for file-extensions ".aaa",".bbb",".ccc" ) containing 3 sub-menu items - "sub-info-1","sub-info-2","sub-info-3".
VANYA
Posts: 1522
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Shell extension for Windows (Explorer context menu)

Postby VANYA » May 30, 2021 8:00

Hi Iczer!

I updated the link to the picture.

can i have some tips for using this code for creating menu item ("main info" for file-extensions ".aaa",".bbb",".ccc" ) containing 3 sub-menu items - "sub-info-1","sub-info-2","sub-info-3".


For me personally, this is not necessary, but maybe someone will be interested in it.
Iczer
Posts: 67
Joined: Jul 04, 2017 18:09

Re: Shell extension for Windows (Explorer context menu)

Postby Iczer » Jun 05, 2021 15:58

I wanted to change and add new icons for menu items via dll-resources, but failed...

Code: Select all

Dim Shared As HBITMAP bmpMenu
'bmpMenu = LoadBitmapA((GetModuleHandle("AMShellExtention_Test.dll")), MAKEINTRESOURCE(REPACKICON_MAIN))
'bmpMenu = LoadBitmapA((GetModuleHandle("AMShellExtention_Test.dll")), MAKEINTRESOURCE(REPACKICON_MAIN))
bmpMenu = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(REPACKICON_MAIN), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION)

I could not make it show icons using images as bitmap or icons... Is there a some WIN-API magic in filling MENUITEMINFO structure?

Also - how do you make data_1() array from image?
VANYA
Posts: 1522
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Shell extension for Windows (Explorer context menu)

Postby VANYA » Jun 06, 2021 2:51

Also - how do you make data_1() array from image?


I don't remember very well, but it seems like I used Bin2Bas

I could not make it show icons using images as bitmap or icons... Is there a some WIN-API magic in filling MENUITEMINFO structure?


Sorry, but I have no desire to dive into all this again now

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 4 guests