If this is your first visit, be sure to
check out the
FAQ
by clicking the
link above. You may have to
register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
dear friend whenever this code is executing on 2000 it work properly but on win-ME or 98 it not work properly .
--------------------------- code --------------------------------
#include <windows.h>
#define ID_TIMER 1
HWND app_hwnd;
int iIndex;
TCHAR szWindowData[5000];
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
static TCHAR szAppName[] = TEXT ("Beeper2") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
MessageBox (NULL, TEXT ("Program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
hwnd = CreateWindow (szAppName, TEXT ("Beeper2 Timer Demo"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL) ;
app_hwnd=hwnd;
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
return msg.wParam ;
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
DWORD dwBytesWritten;
HANDLE hFile;
int dwPos;
switch (message)
case WM_CREATE:
SetTimer (hwnd, ID_TIMER, 30000, 0) ;
return 0 ;
case WM_DESTROY:
KillTimer (hwnd, ID_TIMER) ;
PostQuitMessage (0) ;
return 0 ;
case WM_TIMER:
EnumDesktopWindows(0,EnumWindowsProc ,0 );
hFile = CreateFile("MYFILE.TXT", // open MYFILE.TXT
GENERIC_WRITE, // open for reading
0, // share for reading
NULL, // no security
OPEN_ALWAYS, // existing file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
dwPos = SetFilePointer(hFile, 0, NULL, FILE_END);
//WriteFile(hFile, szWindowData, iWindLength, &dwBytesWritten, NULL);
WriteFile(hFile, szWindowData, iIndex, &dwBytesWritten, NULL);
CloseHandle(hFile);
return 0 ;
return DefWindowProc (hwnd, message, wParam, lParam) ;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
int iWindLength,i;
TCHAR szText [255];
iWindLength= GetWindowText (hwnd, szText, sizeof (szText)) ;
if ( szText!= NULL )
szText[iWindLength]='\r';
iWindLength++;
szText[iWindLength]='\n';
iWindLength++;
for(i=0;i<iWindLength;i++)
szWindowData[++iIndex]=szText[i];
return 1;
Advertiser Disclosure:
Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.