本文介绍了使用IntPtr作为函数指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在使用EM_GETWORDBREAKPROC参数调用SendMessage,该参数返回指向默认EDITWORDBREAKPROC函数的指针。如何在vb.net中为此指针分配委托? (与Marshal.GetFunctionPointerForDelegate相反)

I''m calling SendMessage with a parameter of EM_GETWORDBREAKPROC which returns a pointer to the default EDITWORDBREAKPROC function. How can I assign a delegate to this pointer in vb.net? (The opposite of Marshal.GetFunctionPointerForDelegate)

推荐答案

引用:

相反的Marshal.GetFunctionPointerForDelegate

The opposite of Marshal.GetFunctionPointerForDelegate



那将是 Marshal.GetDelegateForFunctionPointer 然后!



未经测试的代码片段:


That''ll be Marshal.GetDelegateForFunctionPointer then!

Untested code fragment:

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int EDITWORDBREAKPROCW(
  [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpch,
  int ichCurrent,
  int cch,
  int code);

public EDITWORDBREAKPROCW GetWordBreakProc(IntPtr rawPtr) {
  return (EDITWORDBREAKPROCW)Marshal.GetDelegateForFunctionPointer(
          rawPtr,
          typeof(EDITWORDBREAKPROCW));
}


这篇关于使用IntPtr作为函数指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 09:44