You need to link with Shlwapi.lib.
Try adding the following to one of your source files:
#pragma comment( lib, "Shlwapi" )
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I've tried the example code in the section "A Simple Example of How to Use ShellExecuteEx" on this page:
https://learn.microsoft.com/en-us/windows/win32/shell/launch?redirectedfrom=MSDN
(as both Console and Windows 32-bit), but keep getting the same errors; AFTER putting the required missing "int" in front of "main()" under Visual Studio Community 2019, 16.9.2 (using "Console" project here, "Debug" "x86" with no changes):
Build started...
1>------ Build started: Project: ShellExample, Configuration: Debug Win32 ------
1>ShellExample.cpp
1>ShellExample.obj : error LNK2019: unresolved external symbol __imp__StrCmpIW@8 referenced in function _main
1>ShellExample.obj : error LNK2019: unresolved external symbol __imp__StrRetToBufW@16 referenced in function _main
1>ShellExample.obj : error LNK2019: unresolved external symbol __imp__PathFindExtensionW@4 referenced in function _main
1>C:\Users\user\source\repos\ShellExample\Debug\ShellExample.exe : fatal error LNK1120: 3 unresolved externals
1>Done building project "ShellExample.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
As I mentioned above, I tried this beginning with a Windows project using the proper function name there (instead of just int main()) and got the same 3 errors.
Dan, TheStarman.
You need to link with Shlwapi.lib.
Try adding the following to one of your source files:
#pragma comment( lib, "Shlwapi" )