Is it possible to specify WINAPI when calling a function

Posted on 2011-02-12
Last Modified: 2012-05-11
The following won't compile because GetProcAddress name clashs between the class and WINAPI. If I rename MY_ODBC_DriverMangerClass::GetProcAddress  then it works. Is there any way I can specify the WINAPI call within the body of the class function so I can keep the same function name? Any alternative suggestions?

class MY_ODBC_DriverMangerClass
            HINSTANCE DLLinstance;
            VOID LoadDriverManager() { DLLinstance = LoadLibrary(_T("odbc32.dll")); };
            FARPROC WINAPI GetProcAddress(__in  LPCSTR lpProcName) {return(GetProcAddress(DLLinstance,lpProcName));};
Question by:elcbruce
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 86

Accepted Solution

jkr earned 500 total points
ID: 34881195
Just use the scope resolution operator '::' to distinguish between the Windows API and your member function and that will compile fine:
class MY_ODBC_DriverMangerClass
            HINSTANCE DLLinstance;
            VOID LoadDriverManager() { DLLinstance = LoadLibrary(_T("odbc32.dll")); };
            FARPROC WINAPI GetProcAddress(__in  LPCSTR lpProcName) {return(::GetProcAddress(DLLinstance,lpProcName));};

Open in new window


Author Comment

ID: 34882446
That worked, thanks.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question