How to open a file
-
I'm trying to open a file of any type from an app built with VB6. Does anybody know the code to open a file, so that the program associated with this file type starts? [Maybe it's a stupid question, but i just don't know how to do this :confused: ] Thanks in advance, M_M_G
-
I'm trying to open a file of any type from an app built with VB6. Does anybody know the code to open a file, so that the program associated with this file type starts? [Maybe it's a stupid question, but i just don't know how to do this :confused: ] Thanks in advance, M_M_G
Short of shelling out and running "Start (the name of the file)" there are other api ways. Tak a look here vbnet.mvps.org
-
Short of shelling out and running "Start (the name of the file)" there are other api ways. Tak a look here vbnet.mvps.org
-
I always use ShellExecute:
'ShellExecute Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hwnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Public Const SW_NORMAL = 1 ' Displays the window normalised Public Const SW_SHOWMINIMIZED = 2 ' Displays the window minimised Public Const SW_SHOWMAXIMIZED = 3 ' Displays the window maximised Public Const SW_SHOWNOACTIVATE = 4 ' Displays the window normalised without focus Public Const SW_SHOW = 5 ' Activates a window at its current size Public Const SW_SHOWNA = 8 ' Displays the window at its current size without focus Public Const SW_SHOWDEFAULT = 10 ' Displays the window at its default size ShellExecute Me.hwnd, "Open", m_strFilename, "", "", SW_SHOWMAXIMIZED
That should do everything you need! "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox -
I always use ShellExecute:
'ShellExecute Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hwnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Public Const SW_NORMAL = 1 ' Displays the window normalised Public Const SW_SHOWMINIMIZED = 2 ' Displays the window minimised Public Const SW_SHOWMAXIMIZED = 3 ' Displays the window maximised Public Const SW_SHOWNOACTIVATE = 4 ' Displays the window normalised without focus Public Const SW_SHOW = 5 ' Activates a window at its current size Public Const SW_SHOWNA = 8 ' Displays the window at its current size without focus Public Const SW_SHOWDEFAULT = 10 ' Displays the window at its default size ShellExecute Me.hwnd, "Open", m_strFilename, "", "", SW_SHOWMAXIMIZED
That should do everything you need! "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox -
M_M_G wrote: with a few mods What did you have to change? (Not having a dig, just curious!) "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
-
M_M_G wrote: with a few mods What did you have to change? (Not having a dig, just curious!) "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
-
All the 'Public' stuff didn't work. It also didn't work properly with the 'SW_SHOWMAXIMIZED' argument.