ShellExecuteA is a WinAPI function that allows an application to open or execute files, URLs, or other applications.
ShellExecuteA is part of the ShellAPI.
https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea
Definition:
HINSTANCE ShellExecuteA(
HWND hwnd, // Parent window handle (can be NULL)
LPCSTR lpOperation, // Action to perform ("open", "print", "runas", ...)
LPCSTR lpFile, // File or application to execute
LPCSTR lpParameters, // Command line arguments (NULL if not needed)
LPCSTR lpDirectory, // Default working directory (NULL if not needed)
INT nShowCmd // Window visibility (e.g., SW_SHOWNORMAL)
);
Open Notepad:
#include <windows.h>
#include <shellapi.h>
int main() {
ShellExecuteA(NULL, "open", "notepad.exe", NULL, NULL, SW_SHOWNORMAL);
return 0;
}
Open a site in the default browser:
#include <windows.h>
#include <shellapi.h>
int main() {
ShellExecuteA(NULL, "open", "https://www.danielroberson.com", NULL, NULL, SW_SHOWNORMAL);
return 0;
}