在c#中如何通过名字获取窗口句柄

如何通过窗口标题获取窗口句柄

public static IntPtr WinGetHandle( string wName )
{
	IntPtr hWnd = IntPtr.Zero;
	foreach ( Process pList in Process.GetProcesses( ) )
	{
		if ( pList.MainWindowTitle.Contains( wName ) )
		{
			hWnd = pList.MainWindowHandle;
		}
	}
	return hWnd; // 返回窗口句柄 或者 0
}
日期:2020-04-11 22:50:23 来源:oir作者:oir