Category : C++ Source Code
Archive   : C_ALL.ZIP
Filename : TI866.ASC

 
Output of file : TI866.ASC contained in archive : C_ALL.ZIP







PRODUCT : C++ NUMBER : 866
VERSION : All
OS : WIN
DATE : August 12, 1992 PAGE : 1/1

TITLE : Using The Windows API Function MakeProcInstance




I keep getting a type mismatch error from the compiler when I
pass my function pointer to MakeProcInstance, and a type mismatch
error when I assign my function's return value to another
function pointer. Why?

Unless two functions take the same parameters, they are
considered to be of different types. Thus, if I declare a
DlgProc like so:

int FAR PASCAL _export DlgProc(HWND, WORD, WORD, DWORD);

I will get a type mismatch when I do:

MakeProcInstance(DlgProc, hInstance);

because MakeProcInstance expects a FARPROC for its first
parameter, which is declared to be a

typedef int (FAR PASCAL *FARPROC)();

To suppress this error, do this:

MakeProcInstance((FARPROC)DlgProc, hInstance);

That is typecast the function pointer you're passing to
MakeProcInstance to be the type it expects. Similarly, since
MakeProcInstance returns a FARPROC, you will get an error if you
assign its return value into other than a FARPROC. You would
need to either make the variable your assigning
MakeProcInstance's return value into a FARPROC, or typecast the
return value to the type of your variable.

DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.















  3 Responses to “Category : C++ Source Code
Archive   : C_ALL.ZIP
Filename : TI866.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/