1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| #include <windows.h>
#include <tchar.h>
#include <psapi.h>
bool getFullscreenActiveWindow(HWND toto);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HWND toto;
char * caption = new char[255];
int full = 0;
int close = 0;
STARTUPINFO sInfo;
PROCESS_INFORMATION pInfo;
HMODULE hMod;
DWORD cbNeeded;
BOOL Result;
ZeroMemory(&sInfo,sizeof(sInfo));
ZeroMemory(&pInfo,sizeof(pInfo));
CreateProcess("c:\\docklets\\YzDock.exe", 0
, 0, 0, TRUE, NORMAL_PRIORITY_CLASS, 0, 0, &sInfo, &pInfo);
WaitForInputIdle(pInfo.hProcess, 500);
while (1)
{
full = 0;
toto = GetForegroundWindow();
GetWindowText(toto,caption,254);
Result = EnumProcessModules(pInfo.hProcess, &hMod, sizeof(hMod), &cbNeeded);
if (toto && strcmp(caption,"Program Manager"))
{
if (getFullscreenActiveWindow(toto) )
full = 1;
}
if (!Result && full == 0)
{
CreateProcess("c:\\docklets\\YzDock.exe", 0
, 0, 0, TRUE, NORMAL_PRIORITY_CLASS, 0, 0, &sInfo, &pInfo);
}
if (Result && full == 1)
{
TerminateProcess(pInfo.hProcess, (UINT)0);
CloseHandle(pInfo.hProcess);
}
Sleep(1500);
}
return 0;
}
bool getFullscreenActiveWindow(HWND toto)
{
RECT clsRect;
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
if (!GetWindowRect(toto, &clsRect))
{
free(toto);
return false;
}
if (clsRect.top <= 0 && clsRect.left <= 0 &&clsRect.right >= cx && clsRect.bottom >= cy)
{
free(toto);
return true;
}
free(toto);
return false;
} |
Partager