v 1. Edited by Semaj as cpp at 2007-09-23 05:58:56 MSK and set expiration to 2007-09-26 05:58:56 MSK.
v 1. Edited by Anonymous as cpp at 2009-10-24 01:47:38 MSK and set expiration to 2009-10-24 13:47:38 MSK.
Paste will expire never.
- private void btnDoSome_Click(object sender, EventArgs e)
- {
- IntPtr hWnd = WinApi.DeepFindWindow("DesktopExplorerWindow");
- if (hWnd != IntPtr.Zero)
- {
- WinApi.SetWindowPos(hWnd, IntPtr.Zero, 0, 128,240, 320, 0);
- }
- }
- class WinApi
- {
- public const int GW_HWNDFIRST = 0;
- public const int GW_HWNDNEXT = 2;
- [DllImport("coredll.dll", EntryPoint = "GetActiveWindow")]
- internal static extern IntPtr GetActiveWindow();
- [DllImport("coredll.dll", EntryPoint = "GetParent")]
- internal static extern IntPtr GetParent(IntPtr hWnd);
- [DllImport("coredll.dll", EntryPoint = "GetClassName")]
- internal static extern int GetClassName(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount);
- [DllImport("coredll.dll", EntryPoint = "SetWindowPos")]
- internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hwndParent, int X, int Y, int CX, int CY, uint uFlags);
- public static IntPtr DeepFindWindow(string sClassName)
- {
- IntPtr hWnd = GetActiveWindow();
- hWnd = GetWindow(hWnd, GW_HWNDFIRST);
- while (hWnd != IntPtr.Zero)
- {
- IntPtr hWndPar = GetParent(hWnd);
- if (hWndPar == IntPtr.Zero)
- {
- StringBuilder strBClass = new StringBuilder(64);
- GetClassName(hWnd, strBClass, 64);
- if (strBClass.ToString() == sClassName) return hWnd;
- }
- hWnd = GetWindow(hWnd, GW_HWNDNEXT);
- }
- return IntPtr.Zero;
- }
- }