嗨,在 c# WinForms 中,为了替换已弃用的,AppDomain.GetCurrentThreadId()
我必须考虑以下内容
...
[DllImport("user32.dll", SetLastError = true)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
private static IWin32Window _owner;
...
#
uint processID = 0;
IntPtr ptr = _owner.Handle.ToPointer();
GetWindowThreadProcessId(ptr, out processID);
int replacementCurrentThreadId = processID;
除非它不起作用 - 错误是
The best overloaded method match for has some invalid arguments
或者
Cannot implicitly convert type 'void*' to 'System.IntPtr'. An explicit conversion exists (are you missing a cast?)
我相信我有正确的方法(获取 currentThreadId),但它不会让我分配值 - 大概是因为它们是指针(?)任何帮助都会得到帮助