Right I have got everything working apart from one thing, thats when the computer is turned off it doesn't run get_second_time();!! I am extreamly new to programming in windows and I have just copied and pasted my Procedure from a program I made with the help of a tutorial (I have changed it slightly to try and make it work) and I think its that procedure which isn't working currectly!!
Code:
#include <windows.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
void remove_char( char *string, const char item )
{
char *at = strchr( string, item );
while( *at ) *at++ = *(at + 1);
}
void get_first_time()
{
FILE *fp;
char first_time[25];
time_t timer;
timer=time(NULL);
strcpy(first_time,asctime(localtime(&timer)));
timer=time(NULL);
fp = fopen("c:\\log.txt", "at");
remove_char( first_time, '\n' );
fprintf(fp,"%s --> ",first_time);
fclose(fp);
}
void get_second_time()
{
FILE *fp;
char second_time[25];
time_t timer;
timer=time(NULL);
strcpy(second_time,asctime(localtime(&timer)));
timer=time(NULL);
fp = fopen("c:\\log.txt", "at");
fprintf(fp,"%s-____________________-\n\n",second_time);
fclose(fp);
}
LRESULT CALLBACK Procedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
get_second_time();
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain( HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int WinMode )
{
MSG Msg;
get_first_time();
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
return 0;
}