From 249a0b6b60b5139b46657f5863a82bbcd051a9d6 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Sat, 30 Nov 2024 14:45:42 +0200 Subject: [PATCH] win32: add minimal mingw header shellapi.h This is a very stripped down version[1], with only CommandLineToArgvW (typically used with GetCommandLineW() - which we already have), ShellExecute and FindExecutable, which don't require any new structs, and where used constants already exist at our winuser.h . Pretty cheap, and hopefully covers some meaningful new use cases[2]. Requires linking with -lshell32 . [1] original full version: http://download.savannah.nongnu.org/releases/tinycc/winapi-full-for-0.9.27.zip [2] Can now build "less" for windows - https://github.com/gwsw/less/ . Add -luser32 to LIBS at Makefile.wng (mingw makefile), then (gnu make): make -f Makefile.wng CC=tcc less.exe --- win32/include/winapi/shellapi.h | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 win32/include/winapi/shellapi.h diff --git a/win32/include/winapi/shellapi.h b/win32/include/winapi/shellapi.h new file mode 100644 index 000000000..ce4e78ec0 --- /dev/null +++ b/win32/include/winapi/shellapi.h @@ -0,0 +1,59 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER within this package. + */ +#ifndef _INC_SHELLAPI +#define _INC_SHELLAPI + +#ifndef WINSHELLAPI +#if !defined(_SHELL32_) +#define WINSHELLAPI DECLSPEC_IMPORT +#else +#define WINSHELLAPI +#endif +#endif + +#ifndef SHSTDAPI +#if !defined(_SHELL32_) +#define SHSTDAPI EXTERN_C DECLSPEC_IMPORT HRESULT WINAPI +#define SHSTDAPI_(type) EXTERN_C DECLSPEC_IMPORT type WINAPI +#else +#define SHSTDAPI STDAPI +#define SHSTDAPI_(type) STDAPI_(type) +#endif +#endif + +/* SHDOCAPI[_] definitions not required in this TinyCC minimal header */ + +#if !defined(_WIN64) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef UNICODE +#define ShellExecute ShellExecuteW +#define FindExecutable FindExecutableW +#else +#define ShellExecute ShellExecuteA +#define FindExecutable FindExecutableA +#endif + + /* minimal subset distributed with TinyCC. nShowCmd is at winuser.h */ + SHSTDAPI_(HINSTANCE) ShellExecuteA(HWND hwnd,LPCSTR lpOperation,LPCSTR lpFile,LPCSTR lpParameters,LPCSTR lpDirectory,INT nShowCmd); + SHSTDAPI_(HINSTANCE) ShellExecuteW(HWND hwnd,LPCWSTR lpOperation,LPCWSTR lpFile,LPCWSTR lpParameters,LPCWSTR lpDirectory,INT nShowCmd); + SHSTDAPI_(HINSTANCE) FindExecutableA(LPCSTR lpFile,LPCSTR lpDirectory,LPSTR lpResult); + SHSTDAPI_(HINSTANCE) FindExecutableW(LPCWSTR lpFile,LPCWSTR lpDirectory,LPWSTR lpResult); + SHSTDAPI_(LPWSTR *) CommandLineToArgvW(LPCWSTR lpCmdLine,int*pNumArgs); + +#ifdef __cplusplus +} +#endif + +#if !defined(_WIN64) +#include +#endif +#endif