Here's my code so far with some error fixes and stuff added and the recources attacched - I need help, though...
Code:
// Download Recorder - started by Chris Pocock - AKA "face_master"
// Used to record and log every byte that is downloaded
// Needs socket functionality
// Needs main dialog box recource + dialog box controls
#include <windows.h>
#include <fstream.h>
#include <time.h>
#include "Resource.h"
#define ID_TIMER 1
// Globals
int byte_count = 0; // Count of how much is downloaded
int just_downloaded = 0; // Amount downloaded in last second,
// though, i'm not sure how you would
// effectively store the last bytes
// downloaded in the last second into
// this variable...
char byte_display[MAX_PATH];
char time_str[MAX_PATH];
// Prototypes
void GetDownloadValue();
void ExportLog();
void DisplayLog(HWND);
void GetTime();
// Callbacks
BOOL CALLBACK APP_DlgProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(
HINSTANCE hInstance, HINSTANCE hPrevious, LPTSTR lpsz, int iCmd)
{
// Run main dialog
BOOL b = DialogBox(hInstance, "DLG_MAIN", NULL, APP_DlgProc);
return b;
}
BOOL CALLBACK APP_DlgProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch(uiMsg)
{
case WM_INITDIALOG:
SetTimer(hDlg, ID_TIMER, 1000, NULL);
break;
case WM_TIMER: // Handle timer messages
byte_count += just_downloaded;
itoa(byte_count, byte_display, 10);
SetDlgItemText(hDlg, IDC_BYTES, byte_display);
case WM_COMMAND:
switch(wParam)
{
case IDC_ABOUT:
MessageBox(hDlg, "Records your downloads and displays them. Current version completely written by Chris Pocock ('face_master').", "Download Recorder", MB_OK);
break;
case IDC_SHOWLOG:
DisplayLog(hDlg);
break;
case IDOK:
case IDCANCEL:
KillTimer(hDlg, ID_TIMER);
EndDialog(hDlg, FALSE);
return FALSE;
}
break;
}
return FALSE;
}
void GetDownloadValue() // Needs alot of work which I cannot attend to regarding sockets etc...
{
// alter 'just_downloaded' variable so it contains the amount of bytes that
// were just downloaded
}
void ExportLog()
{
char log_data[MAX_PATH];
itoa(byte_count, log_data, 10);
GetTime();
ofstream log("log.dat", ios::ate);
log << "Log Entry at: ";
log << time_str;
log << "\n";
log << log_data;
log << "\n\n";
}
void GetTime() // Dunno if I did any of this right -
{ // i've never used any of these before
time_t Time;
time( Time );
time_str = ctime(Time);
}
void DisplayLog(HWND hDlg) // Set the text inside an edit control in the dialog box
{
char log_str[MAX_PATH]; // Used to store the contents of the log
// First import the contents of the log file into 'log_str'
// not done yet...
SetDlgItemText(hDlg, IDC_LOG, log_str);
}
But I get these errors...
Code:
error C2664: 'time' : cannot convert parameter 1 from 'long' to 'long *'
'ctime' : cannot convert parameter 1 from 'long' to 'const long *'