Click here to Skip to main content
15,665,942 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Dear all,
I need to invoke the callback function defined in the dll(build in c/c++) to the application.I want the code and methodology to do it.
I really don't know how to do it with the callback functions.
I referred in net and found that it is need to use delegates for this purpose.
How to do it ? can any one explain me in detail about this ?
The following is the definition

/* Callback function type */

/*Function call*/
WORD WINAPI readdevice(WORD Lines,FUNCSCANBACK funcScanBack)

funcScanBack - callback function address. Reference to "FUNCSCANBACK" definition:
hBuf - Image buffer handle for callback.
unLines - Image lines in the buffer.

Return TRUE means continue read job, FALSE means cancel read job.
Updated 14-Nov-11 22:14pm

1 solution

public delegate UNKNWON FUNCSCANBACK(IntPtr hBuf,UInt32 unLines);
public class yourClass{

   public static extern UInt16 readdevice(UInt16 Lines, FUNCSCANBACK y);

void invokeFunc(){

readdevice(0,new FUNCSCANBACK(myCallBackFunc));


UNKNOWN myCallBackFunc(IntPtr hBuf,UInt32 unLines){


I used UNKNOWN as return type since I have no idea about CALLBACK*?
Share this answer
Ajaykumar.thurai 16-Nov-11 1:24am    
Thanks a lot. It is more helpful sir.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900