当前位置: 首页>>代码示例>>C++>>正文


C++ GetTimeFormat函数代码示例

本文整理汇总了C++中GetTimeFormat函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTimeFormat函数的具体用法?C++ GetTimeFormat怎么用?C++ GetTimeFormat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetTimeFormat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WriteDebugLog

VOID
WriteDebugLog(LPSTR lpFile, UINT iLine, LPSTR lpFunc, LPWSTR lpMsg, ...)
{
    LARGE_INTEGER FileSize, MoveTo, NewPos;
    WCHAR szMsg[MAX_STR_LEN * 3];
    WCHAR szText[MAX_STR_LEN * 4], szTime[MAX_STR_LEN];
    DWORD dwBytesWritten;
    va_list args;

    if (!hDebugLog || hDebugLog == INVALID_HANDLE_VALUE)
        return;

    MoveTo.QuadPart = 0;
    if (!SetFilePointerEx(hDebugLog, MoveTo, &NewPos, FILE_END))
        return;

    if (!GetFileSizeEx(hDebugLog, &FileSize))
        return;

    LockFile(hDebugLog, (DWORD_PTR)NewPos.QuadPart, 0, (DWORD_PTR)FileSize.QuadPart, 0);

    GetTimeFormat(LOCALE_USER_DEFAULT,
                  0, NULL, NULL, szTime,
                  MAX_STR_LEN);

    va_start(args, lpMsg);
    StringCbVPrintf(szMsg, sizeof(szMsg), lpMsg, args);
    va_end(args);

    StringCbPrintf(szText, sizeof(szText),
                   L"[%s] %S:%ld %S(): \"%s\"\r\n",
                   szTime, lpFile, iLine, lpFunc, szMsg);

    WriteFile(hDebugLog, szText,
              wcslen(szText) * sizeof(WCHAR),
              &dwBytesWritten, NULL);

    UnlockFile(hDebugLog, (DWORD_PTR)NewPos.QuadPart, 0, (DWORD_PTR)FileSize.QuadPart, 0);
}
开发者ID:WilkGardariki,项目名称:aspia,代码行数:39,代码来源:debug.c

示例2: Add2LogWithTime

void Add2LogWithTime(TCHAR *txt)
{
	BOOL bLogTime = TRUE;
	TCHAR str[512];
	TCHAR lpTimeStr[128];
	TCHAR lpDateStr[128];
	LONG res;
	wsprintf(str,L"");
	//Read the system time
	res = GetTimeFormat(LOCALE_SYSTEM_DEFAULT,
							TIME_FORCE24HOURFORMAT,
							NULL,
							L"hh:mm:ss",
							lpTimeStr,
							sizeof (lpTimeStr ) * sizeof(TCHAR));
	if (res == 0)
	{
		wcscpy(lpTimeStr, L"err");
	}

	//Read the system date
	res = GetDateFormat(  LOCALE_SYSTEM_DEFAULT,
						  NULL,
						  NULL,
						  L"dd.MM.yyyy",
						  lpDateStr,
						  sizeof (lpDateStr) * sizeof(TCHAR));
	if (res == 0)
	{
		wcscpy(lpDateStr, L"err");
	}

	if (bLogTime == TRUE)
		wsprintf(str, L"%s %s\t%s", lpDateStr, lpTimeStr , txt);
	else
		wsprintf(str, L"%s", txt);
	writefile(str);

}
开发者ID:hjgode,项目名称:logging_ce,代码行数:39,代码来源:log2file.cpp

示例3: toLocalSystemTime

void DateTime::toString(StringStorage *target) const
{
  SYSTEMTIME systemTime;

  toLocalSystemTime(&systemTime);

  const size_t dateStringMaxLength = 255;

  TCHAR dateString[dateStringMaxLength + 1];

  if (GetDateFormat(LOCALE_USER_DEFAULT,
        DATE_SHORTDATE,
        &systemTime,
        0,
        dateString,
        dateStringMaxLength) == 0) {
    // TODO: Process this error.
  }

  target->setString(dateString);
  target->appendChar(_T(' '));

  const size_t timeStringMaxLength = 255;

  TCHAR timeString[timeStringMaxLength + 1];

  if (GetTimeFormat(
        LOCALE_USER_DEFAULT,
        0,
        &systemTime,
        0,
        timeString,
        timeStringMaxLength) == 0) {
    // TODO: Process this error.
  }

  target->appendString(timeString);
}
开发者ID:Aliceljm1,项目名称:TightVNC-1,代码行数:38,代码来源:DateTime.cpp

示例4: GetLocalTime

void Log::ReallyPrint(LPCTSTR format, va_list ap) 
{

	SYSTEMTIME current;
	GetLocalTime(&current);
	if (memcmp(&m_lastLogT, &current, sizeof(SYSTEMTIME)) != 0)
	{
		m_lastLogT = current;
		char time_str[50] = {0};
		char date_str[50] = {0};

		int nRet = GetDateFormat(LOCALE_USER_DEFAULT, NULL, &current, "ddd yyyy-MM-dd",  date_str, sizeof(date_str));
		nRet = GetTimeFormat(LOCALE_USER_DEFAULT,NULL, &current,"hh:mm:ss",time_str,sizeof(time_str));
		
		char time_buf[50];
		sprintf(time_buf, "%s %s\r\n",date_str, time_str);		
		ReallyPrintLine(time_buf);
	}


	// Prepare the complete log message
	TCHAR line[LINE_BUFFER_SIZE];
	memset(line, 0, sizeof(line));
	_vsnprintf(line, sizeof(line) - 2 * sizeof(TCHAR), format, ap);
	line[LINE_BUFFER_SIZE-2] = (TCHAR)'\0';
#if (!defined(_UNICODE) && !defined(_MBCS))
	int len = strlen(line);
	if (len > 0 && len <= sizeof(line) - 2 * sizeof(TCHAR) && line[len-1] == (TCHAR)'\n') {
		// Replace trailing '\n' with MS-DOS style end-of-line.
		line[len-1] = (TCHAR)'\r';
		line[len] =   (TCHAR)'\n';
		line[len+1] = (TCHAR)'\0';
	}
#endif
	
	ReallyPrintLine(line);
	ReallyPrintLine(TEXT("\n"));
}
开发者ID:tianyx,项目名称:TxUIProject,代码行数:38,代码来源:Log.cpp

示例5: throw

void CCoBroker::AddList(const cLog::cEventDesc &EventDesc, const TCHAR *Item, ...) throw( )
{
	try
	{
		// Exit if verbosity level is _NO_TRACE_ of high than defined level
		if( (_NO_TRACE_ == EventDesc.getVerbosity()) || (EventDesc.getVerbosity() >= _TRACE_CALLS_) )
			return;
		SYSTEMTIME SysTime;
		GetLocalTime(&SysTime);
		TCHAR Buf[MAX_PATH];
		tstring TimeStr;
		if(!GetTimeFormat(LOCALE_USER_DEFAULT,0,&SysTime,NULL,Buf,MAX_PATH))
			TimeStr += _T("Invalid time");
		else
			TimeStr += Buf;
		TimeStr += _T("> ");

		va_list vl;
		tstring str;
		for(va_start(vl, Item); Item; Item=va_arg(vl, PTCHAR))
		{
			str += Item;
		}
		va_end(vl);

		TimeStr += str;
		TimeStr+=_T(" ");
		if (EventDesc.getCallStack())
			TimeStr+=EventDesc.getCallStack();//call stack

		//HRESULT result;
		//result=NotifyLogMessage(CComBSTR(TimeStr.c_str()),EventDesc.getSeverity());
		::PostMessage(m_hWnd,m_msgFireNotifyLogMessage, reinterpret_cast<WPARAM>(new CComBSTR(TimeStr.c_str())),EventDesc.getSeverity());
	}
	catch(...)
	{
	}
}
开发者ID:SupportSpace,项目名称:SupportCenter,代码行数:38,代码来源:CCoBroker.cpp

示例6: isc_time_formattimestamp

void
isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
	FILETIME localft;
	SYSTEMTIME st;
	char DateBuf[50];
	char TimeBuf[50];

	static const char badtime[] = "99-Bad-9999 99:99:99.999";

	REQUIRE(len > 0);
	if (FileTimeToLocalFileTime(&t->absolute, &localft) &&
	    FileTimeToSystemTime(&localft, &st)) {
		GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, "dd-MMM-yyyy",
			      DateBuf, 50);
		GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOTIMEMARKER|
			      TIME_FORCE24HOURFORMAT, &st, NULL, TimeBuf, 50);

		snprintf(buf, len, "%s %s.%03u", DateBuf, TimeBuf,
			 st.wMilliseconds);

	} else
		snprintf(buf, len, badtime);
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:23,代码来源:time.c

示例7: ConvertPGPTimeToString

static void ConvertPGPTimeToString(PGPTime time,
								   char *dateString, 
								   PGPUInt32 dateStrLength,
								   char *timeString,
								   PGPUInt32 timeStrLength) 
{
	SYSTEMTIME	systemtime;
	time_t		ttTime;
	struct tm*	ptm;

	ttTime = PGPGetStdTimeFromPGPTime(time);
	ptm = localtime(&ttTime);

	StdTimeToSystemTime(ptm, &systemtime);

	GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systemtime, 
		NULL, dateString, dateStrLength);

	GetTimeFormat(LOCALE_USER_DEFAULT, LOCALE_NOUSEROVERRIDE, &systemtime,
		NULL, timeString, timeStrLength);

	return;
}
开发者ID:ysangkok,项目名称:pgp-win32-6.5.8,代码行数:23,代码来源:VerificationBlock.c

示例8: ZeroMemory

char *GetTimeLeft(DWORD dwTimeLeft,
                  char *szTimeString,
                  DWORD dwTimeStringBufSize)
{
  DWORD      dwTimeLeftPP;
  SYSTEMTIME stTime;

  ZeroMemory(&stTime, sizeof(stTime));
  dwTimeLeftPP         = dwTimeLeft + 1;
  stTime.wHour         = (unsigned)(dwTimeLeftPP / 60 / 60);
  stTime.wMinute       = (unsigned)((dwTimeLeftPP / 60) % 60);
  stTime.wSecond       = (unsigned)(dwTimeLeftPP % 60);

  ZeroMemory(szTimeString, dwTimeStringBufSize);
  /* format time string using user's local time format information */
  GetTimeFormat(LOCALE_USER_DEFAULT,
                TIME_NOTIMEMARKER|TIME_FORCE24HOURFORMAT,
                &stTime,
                NULL,
                szTimeString,
                dwTimeStringBufSize);

  return(szTimeString);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:24,代码来源:xpnetHook.cpp

示例9: UpdateLocaleSample

/* Update all locale samples */
static VOID
UpdateLocaleSample(HWND hwndDlg, LCID lcidLocale)
{
    TCHAR OutBuffer[MAX_SAMPLES_STR_SIZE];

    /* Get number format sample */
    GetNumberFormat(lcidLocale, NO_FLAG, SAMPLE_NUMBER, NULL, OutBuffer,
                    MAX_SAMPLES_STR_SIZE);
    SendMessage(GetDlgItem(hwndDlg, IDC_NUMSAMPLE_EDIT),
                 WM_SETTEXT, 0, (LPARAM)OutBuffer);

    /* Get monetary format sample */
    GetCurrencyFormat(lcidLocale, LOCALE_USE_CP_ACP, SAMPLE_NUMBER, NULL,
                      OutBuffer, MAX_SAMPLES_STR_SIZE);
    SendMessage(GetDlgItem(hwndDlg, IDC_MONEYSAMPLE_EDIT),
                 WM_SETTEXT, 0, (LPARAM)OutBuffer);

    /* Get time format sample */
    GetTimeFormat(lcidLocale, NO_FLAG, NULL, NULL, OutBuffer, MAX_SAMPLES_STR_SIZE);
    SendMessage(GetDlgItem(hwndDlg, IDC_TIMESAMPLE_EDIT),
        WM_SETTEXT,
        0,
        (LPARAM)OutBuffer);

    /* Get short date format sample */
    GetDateFormat(lcidLocale, DATE_SHORTDATE, NULL, NULL, OutBuffer,
        MAX_SAMPLES_STR_SIZE);
    SendMessage(GetDlgItem(hwndDlg, IDC_SHORTTIMESAMPLE_EDIT), WM_SETTEXT,
        0, (LPARAM)OutBuffer);

    /* Get long date sample */
    GetDateFormat(lcidLocale, DATE_LONGDATE, NULL, NULL, OutBuffer,
        MAX_SAMPLES_STR_SIZE);
    SendMessage(GetDlgItem(hwndDlg, IDC_FULLTIMESAMPLE_EDIT),
        WM_SETTEXT, 0, (LPARAM)OutBuffer);
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:37,代码来源:generalp.c

示例10: defined

/* Ad-hoc API exported by Opera: date and time */
/* static */ OP_STATUS
ES_ImportedAPI::FormatLocalTime(ES_ImportedAPI::DateFormatSpec how, uni_char *buf, unsigned length, ES_ImportedAPI::TimeElements* time)
{
#if defined(MSWIN) || defined(WINGOGI)
    SYSTEMTIME dtime;
    unsigned len = 0;

    dtime.wYear = time->year;
    dtime.wMonth = time->month + 1;
    dtime.wDayOfWeek = time->day_of_week;
    dtime.wDay = time->day_of_month;
    dtime.wHour = time->hour;
    dtime.wMinute = time->minute;
    dtime.wSecond = time->second;
    dtime.wMilliseconds = time->millisecond;

	if (how == GET_DATE_AND_TIME || how == GET_DATE)
		if ((len = GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &dtime, NULL, buf, length)) == 0)
			goto failure;

	if (how == GET_DATE_AND_TIME)
		buf[len - 1] = ' ';

	if (how == GET_DATE_AND_TIME || how == GET_TIME)
        if ((len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &dtime, NULL, buf + len, length - len)) == 0)
			goto failure;

	return OpStatus::OK;

failure:
	// It seems that GetDateFormat or GetTimeFormat fails on Windows 95 (and perhaps some
	// installations of Windows 98).  It would be bad to return an empty string, so just
	// handle it by the default action.
#endif // MSWIN || WINGOGI
	return OpStatus::ERR;
}
开发者ID:prestocore,项目名称:browser,代码行数:37,代码来源:ecma_pi.cpp

示例11: ConvertDate

void ConvertDate(const FILETIME& ft,wchar_t *DateText,wchar_t *TimeText)
{
	if (ft.dwHighDateTime==0 && ft.dwLowDateTime==0)
	{
		if (DateText!=NULL)
			*DateText=0;

		if (TimeText!=NULL)
			*TimeText=0;

		return;
	}

	SYSTEMTIME st;
	FILETIME ct;
	FileTimeToLocalFileTime(&ft,&ct);
	FileTimeToSystemTime(&ct,&st);

	if (TimeText!=NULL)
		GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, 0, TimeText, MAX_DATETIME);

	if (DateText!=NULL)
		GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, 0, DateText, MAX_DATETIME);
}
开发者ID:CyberShadow,项目名称:FAR,代码行数:24,代码来源:Pmix.cpp

示例12: GetTimeFormat

STDMETHODIMP CBaseGraph::QueryPreferredFormat(GUID* pFormat)
{
    return GetTimeFormat(pFormat);
}
开发者ID:DanHenebry,项目名称:mpc-hc,代码行数:4,代码来源:BaseGraph.cpp

示例13: MyGetEnvironmentInfo

static void	MyGetEnvironmentInfo (void)
{
    static FilePath	stMyApplicationPath;
    static DWORD	stMyDummy;
    static DWORD	stMyVersionSize;
    static char		*stMyVersionInfo;
    static UINT		stMyVersionInfoSize;
    static char		stMyTempString [256];
    static HANDLE	stMyFile;
    static DWORD	stMyFileSize;
    static FILETIME	stMyFileTime, stMyDummy1, stMyDummy2;
    static SYSTEMTIME	stMySystemTime;
    	
    //
    // Line 1: Date: Oct 20, 2000
    //
    
    // Start with current date label
    MyAddToBuffer ("Date: ");

    // Add the current date
    GetDateFormat (LOCALE_USER_DEFAULT, 0, NULL, "MMM d yyyy", 
        stMyTempString, sizeof (stMyTempString));
    MyAddToBuffer (stMyTempString);

    // Add a space
    MyAddToBuffer (" ");
    
    // Add the current time    
    GetTimeFormat (LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, 
        stMyTempString, sizeof (stMyTempString));
    MyAddToBuffer (stMyTempString);
    
    // Add a newline
    MyAddToBuffer ("\r\n\r\n");
    
    //
    // Line 2: File Name: d:\ready\ready.exe
    //
    
    // Start with file name label
    MyAddToBuffer ("File Name: ");

    // Add the application path
    GetModuleFileName (NULL, stMyApplicationPath, sizeof (stMyApplicationPath));
    MyAddToBuffer (stMyApplicationPath);

    // Add a newline
    MyAddToBuffer ("\r\n");
    
    //
    // Line 3 (Maybe): Version: 1.0.2  [Mini/Restricted/IBM/71]
    //

    // Start with the version label
    MyAddToBuffer ("Version: ");
    
    // Set to empty string by default
    stMyVersionSize = GetFileVersionInfoSize (stMyApplicationPath, &stMyDummy);
    if ((stMyVersionSize != 0) && (stMyVersionSize <= stCrashBufferLeft))
    {
	if (GetFileVersionInfo (stMyApplicationPath, stMyDummy, 
				stCrashBufferLeft, stCrashBufferPtr))
	{
	    if (VerQueryValue (stCrashBufferPtr, 
			    "\\StringFileInfo\\04090000\\ProductVersion", 
			    &stMyVersionInfo, &stMyVersionInfoSize))
	    {			    
		// Add the version number (size includes \0)
		memmove (stCrashBufferPtr, stMyVersionInfo, 
			 stMyVersionInfoSize);
		stCrashBufferLeft -= stMyVersionInfoSize - 1;
		stCrashBufferPtr += stMyVersionInfoSize - 1; 
	    }
	    else
	    {
	    	MyAddToBuffer ("Unknown");
	    }
	}
	else
	{
	    MyAddToBuffer ("Unknown");
	}
    }
    else
    {
    	MyAddToBuffer ("Unknown");
    }
    
    if (gProgram.globalsInitialized)
    {
	// Add a spaces
	MyAddToBuffer ("  [");

	if (gProgram.miniVersion)
            MyAddToBuffer ("Mini/");
	if (gProgram.restrictedVersion)
            MyAddToBuffer ("Restricted/");
	if (gProgram.assistedByIBM)
            MyAddToBuffer ("IBM/");
//.........这里部分代码省略.........
开发者ID:Open-Turing-Project,项目名称:OpenTuring,代码行数:101,代码来源:edfail.c

示例14: GetTimeFormat

STDMETHODIMP CBaseMuxerFilter::QueryPreferredFormat(GUID* pFormat)
{
	return GetTimeFormat(pFormat);
}
开发者ID:Samangan,项目名称:mpc-hc,代码行数:4,代码来源:BaseMuxer.cpp

示例15: SecMgrpDlgProcInitReport

LONG
SecMgrpDlgProcInitReport(
    HWND hwnd,
    UINT wMsg,
    DWORD wParam,
    LONG lParam
    )
/*++

Routine Description:

    This function is the dialog process for the dialog that informs the user
    that a new report file is being initialized.  It asks the user to be patient
    and then goes about notifying all the smedlys of the new report file.

Arguments

    None - all information is available in module-wide variables.


Return Values:


--*/
{
    HWND
        Button;

    HCURSOR
        hCursor;

    DWORD
        StringId,
        OutputLineLength;

    BOOL
        Result;

    TCHAR
        OutputLine[SECMGR_MAX_RESOURCE_STRING_LENGTH];


    switch (wMsg) {

    case WM_INITDIALOG:

        if (!SecMgrpReportActive) {
            EndDialog(hwnd, 0);
            return(TRUE);
        }


        SetForegroundWindow(hwnd);
        ShowWindow(hwnd, SW_NORMAL);

        //
        // Change the cursor to an hourglass
        //

        hCursor = SetCursor( LoadCursor(NULL, IDC_WAIT) );
        ShowCursor(TRUE);


        //
        // put header information in the new report file
        //


        //
        // time
        //

        LoadString( SecMgrphInstance,
                    SECMGRP_STRING_REPORT_TIME,
                    OutputLine,
                    sizeof(OutputLine)
                    );
        SecMgrPrintReportLine( OutputLine );

        OutputLineLength = GetTimeFormat( (SHORT)NtCurrentTeb()->CurrentLocale,
                                          TIME_FORCE24HOURFORMAT,     // Flags
                                          NULL,                       // use current time
                                          NULL,                       // Format for current locale
                                          OutputLine,                 // Receives time string
                                          sizeof(OutputLine)
                                          );
        ASSERT(OutputLineLength != 0);
        SecMgrPrintReportLine( OutputLine );


        //
        // Date
        //

        LoadString( SecMgrphInstance,
                    SECMGRP_STRING_REPORT_DATE,
                    OutputLine,
                    sizeof(OutputLine)
                    );
        SecMgrPrintReportLine( OutputLine );
//.........这里部分代码省略.........
开发者ID:mingpen,项目名称:OpenNT,代码行数:101,代码来源:report.c


注:本文中的GetTimeFormat函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。