It does not work for me in the ShellExecute code. Nothing is underlined, but when compiling, errors in the .obj file pop up that do not give me any information enter image description here Used this code:

#include <windows.h> ... ShellExecute(NULL, L"open", L"http://www.cyberforum.ru", NULL, NULL, SW_SHOW); 

And its various variations, mistakes are repeated. Please help with a solution or suggest alternatives, thank you.

Reported as a duplicate by VTT members, ߊߚߤߘ , Harry c ++ 23 Apr at 3:33 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    And before the heap, if you use wide characters, it is desirable to strictly define the function, not relying on autodetection, in your case ShellExecuteW(..) - NewView 10:21 pm

1 answer 1

In order for ShellExecute work, you need to add an appropriate header file in addition to windows.h . For ShellExecute specifically, this is shellapi.h .

For the future, use a simple algorithm of action. If the WinAPI function is not found, open Google and enter its name, for example, like this . Directly the very first is a link to Microsoft Docs . Open and scroll down to the end, there is a section of Requirements, where everything that is required for this function is indicated.

  • shellapi.h included in windows.h , there is a linker error in the question - VTT
  • The answer is correct, you need to watch the docks :) and connect Shell32.lib - NewView
  • Many thanks to you, NewView, your addition as the answer above helped. I would not have guessed myself, I need to study this topic better with linkers) - Fedya Ratnikov
  • @NewView, strangely, I looked at a couple of projects where ShellExecute used, Shell32.lib not connected anywhere. Well, maybe I looked at something, I answered late at night. - freim
  • @VTT, yes, right - shellapi.h was specified in my project, where WIN32_LEAN_AND_MEAN was defined. - freim