日志.VC

1、

int WriteLog(char* _pcFullFileName, char* _pcWrite, int _iWriteLen, unsigned long * _pdwWritten)
{
    HANDLE hLogFile = CreateFileA(_pcFullFileName, GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_ALWAYS/*CREATE_NEW*/, 0, 0);// ZC: 存在:打开;不存在:创建
    if (hLogFile == INVALID_HANDLE_VALUE)
        return GetLastError();

    if (INVALID_SET_FILE_POINTER == SetFilePointer(hLogFile, 0, 0, FILE_END))
    {
        int iErr = GetLastError();
        CloseHandle(hLogFile);
        return iErr;
    }

    BOOL B = WriteFile(hLogFile, _pcWrite, _iWriteLen, _pdwWritten, NULL);
    if (!B)
    {
        int iErr = GetLastError();
        CloseHandle(hLogFile);
        return iErr;
    }
    CloseHandle(hLogFile);
    return 0;
}

 

2、

3、

4、

5、

 

posted @ 2019-09-30 14:03  CppSkill  阅读(112)  评论(0编辑  收藏  举报