开发者

Assigning a window handle from a literal value

For a c# program to hide the window of another running program. the logic is

foreach (Process proc in Process.GetProcesses())
            {
                if (proc.MainWindowTitle.StartsWith("Some_title"))
                {
                    handle = proc.MainWindowHandle;
             } 
            }...
...
SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, 0x0001 | 0x0002 | 0x0004 | 0x0010 | 0x0080);
...
//later to unhide
 SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, 0x0001 | 0x0002 | 0x0004 | 0x0040);

now if i terminate the program before unhiding the window, i lose the handle of the window which i set to hide. Iterating again through the process list will not get me the hidden window's handle again, since(probably) the hidden window is not the ma开发者_如何学编程in window anymore for that process. [and it is a chat client with multiple windows]

any method that you can think of, to save the window handle to a file between invocations of the program , and to do the unhiding at a later point?

i have tried, but literals cannot be assigned back to IntPtr type for using as the handles.


int literal = 10;
IntPtr handle = new IntPtr(literal);

doesnt serve your needs?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜