1 将Cstring转成TCHAR*
StrToTchar(CString temString,TCHAR * pTchar)
{
int tmpLength=0 ;
tmpLength = temString.GetLength();
TCHAR * ptemTchar = temString.GetBuffer(tmpLength);
wcscpy( pTchar,ptemTchar);
}
2 获取系统时间
CString GetSysTime()
{//得到系统时间
CString strTime;
SYSTEMTIME st;
::GetLocalTime(&st);
TCHAR datetime[20];
TCHAR times[20];
GetDateFormat(LOCALE_USER_DEFAULT,NULL,&st,_T("yyyy-MM-dd"),datetime,20);
GetTimeFormat(LOCALE_USER_DEFAULT,NULL,&st,_T("HH:mm:ss"),times,20);
strTime = (CString)datetime + _T(" ")+(CString)times;
return strTime;
}
CTime t = CTime::GetCurrentTime();
SelfInfo[8] = IntToStr(t.GetYear());
SelfInfo[9] = IntToStr(t.GetMonth());
SelfInfo[10] = IntToStr(t.GetDay());
3 写日志
void Writelog(char *str)
{
FILE *fp;
fp = fopen("\\Storage\\LogFile.txt","w+");
if(!fp)
{
return;
}
fprintf(fp,"%s\n",str);
fclose(fp);
return;
}
posted on 2008-06-23 03:59
幽幽 阅读(313)
评论(0) 编辑 收藏 引用 所属分类:
杂集