我是新来的C#(从本机C + +背景),我试图写一个小UI来打印窗口广播消息等等。我已经覆盖默认的WndProc消息循环在我的C#程序像这样:如何将非托管IntPtr类型转换为c#字符串?
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
// Listen for operating system broadcasts.
switch (m.Msg)
{
case WM_SETTINGCHANGE:
this.richTextLog.Text += "WM_SETTINGCHANGE - lParam=" + m.LParam.ToString() + "\n";
break;
}
base.WndProc(ref m);
}
我想知道什么,是如何获取lParam的对象,它是类型的IntPtr的字符串表示。它本质上是C++土地上的一个void *,我可以以某种方式将它投射到C#中吗?据推测,这样做本质上是不安全的。
首先测试IntPtr.Zero。信息并不完全值得。 – 2012-02-07 12:37:41
很好,非常感谢。 – Benj 2012-02-07 13:09:45