Hi,
need urgent help. I am trying to check that IE is launched or not, if
yes then close it.
Can someone help me to write a code for this problem. I did try
GetActiveWindow then CloseMainWindow but doesn't work.
other approche is here...
int _tmain(int argc, _TCHAR* argv[])
{
//HWND hActiveWindow = GetActiveWindow();
MessageBox(GetActiveWindow(),hehe,"Checking",MB_OK);
/*LPCWSTR wName = L"Untitled - Notepad";
HWND hndl = FindWindow(NULL, wName);
if (hndl == NULL)
{
DWORD dw=GetLastError();
A a;
a.ErrorExit(TEXT("_tmain"));
}*/
//CloseWindow(hActiveWindow);
}
void A::ErrorExit(LPTSTR lpszFunction)
{
// Retrieve the system error message for the last-error code
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
// Display the error message and exit the process
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
(lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR));
StringCchPrintf((LPTSTR)lpDisplayBuf,
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("%s failed with error %d: %s"),
lpszFunction, dw, lpMsgBuf);
MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
ExitProcess(dw);
}
thanks,
Raj