Board index » delphi » Confusing c++ typedef please help

Confusing c++ typedef please help

Im really confused about this vital c++ typedef

typedef LRESULT (WINAPI *LPFNAWEMANAGER) (AWEHANDLE, UINT, LPARAM, LPARAM);

I tried DrBob's expert tool and it got confused too. It gave me this source:

Type  = LRESULT (*LPFNAWEMANAGER) (AWEHANDLE, UINT, LPARAM, LPARAM);

Here is how the author off the header file describes it:

/*
    The LPFNAWEMANAGER type is used to declare a pointer to the message
    function. This message function will receive all necessary messages from
    the application who wishes to access its API. This type declaration is
    useful especially when dynamic linking is used.

    Example:

    :

    AWEHANDLE         hMyID;
    LPFNAWEMANAGER    lpfnAWEManager;

    :
    lpfnAWEManager = (Retrieve Address of function);
    :

*/

Please help.

Mr. noclueaboutc++ aka Emil Ramstedt

e...@ramstedt.pp.se

 

Re:Confusing c++ typedef please help


Quote
Emil wrote:

> Im really confused about this vital c++ typedef

> typedef LRESULT (WINAPI *LPFNAWEMANAGER) (AWEHANDLE, UINT, LPARAM, LPARAM);

> I tried DrBob's expert tool and it got confused too. It gave me this source:

> Type  = LRESULT (*LPFNAWEMANAGER) (AWEHANDLE, UINT, LPARAM, LPARAM);

> Here is how the author off the header file describes it:

> /*
>     The LPFNAWEMANAGER type is used to declare a pointer to the message
>     function. This message function will receive all necessary messages from
>     the application who wishes to access its API. This type declaration is
>     useful especially when dynamic linking is used.

>     Example:

>     :

>     AWEHANDLE         hMyID;
>     LPFNAWEMANAGER    lpfnAWEManager;

>     :
>     lpfnAWEManager = (Retrieve Address of function);
>     :

> */

> Please help.

My C ain't the best, but I do believe this translates to something like:

type
  LPFNAWEMANAGER = function (awe : AWEHANDLE; uint : WORD; lp1, lp2 :
LONGINT) : LRESULT; stdcall;

--
Need a custom component? Late on a project? Could use an util?
DOS Device driver? A VxD? NT drivers or services? Applications of any
kind?
Low rates, fast delivery!

When responding to news postings, please CC a copy to my email address.
Thanks.
Erik Sperling Johansen <e...@info-pro.no>

Re:Confusing c++ typedef please help


since the WINAPI causes some non-standard modifiers to be applied,
that is perhaps what confuses the expert tool.

Taking out the WINAPI may help the tool translate the type - but you
still need the equivalent of the WINAPI (ie. _far _stdcall).

Anyway, something like

type
        LPFNAWEMANAGER = function(AWEHANDLE, UINT, LPARAM, LPARAM) :
LRESULT stdcall;

should do what you want.

Quote
e...@ramstedt.pp.se (Emil) wrote:
>Im really confused about this vital c++ typedef

>typedef LRESULT (WINAPI *LPFNAWEMANAGER) (AWEHANDLE, UINT, LPARAM, LPARAM);

>I tried DrBob's expert tool and it got confused too. It gave me this source:

>Type  = LRESULT (*LPFNAWEMANAGER) (AWEHANDLE, UINT, LPARAM, LPARAM);

>Here is how the author off the header file describes it:

>/*
>    The LPFNAWEMANAGER type is used to declare a pointer to the message
>    function. This message function will receive all necessary messages from
>    the application who wishes to access its API. This type declaration is
>    useful especially when dynamic linking is used.

>    Example:

>    :

>    AWEHANDLE         hMyID;
>    LPFNAWEMANAGER    lpfnAWEManager;

>    :
>    lpfnAWEManager = (Retrieve Address of function);
>    :

>*/

>Please help.

>Mr. noclueaboutc++ aka Emil Ramstedt

>e...@ramstedt.pp.se

Re:Confusing c++ typedef please help


Quote
>> typedef LRESULT (WINAPI *LPFNAWEMANAGER) (AWEHANDLE, UINT, LPARAM, LPARAM); <<

I don't have the manuals here, but basically check the help for "procedural type".

type TLPfnAWEManager = function(AWEHandle; UInt; LParam; LParam): longint;

var LPfnAWEManager: TLPfnAWEManager

later in your code you can assign an address reference to your function pointer, e.g.

LPfnAWEManager := @AWEManager;
myResult := LPfnAWEManager^(myAWEHandle, myInteger, myParam1, myParam2);

I'm doing this without manuals, so please read up on it.

Best Regards
Andy Schmidt

Other Threads