Solved

Is it possible to specify WINAPI when calling a function

Posted on 2011-02-12
2
341 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now