⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debuglog.cpp

📁 穿防火墙源代码
💻 CPP
字号:
/*	produce   logs
*/
#include 	<windows.h>
#include 	<stdio.h>
#include "debuglog.h"

#define  LOGFILENAME  "d:\\debuglog.txt"

HANDLE hlogFile; 

int  debugloginit()
{
	hlogFile = CreateFile(LOGFILENAME,    // file to open
                   GENERIC_READ | GENERIC_WRITE,          // open for reading
                   FILE_SHARE_READ,       // share for reading
                   NULL,                  // default security
                   OPEN_ALWAYS,         // existing file only
                   FILE_ATTRIBUTE_NORMAL, // normal file
                   NULL); 
	if (hlogFile == INVALID_HANDLE_VALUE) 
	{
		OutputDebugString("debugloginit  CreateFile  error\n");
	}
	else
	{
		SetFilePointer(hlogFile,0,NULL,FILE_END);
	}
	return 0;
}

int	 debuglogClose()
{
	if  (hlogFile!=NULL)
	{
		CloseHandle (hlogFile);
	}
	return 0;
}

int logprintf(LPCSTR lpszLog)
{
	
      DWORD dwBytesWritten; 
      int nSize;
      //va_list pArglist;
	BOOL fSuccess;

	if (lpszLog==NULL)
	{
		return(-1);
	}
      nSize=strlen(lpszLog);
	  if (nSize<1)
	  {
	  	return(-1);
	  }
	 fSuccess = WriteFile(hlogFile, 
                                 lpszLog, 
                                 nSize,
                                 &dwBytesWritten, 
                                 NULL); 
	if (!fSuccess) 
      {
           OutputDebugString("WriteFile failed with error.\n");
           return (-1);
       }
	return 0;
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -