Results 1 to 2 of 2

Thread: "Open As" Dialogue

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2023
    Posts
    976

    "Open As" Dialogue

    Another very useful shell32 API which not been mentioned in this forum.
    This example is made in it's simpliest form.
    Many other examples as using "ShellExecute" and ShellExecuteEx" API's.
    It seems this API have been forgotten

    Code:
    Public Enum OPENASINFO_Flags
        OAIF_ALLOW_REGISTRATION = &H1
        'Enable the "always use this program" checkbox. If not passed, it will be disabled.
        
        OAIF_REGISTER_EXT = &H2
        'Do the registration after the user hits the OK button.
        
        OAIF_EXEC = &H4
        'Execute file after registering.
        
        OAIF_FORCE_REGISTRATION = &H8
        'Force the Always use this program checkbox to be checked. Typically, you won't use the OAIF_ALLOW_REGISTRATION flag when you pass this value.
        
        OAIF_HIDE_REGISTRATION = &H20
        'Introduced in Windows Vista. Hide the Always use this program checkbox. If this flag is specified, the OAIF_ALLOW_REGISTRATION and OAIF_FORCE_REGISTRATION flags will be ignored.
        
        OAIF_URL_PROTOCOL = &H40
        'Introduced in Windows Vista. The value for the extension that is passed is actually a protocol, so the Open With dialog box should show applications that are registered as capable of handling that protocol.
        
        OAIF_FILE_IS_URI = &H80
    End Enum
    
    Public Type OPENASINFO
         pcszFile As Long
         pcszClass As Long
        oaifInFlags As OPENASINFO_Flags
    End Type
    
    Public Declare Function SHOpenWithDialog Lib "shell32.dll" (ByVal hWndParent As Long, poainfo As OPENASINFO) As Long
    
    Public Sub OpenWithDlg(ByVal sFileName As String, ByVal uFlags As OPENASINFO_Flags, Optional ByVal hWndParent As Long = 0)
       Dim hr As Long
       Dim lpOAI As OPENASINFO
       
       With lpOAI
              .oaifInFlags = uFlags
              .pcszFile = StrPtr(sFileName)
       End With
       
       hr = SHOpenWithDialog(hWndParent, lpOAI)
       
    End Sub
    
    m_cShell32.OpenWithDlg "C:\DumpStack.log.tmp", OAIF_EXEC Or OAIF_REGISTER_EXT, Me.hWnd
    Attached Images Attached Images  

  2. #2
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: "Open As" Dialogue

    ...hasn't been mentioned? Number 1 search result for SHOpenWithDialog:

    [VB6] API Open With Dialog with enhanced functionality


    Something else you might be interested in, I have a project that lists the handlers then provides this dialog at the bottom for more options, like the Open With menu...

    [VB6] List/Execute File Handlers: IAssocHandler and IAssocHandlerInvoker (Vista+)

    Name:  associ1.jpg
Views: 279
Size:  49.4 KB

    ---

    Welcome to the shell programming addiction
    Last edited by fafalone; Nov 15th, 2023 at 10:24 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width