Announcement

Collapse
No announcement yet.

Right-click in Explorer...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Right-click in Explorer...

    Hi All,

    I would like to make a program that yor start by right-clicking
    on a file in the Explorer. As far as I know it can be done by
    making a dll. Any examples around here?

    Regards
    Peter

    ------------------
    [email protected]
    www.dreammodel.dk

  • #2
    Do you mean IContextMenu ?
    You can find C-sample on codeguru. But it's not a simple DLL - this is a COM object.
    MFC has special wizard to make similar (ATL) objects; PB - not (to do this "manually" is very hard).

    ------------------
    E-MAIL: [email protected]

    Comment


    • #3
      Peter --

      1) Do you want to be able to right-click on any file, or do you have a list of specific file extensions, or...?

      2) It is relatively simple to add an item to the "Send To" list on the standard right-click menu. Would that be sufficient?

      -- Eric


      ------------------
      Perfect Sync Development Tools
      Perfect Sync Web Site
      Contact Us: mailto:[email protected][email protected]</A>
      "Not my circus, not my monkeys."

      Comment


      • #4
        Eric,

        1) I would like to be able to click on any file
        2) I know the 'Send To'-trick

        Regards
        Peter

        ------------------
        [email protected]
        www.dreammodel.dk

        Comment


        • #5
          I gotta admit I would not mind being able to do this too, it was the next option in my self-extraction compressing utility..
          Much like Winzip does.

          Now, MS has PowerToys and in there is a tool called "Doshere".
          This is copyright of MS, but for learning example you may be able to write your own from this?

          Lance if this can't be here please nuke it and let me know


          Scott
          ;
          ; "Command Prompt Here" PowerToy
          ;
          ; Copyright 1996 Microsoft Corporation
          ;
          [version]
          signature="$CHICAGO$"

          [DosHereInstall]
          CopyFiles = DosHere.Files.Inf
          AddReg = DosHere.Reg

          [DefaultInstall]
          CopyFiles = DosHere.Files.Inf
          AddReg = DosHere.Reg

          [DefaultInstall.ntx86]
          CopyFiles = DosHere.Files.Inf
          AddReg = DosHere.Reg.NT

          [DefaultUnInstall]
          DelFiles = DosHere.Files.Inf
          DelReg = DosHere.Reg

          [DefaultUnInstall.ntx86]
          DelFiles = DosHere.Files.Inf
          DelReg = DosHere.Reg.NT

          [SourceDisksNames]
          55="DOS Prompt Here","",1

          [SourceDisksFiles]
          DOSHERE.INF=55

          [DestinationDirs]
          DosHere.Files.Inf = 17

          [DosHere.Files.Inf]
          DOSHERE.INF

          [DosHere.Reg]
          HKLM,%UDHERE%
          HKLM,%UDHERE%,DisplayName,,"%DosHereName%"
          HKLM,%UDHERE%,UninstallString,,"%10%\rundll.exe setupx.dll,InstallHinfSection DefaultUninstall 132 %17%\DosHere.inf"
          HKCR,Directory\Shell\DosHere,,,"%DosHereAccel%"
          HKCR,Directory\Shell\DosHere\command,,,"%10%\command.com /k cd ""%1"""
          HKCR,Drive\Shell\DosHere,,,"%DosHereAccel%"
          HKCR,Drive\Shell\DosHere\command,,,"%10%\command.com /k cd ""%1"""

          [DosHere.Reg.NT]
          HKLM,%UDHERE%
          HKLM,%UDHERE%,DisplayName,,"%DosHereName%"
          HKLM,%UDHERE%,UninstallString,,"rundll32.exe syssetup.dll,SetupInfObjectInstallAction DefaultUninstall 132 %17%\DosHere.inf"
          HKCR,Directory\Shell\DosHere,,,"%DosHereAccel%"
          HKCR,Directory\Shell\DosHere\command,,,"%11%\cmd.exe /k cd ""%1"""
          HKCR,Drive\Shell\DosHere,,,"%DosHereAccel%"
          HKCR,Drive\Shell\DosHere\command,,,"%11%\cmd.exe /k cd ""%1"""

          [Strings]
          DosHereName="Command Prompt Here PowerToy"
          DosHereAccel="Command &Prompt Here"
          UDHERE="Software\Microsoft\Windows\CurrentVersion\Uninstall\DosHere"


          ------------------
          Scott
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment


          • #6
            Hej Peter

            Maybe the only way is to do it in C/C++

            In that case there is a nice example here(with C++ source code):
            http://icq.zdnet.com/downloads/texis...e=001315&b=pcm

            And here: http://www.thecodeproject.com/shell/shellextguide4.asp

            ------------------
            Best Regards
            Peter Scheutz

            [This message has been edited by Peter Scheutz (edited April 04, 2001).]
            Best Regards
            Peter Scheutz

            Comment


            • #7
              Given that the above INF file has NO executable other than shelling to CMD.EXE it is possible to do it in PB, it's just a registry entry.....
              There was no COM objects invoked above, just a simple set of registry entries....

              Therefore if you wrote code based on the above INF file to populate the registry section and replaced CMD.EXE with your own executable I believe it should be easy to do...

              Perhaps this weekend I will write one, if I have time...


              Scott

              ------------------
              Scott
              Scott Turchin
              MCSE, MCP+I
              http://www.tngbbs.com
              ----------------------
              True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

              Comment


              • #8
                Well, it seems to me I encounted one old method.
                I tested under Win2000 (probably, in another OSes are used another keys).

                So, I created reg file (let's say 1.reg) and registered it - regedit 1.reg

                REGEDIT4
                [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Semen\Command]
                ""="C:\\Test\\A.Exe %1"

                In directory C:\Test I created A.Exe which dispays command (a filename). All works fine.

                ------------------
                E-MAIL: [email protected]

                Comment


                • #9
                  That way looks even easier than the .INF file...

                  Winamp for example:
                  Windows Registry Editor Version 5.00

                  [HKEY_CLASSES_ROOT\Applications\Winamp.exe\shell\ListBookmark]
                  @="Add to Winamp's &Bookmark list"

                  [HKEY_CLASSES_ROOT\Applications\Winamp.exe\shell\ListBookmark\command]
                  @="\"C:\\Winamp\\Winamp.exe\" /BOOKMARK \"%1\""


                  Take that info, write to those registry keys and walah!

                  Good catch

                  Scott


                  ------------------
                  Scott
                  Scott Turchin
                  MCSE, MCP+I
                  http://www.tngbbs.com
                  ----------------------
                  True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                  Comment


                  • #10
                    Supercool.

                    Same key works on 98 SE too.
                    Anybody tested Win95?


                    ------------------
                    Best Regards
                    Peter Scheutz
                    Best Regards
                    Peter Scheutz

                    Comment


                    • #11
                      another twist

                      REGEDIT4
                      [HKEY_CLASSES_ROOT\Unknown\shell\MYAPP\command]
                      ""="C:\\<path>\\MYAPP.Exe %1"

                      You have made a extra entry in right click menu available
                      when You click on a file with unknown extension.

                      (only tested on W2k)

                      -p

                      ------------------

                      Comment


                      • #12
                        Thanks All!

                        I have a working example now. But I have one problem:
                        If I select more than 1 file (let ud say 3 files), Explorer
                        executes my program 3 times. Any solution to that? When I select
                        multiple files I would like Explorer to input a list to my
                        program. That's how it works if you put a shortcut to a program
                        in the 'Send To'-folder.

                        Regards
                        Peter

                        ------------------
                        [email protected]
                        www.dreammodel.dk

                        Comment


                        • #13
                          Peter --

                          > list
                          It's old interface. Modern uses com (..\shellex) and probably supports a list.

                          But you can do something like below (tested under Win2000)

                          Code:
                             #Compile Exe
                             #Dim All
                             #Register None
                             #Include "Win32Api.Inc"
                             
                             %ID_TEXT = 101
                             
                             Type COPYDATASTRUCT
                                dwData As Asciiz Ptr
                                cbData As Dword
                                lpData As Asciiz Ptr
                             End Type
                          
                             CallBack Function DlgProc
                                Select Case CbMsg
                                   Case %WM_COPYDATA
                                   Dim cdt As COPYDATASTRUCT Ptr
                                   cdt = CbLparam
                                   Dim Txt As String
                                   Control Get Text CbHndl, %ID_Text To Txt
                                   Txt = Txt + $CRLF + @[email protected]
                                   Control Set Text CbHndl, %ID_Text, Txt
                                   Function = 1: Exit Function
                                End Select
                             
                             End Function
                             
                             Function WinMain (ByVal hCurInstance  As Long, ByVal hPrevInstance As Long, _
                                lpszCmdLine   As Asciiz Ptr, ByVal nCmdShow As Long) Export As Long
                          
                                Dim hMutex As Long, hDlg As Long, Cdt As COPYDATASTRUCT, PrgName As Asciiz * %MAX_PATH, Msg As tagMsg, hWnd As Long
                                
                                PrgName = "Any unique name"
                                hMutex = CreateMutex(ByVal %Null, 0, PrgName): If hMutex = 0 Then Exit Function ' Error in Mutex
                          
                                If GetLastError = %ERROR_ALREADY_EXISTS Then
                                   Cdt.cbdata = Len(@lpszCmdLine) + 1
                                   Cdt.lpData  = lpszCmdLine
                                   While IsFalse(hWnd)
                                      hWnd = FindWindow (ByVal 0&, PrgName)
                                      While PeekMessage(Msg, %NULL, %NULL, %NULL, %PM_REMOVE): Wend
                                   Wend
                                   SendMessage hWnd, %WM_COPYDATA, 0, VarPtr(Cdt): Exit Function
                               End If
                          
                               Dialog New 0, PrgName, , , 450, 200, %WS_SYSMENU Or %WS_CAPTION To hDlg
                               Control Add TextBox, hDlg, %ID_TEXT, Command$, 10, 10,430, 180, %ES_MULTILINE, %WS_EX_CLIENTEDGE
                               Dialog Show Modal hDlg Call DlgProc
                               CloseHandle hMutex ' Possible to delete
                          
                            End Function
                          ------------------
                          E-MAIL: [email protected]

                          Comment

                          Working...
                          X