Is it possible to write winapi function prototypes in a C file
I know that it is possible, because the function prototype (CryptAcquireContextW above works to my delight
But I can't write VirtualLock prototypes, the compiler doesn't even complain about an unresolved symbol, it just reads it as a syntax error and expects ")" after the first parameter. I have a header in front of my eyes
C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um
used CMAKE and tested previous compiled and executed
#ifdef WINDOWS_branching_OP_1
#if defined(_WIN64)
#define ULONG_PTR unsigned int64_t // __int64
#else
#define ULONG_PTR unsigned long
#endif
#define DWORD unsigned long
#define QWORD unsigned __int64
#define BYTE unsigned char
#define BOOL int
#define LPVOID void*
#define SIZE_T ULONG_PTR
#define HCRYPTPROV unsigned long long
#define LPCWSTR const wchar_t*
#define WINADVAPI
#define WINAPI __stdcall
#pragma comment(lib, "advapi32.lib")
WINADVAPI BOOL WINAPI CryptAcquireContextW(
HCRYPTPROV *phProv,
LPCWSTR pszContainer,
LPCWSTR pszProvider,
DWORD dwProvType,
DWORD dwFlags
);
WINADVAPI BOOL WINAPI CryptGenRandom(
_In_ HCRYPTPROV hProv,
_In_ DWORD dwLen,
_Inout_updates_bytes_(dwLen) BYTE *pbBuffer
);
#define WINBASEAPI
WINBASEAPI BOOL WINAPI VirtualLock(
_In_ LPVOID lpAddress,
_In_ SIZE_T dwSize
);
#endif
there are other things that bother me:
- why can't we limit ourselves to function prototypes and I'll have to import the full Header windows.h or memoryapi.h for both the random number functions and the Swap protection functions
- why couldn't I find information on this topic, this is something exceptional, give me information and sources regardless of complexity
- fundamental sources on platform-independent compilation, if you think I'm doing something wrong, I can relearn without asking questions. I need to secure additional functionality in the finished project
cmake 3.30.3 x86_64
VS 2022 BuildTools
I compile static linked library in C. use inside C++/QT IDE qtcreator with main project and other with tested functional

#includeing the header files that provide these declarations?1Why is that important to you?2Probably because it isn't important enough to pursue.3I don't understand the question.#define WIN32_LEAN_AND_MEANor#define WIN64_LEAN_AND_MEANto exclude certain less commonly used Windows header files and API declarations from being included when you use windows.h. Once you start defining you own versions ofDWORDetc, etc you open yourself to more possibility of error.