Solved

Is it possible to specify WINAPI when calling a function

Posted on 2011-02-12
2
357 Views
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
{
      private:
            HINSTANCE DLLinstance;
      public:
            VOID LoadDriverManager() { DLLinstance = LoadLibrary(_T("odbc32.dll")); };
            FARPROC WINAPI GetProcAddress(__in  LPCSTR lpProcName) {return(GetProcAddress(DLLinstance,lpProcName));};
};
0
Comment
Question by:elcbruce
2 Comments
 
LVL 86

Accepted Solution

by:
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
{
      private:
            HINSTANCE DLLinstance;
      public:
            VOID LoadDriverManager() { DLLinstance = LoadLibrary(_T("odbc32.dll")); };
            FARPROC WINAPI GetProcAddress(__in  LPCSTR lpProcName) {return(::GetProcAddress(DLLinstance,lpProcName));};
};

Open in new window

0
 

Author Comment

by:elcbruce
ID: 34882446
That worked, thanks.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

821 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