[Webinar] Streamline your web hosting managementRegister Today

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

Invoke shellexecute API call from a windows form .h file

When I start a standard form app and type the line #include <shellapi.h> at the top of my form1.h, it sets off >100 errors! A lot of them are redefinition errors. If I don't include the include line, I get a function not defined error.
1 Solution
I have managed C++ application whixch works with SHFileOperation function. h-file begins with:

#pragma once

#include <windows.h>
#include <shellapi.h>

namespace ShellTest

BTW, you don't need ShellExecute in managed C++ application. Use Process.Start(StartupInfo*) function with ProcessStartInfo.UseShellExecute = true.
jamesxiAuthor Commented:
I tried adding in the <windows.h> line that you have and it worked the first time! Apparently some or all of the Windows API includes require the windows.h header to be included as well. Also, thanks for the additional info on the process object... C++ is so monsterous with all its libraries these days!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

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