從這裏答案提供Can I choose a custom image for C# Windows Application Drag Drop functions?,爲什麼下面一行:如何將IntPtr轉換爲InteropService.SafeHandle?
return new Cursor(CreateIconIndirect(ref tmp));
會導致編譯器發出此錯誤:
The best overloaded method match for 'System.Windows.Input.Cursor.Cursor(string)' has some invalid arguments Argument 1: cannot convert from 'System.IntPtr' to 'System.Runtime.InteropService.SafeHandle'
,是有辦法解決它?
該代碼只能在Winforms項目中使用。你並不一定要使用它,它有一個討厭的句柄泄漏了一段時間後,將你的程序崩潰。 –