CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    Memphis
    Posts
    24

    File Associations

    I would like to click on a file in a file list and have the associated application start. I cannot seem to find any documentation on this very common Windows capability.


  2. #2
    Guest

    Re: File Associations

    'open a file with it's associated application
    'this example opens addin.txt with notepad

    'put this in a bas module
    '
    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
    '
    Sub ShellDef(strFileName)
    x = ShellEx(Form1.hwnd, "open", strFileName, "", "", 1)
    End Sub

    '>>>>>>>>>>>>>>>>> code for event on form <<<<<<<<<<<<<<<<<<<<<<<<<<
    '
    in the list click event

    Dim MyFile$
    MyFile$ = list1.text 'if list1.text is your file name and extension

    ShellDef MyFile$


  3. #3
    Join Date
    May 1999
    Location
    Memphis
    Posts
    24

    Re: File Associations

    Very good. Thanks.


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

Featured