Results 1 to 5 of 5

Thread: AUTORUN.INF - Run files from VB

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    50

    Arrow AUTORUN.INF - Run files from VB

    Hi,

    I need my VB application to open any file, depending on the file assotiation in the windows. Something like

    shell "program.exe"

    but not just *.exe files
    For example if it's *.jpg, VB opens it with Adobe (or whatever is assotiated), if *.htm, VB opens it with IE.

    What I actually need is to autorun the html page when I insert the CD in CD drive.

    Thanks,
    Best regards, Andrew
    Best regards, Andrew

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    This may give you some ideas.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    4.                                 (ByVal hwnd As Long, _
    5.                                 ByVal lpOperation As String, _
    6.                                 ByVal lpFile As String, _
    7.                                 ByVal lpParameters As String, _
    8.                                 ByVal lpDirectory As String, _
    9.                                 ByVal nShowCmd As Long) As Long
    10. Const SW_SHOWNORMAL = 1
    11.  
    12. Private Sub Command1_Click()
    13. Dim strDir As String
    14. On Error GoTo OpenErr
    15.  
    16.     With CommonDialog1
    17.         .CancelError = True
    18.         .ShowOpen
    19.     End With
    20.    
    21.     strDir = Left(CommonDialog1.FileName, 3)
    22.     ShellExecute Me.hwnd, vbNullString, CommonDialog1.FileName, _
    23.                     vbNullString, strDir, SW_SHOWNORMAL
    24. OpenErr:
    25. End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    50

    What is CommonDialog1?

    What is CommonDialog1?
    Best regards, Andrew

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    It is the Microsoft Common Dialog Control 6.0. You can find it under components.

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    50

    Thanks

    Thanks!!!

    It works even without Common Dialog Control 6.0
    Best regards, Andrew

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