Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

close window

Featured Replies

Posted

i want to inject some code into a running process. This process have a gui and uses a window. (I know the handle of this window)


 


so i want to close this window, but let the process running.


 


i used the API DestroyWindow but get a 0x5 error ( acces denied ), because i dont know the thread which created the window. ( GetCurrentThreadId is not the answer).


 


so my question is do you know a way how to close/destroy a window knowing its handle, but NOT closing the process, just the window of it?


 


 


http://msdn.microsoft.com/en-us/library/windows/desktop/ff381396(v=vs.85).aspx



Closing the Window
When the user closes a window, that action triggers a sequence of window messages.
The user can close an application window by clicking the Close button, or by using a keyboard shortcut such as ALT+F4. Any of these actions causes the window to receive a WM_CLOSE message. The WM_CLOSE message gives you an opportunity to prompt the user before closing the window. If you really do want to close the window, call the DestroyWindow function. Otherwise, simply return zero from the WM_CLOSE message, and the operating system will ignore the message and not destroy the window.
Here is an example of how a program might handle WM_CLOSE.
case WM_CLOSE:
if (MessageBox(hwnd, L"Really quit?", L"My application", MB_OKCANCEL) == IDOK)
{
DestroyWindow(hwnd);
}
// Else: User canceled. Do nothing.
return 0; In this example, the MessageBox function shows a modal dialog that contains OK and Cancel buttons. If the user clicks OK, the program calls DestroyWindow. Otherwise, if the user clicks Cancel, the call to DestroyWindow is skipped, and the window remains open. In either case, return zero to indicate that you handled the message.
If you want to close the window without prompting the user, you could simply call DestroyWindow without the call to MessageBox. However, there is a shortcut in this case. Recall that DefWindowProc executes the default action for any window message. In the case of WM_CLOSE, DefWindowProc automatically calls DestroyWindow. That means if you ignore the WM_CLOSE message in your switch statement, the window is destroyed by default.
When a window is about to be destroyed, it receives a WM_DESTROY message. This message is sent after the window is removed from the screen, but before the destruction occurs (in particular, before any child windows are destroyed).
In your main application window, you will typically respond to WM_DESTROY by calling PostQuitMessage. case WM_DESTROY:
PostQuitMessage(0);
return 0;
We saw in the Window Messages section that PostQuitMessage puts a WM_QUIT message on the message queue, causing the message loop to end.
Here is a flow chart showing the typical way to process WM_CLOSE and WM_DESTROY messages:

post-70577-0-96392100-1400701725_thumb.p


 


Flow chart showing how to handle WM_CLOSE and WM_DESTROY messages


Edited by Dreamer

  • Author

thank you but already tried both ways, but result is the same; closing/terminating the process, so that is not what i want


Hey,

You could try:

HWND hwndDlg; //your window handleEnableWindow(hwndDlg, FALSE);ShowWindow(hwndDlg, SW_HIDE);
This will keep the window running in the background, but it will be hidden and no input will be possible.

Greetings

u can see  this video 


www.youtube.com/watch?v=h54jlxpyT3w


it will give u example.


Edited by Death

  • Author

Mr. eXoDia

thank you the code works flawless.

however is there really no way to delete/close the window instead of just hiding it?

i know a process window can terminate disable enable suspend kill or pause or like this  .


 


lolll



delete the window
 

Then inject code , nice question . xd


Edited by Death

If you destroy the window and the program is still outputting to it (or possibly waiting for input) it's likely always going to crash. The safest option would be to hide the window and then at least the program still has a window to communicate with. After it has been hidden you can delete the tab from the taskbar with ITaskBarList and DeleteTab...


 


http://msdn.microsoft.com/en-us/library/windows/desktop/bb774648%28v=vs.85%29.aspx


 


Ted.


  • Author

thanks teddy and exodia for helping me out!


Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.