Results 1 to 2 of 2

Thread: FindExecutable API [resolved]

  1. #1

    Thread Starter
    Lively Member UTGrim's Avatar
    Join Date
    Jan 2005
    Location
    Brazil
    Posts
    92

    Resolved FindExecutable API [resolved]

    I'm trying to use the FindExecutable API to find out which is the default application for HTML files. Unfortunately, it returns "" every time...

    Here's my code:

    VB Code:
    1. Dim strVar As String, strResult as String
    2. strResult = FindExecutable("temp.html", App.Path + "\", "") 'Calls FindExecutable API
    3. If strResult <> "" Then 'If the result is not blank
    4.     strVar = ExtractFileName(strVar) 'Extracts filename with a function I made
    5. Else
    6.     strVar = "not detected"
    7. End If
    8. optPreview(0).Caption = "Use Default (" + strVar + ")" 'Sets the caption
    Could anybody help me with this?

    Thanks
    Last edited by UTGrim; Mar 26th, 2005 at 01:48 PM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: FindExecutable API

    Try this sample:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const MAX_FILENAME_LEN = 260
    4. Private Declare Function FindExecutable Lib "shell32.dll" _
    5.     Alias "FindExecutableA" _
    6.     (ByVal lpFile As String, ByVal lpDirectory As String, _
    7.      ByVal lpResult As String) As Long
    8.  
    9. Private Sub Command2_Click()
    10. Dim i As Integer, s2 As String
    11. Dim sFile$
    12.  
    13.     'create a temp file
    14.     sFile = App.Path & "\test.htm"
    15.     Open sFile For Output As #1
    16.         Print #1, "http://www.microsoft.com"
    17.     Close #1
    18.    
    19.     'Create a buffer
    20.     s2 = String(MAX_FILENAME_LEN, 32)
    21.     'Retrieve the name and handle of the executable
    22.     i = FindExecutable(sFile, vbNullString, s2)
    23.     If i > 32 Then
    24.         MsgBox Left$(s2, InStr(s2, Chr$(0)) - 1)
    25.     Else
    26.         MsgBox "No association found !"
    27.     End If
    28.    
    29.     'delete temp file
    30.     Kill sFile
    31.  
    32. End Sub

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