Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

How do I start a .lnk

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);

1 Solution
Try to

ShellExecute ( NULL, "open", "c:\\somepath\\prog2.lnk", NULL, NULL, SW_SHOWNORMAL);
hustchAuthor Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now