[mingw - C/C++] ptr and typedef question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[mingw - C/C++] ptr and typedef question

SourceForge.net

Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=3230173
By: packetvb

What is the correct way to call an api by getprocaddress?
This compiles find in MSVC but fails in both MINGW and Borland.

HMODULE __TESTDLL_DLL;
typedef void (WINAPI*__TestProc1) ();
__TestProc1 TestProc1;
typedef Integer  (WINAPI*__TestProc2) (Integer Num1,Integer Num2);
__TestProc2 TestProc2;
typedef void (WINAPI*__TestProc3) ();
__TestProc3 TestProc3;

__TESTDLL_DLL= LoadLibrary("TESTDLL.DLL");
*TestProc1 = (__TestProc1)GetProcAddress(__TESTDLL_DLL,"TestProc1");
*TestProc2 = (__TestProc2)GetProcAddress(__TESTDLL_DLL,"TestProc2");
*TestProc3 = (__TestProc3)GetProcAddress(__TESTDLL_DLL,"TestProc3");

The compiler complains when assigning the ptrs addresses. Anyone explain and
tell me what is correct?

thanks


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=286529


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: [mingw - C/C++] ptr and typedef question

John Vandenberg
On 7/2/05, SourceForge.net <[hidden email]> wrote:

>
> Read and respond to this message at:
> https://sourceforge.net/forum/message.php?msg_id=3230173
> By: packetvb
>
> What is the correct way to call an api by getprocaddress?
> This compiles find in MSVC but fails in both MINGW and Borland.
>
> HMODULE __TESTDLL_DLL;
> typedef void (WINAPI*__TestProc1) ();
> __TestProc1 TestProc1;
> typedef Integer  (WINAPI*__TestProc2) (Integer Num1,Integer Num2);
> __TestProc2 TestProc2;
> typedef void (WINAPI*__TestProc3) ();
> __TestProc3 TestProc3;
>
> __TESTDLL_DLL= LoadLibrary("TESTDLL.DLL");
> *TestProc1 = (__TestProc1)GetProcAddress(__TESTDLL_DLL,"TestProc1");
> *TestProc2 = (__TestProc2)GetProcAddress(__TESTDLL_DLL,"TestProc2");
> *TestProc3 = (__TestProc3)GetProcAddress(__TESTDLL_DLL,"TestProc3");

``*TestProc1'' instructs to dereference the pointer, so these line ask
the compiler to put the return value into a numerical value; e.g.

int i = 1;
i = (__TestProc1)GetProcAddress(__TESTDLL_DLL,"TestProc1");
 
> The compiler complains when assigning the ptrs addresses. Anyone explain and
> tell me what is correct?

remove the * before the variables.

> thanks

Cheers,
John


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. <a href="http://ads.osdn.com/?ad_idt77&alloc_id492&op=click">http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users