Redefinition of VirtualAllocEx
Posted on 2005-04-06
I'm writing a program using Visual C++ 6.0 that needs to run in all Windows versions (from Win95 to XP).
Because some of the Kernel32 functions don't exist across all Windows versions I'm dinamically loading the functions using GetProcAddress().
I'm getting redefinition compile errors in functions that are already imported by the VC6.0 libraries.
As an example, if I want to use VirtualAllocEx() dinamically I use the following code:
typedef LPVOID (WINAPI *VIRTUALALLOCEX)(HANDLE, LPVOID, DWORD, DWORD, DWORD);
VC compiler complains that VirtualAllocEx is redefined (error C2372).
Of course I could name the function differently but for consistency I would like to use the same name.
Is there a way to redefine imported functions (or undefine it from the import list) ?