您的位置:首页 > 移动开发

变长参数的函数写法

2011-04-26 10:13 141 查看
//*****************************************************************************************
//                Template No. SWF0012   Template Version No. 04.04.00
//
//*****************************************************************************************
//   FUNCTION NAME    : PrintLog()
//
//-------------------------------------------------- PURPOSE -----------------------------------------
//
//     Print a text in log file
//---------------------------------------- $$ REQUIREMENTS $$ ----------------------------------------
//
//  Format: $${TAG} R[#][Prod. ID]:Specification Path
//
//               $$:    ISGcq00622453
//                TAG:    [APP_GEN]
//              R #:    R[29]
//            Prod.ID:
//        Spec. Path:   /vob/
//
//
//
//-------------------- PSEUDO CODE / DETAILED FUNCTION DESCRIPTION -------------------
//
//            Creates a log file with the phone info
//
//------------------------------------------------ REVISIONS ------------------------------------------
// Date       Name                 Tracking #     Description
// ---------  -------------------  -------------  ------------------------------
// 26ARP2011  Feng Liu             ISGcq00622453  Initial Creation
//*****************************************************************************************************
//
//----------------------------------------- FUNCTION DEFINITION ---------------------------------------
void FeatureDisableDlg::PrintLog(CString& message)
{
if(APPLICATION_VERSION[0] != 'R')
{
try
{
//verify if it is already opened
if (m_logFile.m_hFile == CFile::hFileNull)
{
if(m_logFile.Open(LOG_FILE_NAME,
CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite))
{
m_logFile.SeekToEnd();
CString log;
log.Format("=====================================================/n",log);
time_t rawtime;
time ( &rawtime );
char timeStr[0x100];

if(!ctime_s(timeStr, 0x100, &rawtime)) {
log.Format("Execution date: %s", timeStr);
} else {
log.Format("Execution date: %s", "Can not read the time.");
}

m_logFile.Write(log, log.GetLength());
}
}
m_logFile.Write(message, message.GetLength());
}
catch (...)
{
}
}
}void FeatureDisableDlg::PrintLog(const char* message, ...)
{
//  if(APPLICATION_VERSION[0] != 'R')
if(1)
{
va_list list;
va_start(list, message);
char szBuffer[MAX_OUTPUT_TEXT_SIZE];
_vsnprintf_s(szBuffer, sizeof(szBuffer), message, list);

CString log(szBuffer);
PrintLog(log);

va_end(list);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息