Results 1 to 2 of 2

Thread: Shell Execution AND File Type List

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    46

    Post

    I like to know how to operate the API call of ShellExecute. What each parameter mean? every thing.

    The other thing is how can i get or load the know file types in the windows system? like in the explorer options-->File Types tab?

    Thank you very much
    Kiron

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    Post

    Here's the scoop:

    Public Declare Function ShellEx Lib "shell32.dll" Alias _
    "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
    ByVal lpFile As String, ByVal lpParameters As Any, _
    ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
    '
    'hwnd is the handle of the object
    'lpOperation is what you want to do..ie Open
    'lpfile is the file you are accessing
    'lpPaameteres are the parametes if any..if not they are null ""
    'lpDirectoy is directory if specified
    'nShowCmd is wheter to show or not show..ie...vbNomal, vbHide..etc


    Sub ShellDef(strFileName)
    x = ShellEx(Form1.hwnd, "open", strFileName, "", "", 1)
    If (x < 0) Or (x > 32) Then
    ' success
    Else
    MsgBox "Failed to start '" & strFileName & "'", vbInformation
    End If
    End Sub
    '===============================================================
    ' >>> code for event on form <<<
    '
    Dim strYourFileVariable$
    strYourFileVariable = "c:\your folder\yourfile.ext"
    ShellDef strYourFileVariable
    '
    '===========================================
    2nd..there is an object in components called
    browser...it is the Windows Explorer not the internet one and it will do what windows does.
    'use the browser dialog box
    '
    Option Explicit

    Private Const BIF_RETURNONLYFSDIRS = 1
    Private Const BIF_DONTGOBELOWDOMAIN = 2
    Private Const MAX_PATH = 260

    Private Declare Function SHBrowseForFolder Lib _
    "shell32" (lpbi As BrowseInfo) As Long

    Private Declare Function SHGetPathFromIDList Lib _
    "shell32" (ByVal pidList As Long, ByVal lpBuffer _
    As String) As Long

    Private Declare Function lstrcat Lib "kernel32" _
    Alias "lstrcatA" (ByVal lpString1 As String, ByVal _
    lpString2 As String) As Long

    Private Type BrowseInfo
    hWndOwner As Long
    pIDLRoot As Long
    pszDisplayName As Long
    lpszTitle As Long
    ulFlags As Long
    lpfnCallback As Long
    lParam As Long
    iImage As Long
    End Type


    Private Sub Form_Load()
    'Opens a Browse Folders Dialog Box that displays the
    'directories in your computer
    Dim lpIDList As Long ' Declare Varibles
    Dim sBuffer As String
    Dim szTitle As String
    Dim tBrowseInfo As BrowseInfo

    szTitle = "Hello World. Click on a directory and " & _
    "it's path will be displayed in a message box"
    ' Text to appear in the the gray area under the title bar
    ' telling you what to do

    With tBrowseInfo
    .hWndOwner = Me.hWnd ' Owner Form
    .lpszTitle = lstrcat(szTitle, "")
    .ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
    End With

    lpIDList = SHBrowseForFolder(tBrowseInfo)

    If (lpIDList) Then
    sBuffer = Space(MAX_PATH)
    SHGetPathFromIDList lpIDList, sBuffer
    sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)

    ' <<< Add Your Code Here >>>

    MsgBox sBuffer

    End If
    End Sub

    'have fun
    'Wayne



    [This message has been edited by HeSaidJoe (edited 12-15-1999).]

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