|
-
Jan 18th, 2005, 10:49 PM
#1
Thread Starter
Fanatic Member
Shellexecute selected file in filelistbox?
I'm trying to launch the selected file in a filelistbox with a specified app., however, filelist1.selected doesn't seem to be correct. What should this be when I use a filelistbox? I've always used listviews & listboxes for most of my apps in the past. My code is below. Any help is appreciated. This is my last issue to resolve.
VB Code:
ShellExecute filelist1.Path & "\" & filelist1.selected, vbNullString, "C:\launcher\fceu.exe", SW_SHOWNORMAL
-
Jan 18th, 2005, 11:11 PM
#2
Re: Shellexecute selected file in filelistbox?
VB Code:
ShellExecute Me.Hwnd, "C:\launcher\fceu.exe", filelist1.Path & "\" & filelist1.selected, "C:\launcher" , SW_SHOWNORMAL
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 18th, 2005, 11:12 PM
#3
Re: Shellexecute selected file in filelistbox?
Debugging, debugging and again - debugging. Step through your code by pressing F8 so you can actually see what's in your variables OR put a breakpointer directly on that line (F9):
- what is the actual value of filelist1.Path
- what is the actual value of filelist1.selected
- what is the actual combined value of filelist1.Path & "\" & filelist1.selected
-
Jan 18th, 2005, 11:24 PM
#4
Thread Starter
Fanatic Member
Re: Shellexecute selected file in filelistbox?
My problem is that it doesn't like this:
It says argument not optional on ".selected". What attribute do I need to use for a filelist box to get the selected item?
-
Jan 18th, 2005, 11:31 PM
#5
Re: Shellexecute selected file in filelistbox?
I think you may simply use FileName:
... File1.Path & File1.FileName ...
Although, "\" in between might not be needed as File1.Path should be ending with back slash.
-
Jan 18th, 2005, 11:33 PM
#6
Re: Shellexecute selected file in filelistbox?
... OR ... you have to specify an Index for Selected property:
... File1.Path & File1.Selected(File1.ListIndex) ...
-
Jan 19th, 2005, 12:02 AM
#7
Thread Starter
Fanatic Member
Re: Shellexecute selected file in filelistbox?
This is taking way to long................Now I'm getting an error on this. And yes, I put my Public Declarations in a module for the ShellExecute command.
VB Code:
ShellCode = ShellExecute(Me.hwnd, "open", filelist1.FileName, , "C:\launcher\fceu.exe", SW_SHOWNORMAL)
And in General Declarations, I dimmed shellcode as and integer
This code is on a command button and I get "Argument not optional" error on the line I posted above. I've looked on 3 API sites and everything looks correct to me. All I'm trying to do is launch my selected file in a filelistbox with a specified application! It's been two years since I 've use any API, but I don't remember the ShellExecute being this hard!
-
Jan 19th, 2005, 12:25 AM
#8
Re: Shellexecute selected file in filelistbox?
VB Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
yVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Check your parameters. You are missing one.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 19th, 2005, 12:28 AM
#9
Thread Starter
Fanatic Member
Re: Shellexecute selected file in filelistbox?
Ok, I got it working, but I need to open the file with a "specified" program, not the one that is associated with it. Will shellexecute allow me to do this?
-
Jan 19th, 2005, 12:30 AM
#10
Re: Shellexecute selected file in filelistbox?
Yes, you pass the program as the third parameter and the file to open as the fourth.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|