Skip to content

Commit

Permalink
win32: add minimal mingw header shellapi.h
Browse files Browse the repository at this point in the history
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
  • Loading branch information
avih committed Nov 30, 2024
1 parent 085e029 commit 249a0b6
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions win32/include/winapi/shellapi.h
Original file line number Diff line number Diff line change
@@ -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 <pshpack1.h>
#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 <poppack.h>
#endif
#endif

0 comments on commit 249a0b6

Please sign in to comment.