我是新來的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