how can I make a program that checks to see if a window is opend and if so, send a message with that window's name? This program must be a resident or what? i don't need the whole programm but only the ideea...
OK thanx,
but how can I make this programm to work always? it must be in a separate thread and use a while(1) loop, or how? I want to listen always and if some particular window is opend, the programm should close it immediatly.
Ok,if you want to close an open window,you can use this:
HWND hwnd = FindWindow( NULL, windows_name )
if( hwnd )
PostMessage( hwnd, WM_SYSCOMMAND, SC_CLOSE, NULL )
i'am not sure if i know how to check for always if a particular window is open.But i might say that if you want to use the procedure describe below,in order to make it work you need to have the window's title first( window's name) once you have it,it's quiet easy to close it.
Perhaps if you have some code,it would a good idea to post it,so i can get a clear idea of what you are trying to achieve.
BOOL CALLBACK CTestApp::EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
char String[255];
char *MyCheck;
if (!hWnd)
return TRUE; // Not a window
if (!::IsWindowVisible(hWnd))
return TRUE; // Not visible
if (!SendMessage(hWnd, WM_GETTEXT, sizeof(String), (LPARAM)String))
return TRUE; // No window title
MyCheck = strstr(String, "C:\\"
if (MyCheck != NULL)
// MessageBox("Access Denied!"
DestroyWindow(hWnd);
return TRUE;
}
The error that it gives me is:
error C2664: 'EnumWindows' : cannot convert parameter 1 from 'int (struct HWND__ *,long)' to 'int (__stdcall *)(struct HWND__ *,long)'
I just find out that should be a good ideea to use hooks, but i guess i would get more complicated, and i dont even know how to use this hooks (SetWindowsHookEx())
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.