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
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