IntPtr和方法P / Invoke [英] IntPtr and method P/Invoke
本文介绍了IntPtr和方法P / Invoke的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我正在尝试使用P / Invoke和一个带IntPtr的方法我在哪里
应该放一个地址一个方法,本机方法将使用
与我沟通。如何将方法转换为IntPtr?
/ Christian
Hi!
I''m trying to use P/Invoke and a Method which takes an IntPtr where I am
supposed to put an address to a method which the native method will use
to communicate back to me. How do I convert a method to an IntPtr?
/ Christian
推荐答案
Christian
您是否在
http://msdn.microsoft.com/library/de...functions.asp?
HTH
Alex
" Christian Westerlund" < CH ****************** @ comhem.se>在留言中写道
news:ed ************** @ TK2MSFTNGP10.phx.gbl ...
Hi, Christian
Did you check sample at
http://msdn.microsoft.com/library/de...functions.asp?
HTH
Alex
"Christian Westerlund" <ch******************@comhem.se> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
嗨!
我正在尝试使用P / Invoke和一个方法,它接受一个IntPtr我应该把一个地址放到一个方法,本机方法将使用
进行通信对我来说。如何将方法转换为IntPtr?
/ Christian
Hi!
I''m trying to use P/Invoke and a Method which takes an IntPtr where I am
supposed to put an address to a method which the native method will use
to communicate back to me. How do I convert a method to an IntPtr?
/ Christian
嗨!
好吧,在那个样本和任何样本中,我看过P / Invoke
函数需要一个这样的委托对象:
public static extern int EnumWindows( CallBack x,int y);
然后它不是问题,你创建一个委托对象并发送它但是我
有一个更像这样的函数: br />
public static extern int EnumWindows(IntPtr callback,int y)
如果我发送一个委托对象作为第一个参数我得到一个错误,我
不知道如何将委托转换为IntPtr。
/ Christian
AlexS写道:
Hi!
Well, in that sample and as in any sample I have seen the P/Invoke
function takes a delegate object like this:
public static extern int EnumWindows(CallBack x, int y);
Then it is not a problem, you create a delegate object and send it but I
have a function that is more like this:
public static extern int EnumWindows(IntPtr callback, int y)
If I send a delegate object as the first parameter I get an error and I
have no idea how to convert a delegate to an IntPtr.
/Christian
AlexS wrote:
Christian
你有没有在
http://msdn.microsoft.com/library/de...functions.asp?
HTH
Alex
Christian Westerlund < CH ****************** @ comhem.se>在消息中写道
新闻:ed ************** @ TK2MSFTNGP10.phx.gbl ...
Hi, Christian
Did you check sample at
http://msdn.microsoft.com/library/de...functions.asp?
HTH
Alex
"Christian Westerlund" <ch******************@comhem.se> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
嗨!
我正在尝试使用P / Invoke和一个方法,它接受一个IntPtr我应该把一个地址放到一个方法,本机方法将使用
进行通信对我来说。如何将方法转换为IntPtr?
/ Christian
Hi!
I''m trying to use P/Invoke and a Method which takes an IntPtr where I am
supposed to put an address to a method which the native method will use
to communicate back to me. How do I convert a method to an IntPtr?
/ Christian
Christian
我不确定我理解你的问题。您可以在
样本中声明函数,而不是使用IntPtr,并测试它是否有效。
HTH
Alex
" Christian Westerlund" < CH ****************** @ comhem.se>在消息中写道
新闻:O9 ************** @ TK2MSFTNGP10.phx.gbl ...
Hi, Christian
I am not sure I understand your issue. You can declare function as in the
sample instead of with IntPtr and test if it works.
HTH
Alex
"Christian Westerlund" <ch******************@comhem.se> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
嗨!
好吧,在那个示例和我看到的P / Invoke
函数的任何一个示例中都有一个这样的委托对象:
public static extern int EnumWindows(CallBack x,int y) ;
然后它不是问题,你创建一个委托对象并发送它但我有一个更像这样的函数:
public static extern int EnumWindows(IntPtr callback,int y )
如果我发送一个委托对象作为第一个参数我得到一个错误,我不知道如何将委托转换为IntPtr。
/基督徒
AlexS写道:
Hi!
Well, in that sample and as in any sample I have seen the P/Invoke
function takes a delegate object like this:
public static extern int EnumWindows(CallBack x, int y);
Then it is not a problem, you create a delegate object and send it but I
have a function that is more like this:
public static extern int EnumWindows(IntPtr callback, int y)
If I send a delegate object as the first parameter I get an error and I
have no idea how to convert a delegate to an IntPtr.
/Christian
AlexS wrote:
基督徒
你有没有检查样品
http://msdn.microsoft.com/library/de...functions.asp?
HTH
Alex
" Christian Westerlund < CH ****************** @ comhem.se>在消息中写道
新闻:ed ************** @ TK2MSFTNGP10.phx.gbl ...
Hi, Christian
Did you check sample at
http://msdn.microsoft.com/library/de...functions.asp?
HTH
Alex
"Christian Westerlund" <ch******************@comhem.se> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
嗨!
我正在尝试使用P / Invoke和一个方法,它接受一个IntPtr我应该把一个地址放到一个方法,本机方法将使用
进行通信对我来说。如何将方法转换为IntPtr?
/ Christian
Hi!
I''m trying to use P/Invoke and a Method which takes an IntPtr where I am
supposed to put an address to a method which the native method will use
to communicate back to me. How do I convert a method to an IntPtr?
/ Christian
这篇关于IntPtr和方法P / Invoke的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文