简体   繁体   中英

How to convert this C type to a c# type

I have a type CK_NOTIFY in C++ defined as follows:

typedef uint ( * CK_NOTIFY)(
   uint   hSession,
   uint   event,
   void*  pApplication
);

I need to redefine this type in C# because I need to use it as an argument for a pinvoke function. What is it exactly? A structure? Or a function pointer?

It would be a delegate . Your "C type" is describing a function.

The function returns a uint and takes 2 uints and a void* .

So your delegate could look like:

Func<uint, uint, object, uint>

How you want to handle the void* is up to you...

如果需要进行互操作(即,将其传递到非托管DLL),则需要这样的委托声明:

public delegate uint CK_NOTIFY(uint hSession, uint @event, System.IntPtr pApplication);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM