How do I start a .lnk

Posted on 2005-03-04
Medium Priority
Last Modified: 2013-12-03
I have two programs, Program1 and Program2.
For end-users, they will be located in the same folder, but during development, they will not.

As a convinience for me and other developers, a link to Program2.exe could be located in the Program1.exe folder.

Program2 is started this way:
  std::string path = pathOfProgram1 + "\\Program2.exe";
  res = ShellExecute(0, 0, path.c_str(), "", 0, SW_SHOWNORMAL);
  if (res <= 32) {
    // Some error - try to start a link
    // This did not work: path += ".lnk"
    //                            res = ShellExecute(0, 0, path.c_str(), "", 0, SW_SHOWNORMAL);

Question by:hustch
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
LVL 86

Accepted Solution

jkr earned 1000 total points
ID: 13459252
Try to

ShellExecute ( NULL, "open", "c:\\somepath\\prog2.lnk", NULL, NULL, SW_SHOWNORMAL);

Author Comment

ID: 13474871
Funny, jkr's suggestion was actually what didn't work, because it caused a AV in CmdLineExt03.dll.
When trying to find the cause (the VC++ output window suggested it was some utility I use), I rebooted to make some setting take effect, and after that, I couldn't reproduce the problem.

The really funny part (using a very broad definition of funny) was that the line I originally said didn't work, actually did work, so much for trying to psot questions from memory.

Anyway thanks for putting me back on the right track.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

765 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