Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Executing .lnk, .pif, .exe, .com etc from vb5/win32

Posted on 1998-02-13
3
Medium Priority
?
387 Views
Last Modified: 2012-06-27
Hi,
I have in my file listbox the items form desktop.  Now when is select any application i want to execute - Desktop may contain shortcuts, actual files or associated files.
How do i get the shortcuts file to run (.lnk)

thanks
0
Comment
Question by:msali
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Expert Comment

by:dirtdart
ID: 1457024
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


ShellExecute will run any file by finding the program associated with it and executing it.  hwnd is the window handle of your main window. lpOperation in this case will be "open".  lpFile is the path and filename.  lpParameters are any command line paramenters you need.  lpDirectory is the directory that your program will run in.  nShowCmd is how the window will show.  SW_SHOW will show the window normal.  SW_HIDE will hide the window.  SW_SHOWDEFAULT will show it in its default manner.  These and others are listed in the Win32API.txt
0
 
LVL 4

Accepted Solution

by:
yowkee earned 20 total points
ID: 1457026
 Use ShellExecute to run program or document with program associated with it. Passed "open" or "explore" in second parameter of ShellExecute to open or explore the file.
 
  For shortcut to program or folder, pass Null string to second parameter (lpOperation). For example, a shorcut "C:\Testwin.lnk" point to folder "C:\windows\command", call Shellexecute to open it:

  ShellExecute(0,, vbNullString, "C:\testwin.lnk", "", "", 1)

  Hope this help.
0
 
LVL 4

Expert Comment

by:yowkee
ID: 1457028
Hi, msali,

  The method worked in my machine. I have a DUN entry in start menu folder and a shortcut to "My Documents" in directory C:\. And it worked for this two entry.
  Do you specify the filename with extension .lnk?
  Let see whether we do the same thing. I make a shortcut to My Documents under root directory C: called "My Documents.lnk". Then I execute it with:
   lstrFolder = "C:\My Documents.lnk"
   call ShellExecute(0, vbNullString, lstrFolder, "", "", 1)
  Could you try it? Thanx.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question