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


C++ FileTimeToSystemTime函数代码示例

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


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

示例1: Get_Exception_Info

//*************************************************************
LLSD WINAPI Get_Exception_Info(PEXCEPTION_POINTERS pException)
//*************************************************************
// Allocate Str[DUMP_SIZE_MAX] and return Str with dump, if !pException - just return call stack in Str.
{
	LLSD info;
	LPWSTR		Str;
	int			Str_Len;
//	int			i;
	LPWSTR		Module_Name = new WCHAR[MAX_PATH];
	PBYTE		Module_Addr;
	HANDLE		hFile;
	FILETIME	Last_Write_Time;
	FILETIME	Local_File_Time;
	SYSTEMTIME	T;

	Str = new WCHAR[DUMP_SIZE_MAX];
	Str_Len = 0;
	if (!Str)
		return NULL;
	
	Get_Version_Str(info);
	
	GetModuleFileName(NULL, Str, MAX_PATH);
	info["Process"] = ll_convert_wide_to_string(Str);
	info["ThreadID"] = (S32)GetCurrentThreadId();

	// If exception occurred.
	if (pException)
	{
		EXCEPTION_RECORD &	E = *pException->ExceptionRecord;
		CONTEXT &			C = *pException->ContextRecord;

		// If module with E.ExceptionAddress found - save its path and date.
		if (Get_Module_By_Ret_Addr((PBYTE)E.ExceptionAddress, Module_Name, Module_Addr))
		{
			info["Module"] = ll_convert_wide_to_string(Module_Name);

			if ((hFile = CreateFile(Module_Name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
				FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
			{
				if (GetFileTime(hFile, NULL, NULL, &Last_Write_Time))
				{
					FileTimeToLocalFileTime(&Last_Write_Time, &Local_File_Time);
					FileTimeToSystemTime(&Local_File_Time, &T);

					info["DateModified"] = llformat("%02d/%02d/%d", T.wMonth, T.wDay, T.wYear);
				}
				CloseHandle(hFile);
			}
		}
		else
		{
			info["ExceptionAddr"] = (int)E.ExceptionAddress;
		}
		
		info["ExceptionCode"] = (int)E.ExceptionCode;
		
		/*
		//TODO: Fix this
		if (E.ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
		{
			// Access violation type - Write/Read.
			LLSD exception_info;
			exception_info["Type"] = E.ExceptionInformation[0] ? "Write" : "Read";
			exception_info["Address"] = llformat("%08x", E.ExceptionInformation[1]);
			info["Exception Information"] = exception_info;
		}
		*/

		
		// Save instruction that caused exception.
		/*
		std::string str;
		for (i = 0; i < 16; i++)
			str += llformat(" %02X", PBYTE(E.ExceptionAddress)[i]);
		info["Instruction"] = str;
		*/
		LLSD registers;
		registers["EAX"] = (int)C.Eax;
		registers["EBX"] = (int)C.Ebx;
		registers["ECX"] = (int)C.Ecx;
		registers["EDX"] = (int)C.Edx;
		registers["ESI"] = (int)C.Esi;
		registers["EDI"] = (int)C.Edi;
		registers["ESP"] = (int)C.Esp;
		registers["EBP"] = (int)C.Ebp;
		registers["EIP"] = (int)C.Eip;
		registers["EFlags"] = (int)C.EFlags;
		info["Registers"] = registers;
	} //if (pException)
	
	// Save call stack info.
	Get_Call_Stack(pException->ExceptionRecord, pException->ContextRecord, info);

	return info;
} //Get_Exception_Info
开发者ID:Boy,项目名称:rainbow,代码行数:97,代码来源:llwindebug.cpp

示例2: HeapAlloc


//.........这里部分代码省略.........
     BOOL addNewLine = TRUE;
     for (cols=0; cols<numCols; cols++) {
      WCHAR username[24];

      /* Work out the index of the entry being pointed to */
      if (orderByCol) {
        i = (cols * numRows) + rows;
        if (i >= entry_count) continue;
      } else {
        i = (rows * numCols) + cols;
        if (i >= entry_count) continue;
      }

      /* /L convers all names to lower case */
      if (lower) {
          WCHAR *p = (fd+i)->cFileName;
          while ( (*p = tolower(*p)) ) ++p;
      }

      /* /Q gets file ownership information */
      if (usernames) {
          strcpyW (string, inputparms->dirName);
          strcatW (string, (fd+i)->cFileName);
          WCMD_getfileowner(string, username, sizeof(username)/sizeof(WCHAR));
      }

      if (dirTime == Written) {
        FileTimeToLocalFileTime (&(fd+i)->ftLastWriteTime, &ft);
      } else if (dirTime == Access) {
        FileTimeToLocalFileTime (&(fd+i)->ftLastAccessTime, &ft);
      } else {
        FileTimeToLocalFileTime (&(fd+i)->ftCreationTime, &ft);
      }
      FileTimeToSystemTime (&ft, &st);
      GetDateFormatW(0, DATE_SHORTDATE, &st, NULL, datestring,
			sizeof(datestring)/sizeof(WCHAR));
      GetTimeFormatW(0, TIME_NOSECONDS, &st,
			NULL, timestring, sizeof(timestring)/sizeof(WCHAR));

      if (wide) {

        tmp_width = cur_width;
        if ((fd+i)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
            static const WCHAR fmt[] = {'[','%','s',']','\0'};
            WCMD_output (fmt, (fd+i)->cFileName);
            dir_count++;
            tmp_width = tmp_width + strlenW((fd+i)->cFileName) + 2;
        } else {
            static const WCHAR fmt[] = {'%','s','\0'};
            WCMD_output (fmt, (fd+i)->cFileName);
            tmp_width = tmp_width + strlenW((fd+i)->cFileName) ;
            file_count++;
            file_size.u.LowPart = (fd+i)->nFileSizeLow;
            file_size.u.HighPart = (fd+i)->nFileSizeHigh;
        byte_count.QuadPart += file_size.QuadPart;
        }
        cur_width = cur_width + widest;

        if ((cur_width + widest) > max_width) {
            cur_width = 0;
        } else {
            int padding = cur_width - tmp_width;
            int toWrite = 0;
            WCHAR temp[101];

            /* Note: WCMD_output uses wvsprintf which does not allow %*
开发者ID:aragaer,项目名称:wine,代码行数:67,代码来源:directory.c

示例3: DeviceAtaHealthInfo


//.........这里部分代码省略.........

            if ((generalLog->PoweronHours.Supported == 1) && (generalLog->PoweronHours.ValidValue == 1)) {
                _tprintf(_T("\t Power-on Hours: %I64d\n"), generalLog->PoweronHours.Count);
            }

            if ((generalLog->LogicalSectorsWritten.Supported == 1) && (generalLog->LogicalSectorsWritten.ValidValue == 1)) {
                _tprintf(_T("\t Logical Sectors Written: %I64d\n"), generalLog->LogicalSectorsWritten.Count);
            }

            if ((generalLog->WriteCommandCount.Supported == 1) && (generalLog->WriteCommandCount.ValidValue == 1)) {
                _tprintf(_T("\t Write Command Count: %I64d\n"), generalLog->WriteCommandCount.Count);
            }

            if ((generalLog->LogicalSectorsRead.Supported == 1) && (generalLog->LogicalSectorsRead.ValidValue == 1)) {
                _tprintf(_T("\t Logical Sectors Read: %I64d\n"), generalLog->LogicalSectorsRead.Count);
            }

            if ((generalLog->ReadCommandCount.Supported == 1) && (generalLog->ReadCommandCount.ValidValue == 1)) {
                _tprintf(_T("\t Read Command Count: %I64d\n"), generalLog->ReadCommandCount.Count);
            }

            if ((generalLog->DateAndTime.Supported == 1) && (generalLog->DateAndTime.ValidValue == 1)) {
                // convert the value to system time

                SYSTEMTIME systemTime = {0};
                TCHAR localDate[255] = {0};
                TCHAR localTime[255] = {0};

                ULONGLONG time = generalLog->DateAndTime.TimeStamp + 0xA9741731300;

                time *= 10000;

                FileTimeToLocalFileTime((LPFILETIME)&time, (LPFILETIME)&time);
                FileTimeToSystemTime((LPFILETIME)&time, &systemTime);

                GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &systemTime, NULL, localDate, 255);
                GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systemTime, NULL, localTime, 255);

                _tprintf(_T("\t Time Stamp: %s %s\n"), localDate, localTime);
            }

            if ((generalLog->PendingErrorCount.Supported == 1) && (generalLog->PendingErrorCount.ValidValue == 1)) {
                _tprintf(_T("\t Pending Error Sectors Count: %I64d\n"), generalLog->PendingErrorCount.Count);
            }

            if ((generalLog->WorkloadUtilizaton.Supported == 1) && (generalLog->WorkloadUtilizaton.ValidValue == 1)) {
                _tprintf(_T("\t Workload Utilization Percentage: %I64d\n"), generalLog->WorkloadUtilizaton.Value);
            }

            if ((generalLog->UtilizationUsageRate.Supported == 1) && (generalLog->UtilizationUsageRate.ValidValue == 1)) {

                if (generalLog->UtilizationUsageRate.RateValidity == 0x00) {
                    //valid
                    _tprintf(_T("\t Utilization Usage Rate Percentagge: %I64d"), generalLog->UtilizationUsageRate.Value);

                    if (generalLog->UtilizationUsageRate.RateBasis == 0x0) {
                        _tprintf(_T(" (Based on the time of manufacture until the time indicated by the Date and Time TimeStamp device statistic, including times during which the device was powered off.) \n"));
                    } else if (generalLog->UtilizationUsageRate.RateBasis == 0x4) {
                        _tprintf(_T(" (Based on the time elapsed since the most recent processing of a power-on reset.) \n"));
                    } else if (generalLog->UtilizationUsageRate.RateBasis == 0x8) {
                        _tprintf(_T(" (Based on the Power-on Hours device statistic.) \n"));
                    } else if (generalLog->UtilizationUsageRate.RateBasis == 0xF) {
                        _tprintf(_T(" (Basis is undetermined.) \n"));
                    } else {
                        _tprintf(_T(" (Basis is not a valid value.) \n"));
                    }
开发者ID:Microsoft,项目名称:StorScore,代码行数:67,代码来源:ata.cpp

示例4: XCOPY_ParseCommandLine


//.........这里部分代码省略.........
            case 'Y': flags |= OPT_NOPROMPT;      break;
            case 'N': flags |= OPT_SHORTNAME;     break;
            case 'U': flags |= OPT_MUSTEXIST;     break;
            case 'R': flags |= OPT_REPLACEREAD;   break;
            case 'H': flags |= OPT_COPYHIDSYS;    break;
            case 'C': flags |= OPT_IGNOREERRORS;  break;
            case 'P': flags |= OPT_SRCPROMPT;     break;
            case 'A': flags |= OPT_ARCHIVEONLY;   break;
            case 'M': flags |= OPT_ARCHIVEONLY |
                               OPT_REMOVEARCH;    break;

            /* E can be /E or /EXCLUDE */
            case 'E': if (CompareStringW(LOCALE_USER_DEFAULT,
                                         NORM_IGNORECASE | SORT_STRINGSORT,
                                         &word[1], 8,
                                         EXCLUDE, -1) == CSTR_EQUAL) {
                        if (XCOPY_ProcessExcludeList(&word[9])) {
                          XCOPY_FailMessage(ERROR_INVALID_PARAMETER);
                          goto out;
                        } else flags |= OPT_EXCLUDELIST;
                      } else flags |= OPT_EMPTYDIR | OPT_RECURSIVE;
                      break;

            /* D can be /D or /D: */
            case 'D': if (word[2]==':' && isdigit(word[3])) {
                          SYSTEMTIME st;
                          WCHAR     *pos = &word[3];
                          BOOL       isError = FALSE;
                          memset(&st, 0x00, sizeof(st));

                          /* Microsoft xcopy's usage message implies that the date
                           * format depends on the locale, but that is false.
                           * It is hardcoded to month-day-year.
                           */
                          st.wMonth = _wtol(pos);
                          while (*pos && isdigit(*pos)) pos++;
                          if (*pos++ != '-') isError = TRUE;

                          if (!isError) {
                              st.wDay = _wtol(pos);
                              while (*pos && isdigit(*pos)) pos++;
                              if (*pos++ != '-') isError = TRUE;
                          }

                          if (!isError) {
                              st.wYear = _wtol(pos);
                              while (*pos && isdigit(*pos)) pos++;
                              if (st.wYear < 100) st.wYear+=2000;
                          }

                          if (!isError && SystemTimeToFileTime(&st, &dateRange)) {
                              SYSTEMTIME st;
                              WCHAR datestring[32], timestring[32];

                              flags |= OPT_DATERANGE;

                              /* Debug info: */
                              FileTimeToSystemTime (&dateRange, &st);
                              GetDateFormatW(0, DATE_SHORTDATE, &st, NULL, datestring,
                                             sizeof(datestring)/sizeof(WCHAR));
                              GetTimeFormatW(0, TIME_NOSECONDS, &st,
                                             NULL, timestring, sizeof(timestring)/sizeof(WCHAR));

                              WINE_TRACE("Date being used is: %s %s\n",
                                         wine_dbgstr_w(datestring), wine_dbgstr_w(timestring));
                          } else {
                              XCOPY_FailMessage(ERROR_INVALID_PARAMETER);
                              goto out;
                          }
                      } else {
                          flags |= OPT_DATENEWER;
                      }
                      break;

            case '-': if (toupper(word[2])=='Y')
                          flags &= ~OPT_NOPROMPT;
                      break;
            case '?': XCOPY_wprintf(XCOPY_LoadMessage(STRING_HELP));
                      rc = RC_HELP;
                      goto out;
            default:
                WINE_TRACE("Unhandled parameter '%s'\n", wine_dbgstr_w(word));
                XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARM), word);
                goto out;
            }
        }
        word = next;
    }

    /* Default the destination if not supplied */
    if (supplieddestination[0] == 0x00)
        lstrcpyW(supplieddestination, wchr_dot);

    *pflags = flags;
    rc = RC_OK;

 out:
    free(cmdline);
    return rc;
}
开发者ID:RPG-7,项目名称:reactos,代码行数:101,代码来源:xcopy.c

示例5: switch


//.........这里部分代码省略.........
                break;

            case _PIMPR_COMPANY_TELEPHONE_NUMBER:
				contact->CONTACT_PIMPR_COMPANY_TELEPHONE_NUMBER=ptrPS->val.lpwstr;
                break;

            case _PIMPR_SPOUSE:
				contact->CONTACT_PIMPR_SPOUSE=ptrPS->val.lpwstr;
                break;

            case _PIMPR_BUSINESS_ADDRESS_STREET:
				contact->CONTACT_PIMPR_BUSINESS_ADDRESS_STREET=ptrPS->val.lpwstr;
                break;

            case _PIMPR_BUSINESS_ADDRESS_CITY:
				contact->CONTACT_PIMPR_BUSINESS_ADDRESS_CITY=ptrPS->val.lpwstr;
                break;

            case _PIMPR_CHILDREN:
				contact->CONTACT_PIMPR_CHILDREN=ptrPS->val.lpwstr;
                break;

            case _PIMPR_WEB_PAGE:
				contact->CONTACT_PIMPR_WEB_PAGE=ptrPS->val.lpwstr;
                break;

            case _PIMPR_BUSINESS_ADDRESS_STATE:
				contact->CONTACT_PIMPR_BUSINESS_ADDRESS_STATE=ptrPS->val.lpwstr;
                break;

            case _PIMPR_BUSINESS_ADDRESS_POSTAL_CODE:
				contact->CONTACT_PIMPR_BUSINESS_ADDRESS_POSTAL_CODE=ptrPS->val.lpwstr;
                break;

            case _PIMPR_BUSINESS_ADDRESS_COUNTRY:
				contact->CONTACT_PIMPR_BUSINESS_ADDRESS_COUNTRY=ptrPS->val.lpwstr;
                break;

            case _PIMPR_HOME_ADDRESS_STREET:
				contact->CONTACT_PIMPR_HOME_ADDRESS_STREET=ptrPS->val.lpwstr;
                break;

            case _PIMPR_HOME_ADDRESS_CITY:
				contact->CONTACT_PIMPR_HOME_ADDRESS_CITY=ptrPS->val.lpwstr;
                break;

            case _PIMPR_HOME_ADDRESS_COUNTRY:
				contact->CONTACT_PIMPR_HOME_ADDRESS_COUNTRY=ptrPS->val.lpwstr;
                break;

            case _PIMPR_OTHER_ADDRESS_STREET:
				contact->CONTACT_PIMPR_OTHER_ADDRESS_STREET=ptrPS->val.lpwstr;
                break;

            case _PIMPR_OTHER_ADDRESS_CITY:
				contact->CONTACT_PIMPR_OTHER_ADDRESS_CITY=ptrPS->val.lpwstr;
                break;

            case _PIMPR_HOME_ADDRESS_STATE:
				contact->CONTACT_PIMPR_HOME_ADDRESS_STATE=ptrPS->val.lpwstr;
                break;

            case _PIMPR_HOME_ADDRESS_POSTAL_CODE:
				contact->CONTACT_PIMPR_HOME_ADDRESS_POSTAL_CODE=ptrPS->val.lpwstr;
                break;

            case _PIMPR_OTHER_ADDRESS_STATE:
				contact->CONTACT_PIMPR_OTHER_ADDRESS_STATE=ptrPS->val.lpwstr;
                break;

            case _PIMPR_OTHER_ADDRESS_POSTAL_CODE:
				contact->CONTACT_PIMPR_OTHER_ADDRESS_POSTAL_CODE=ptrPS->val.lpwstr;
                break;

            case _PIMPR_OTHER_ADDRESS_COUNTRY:
				contact->CONTACT_PIMPR_OTHER_ADDRESS_COUNTRY=ptrPS->val.lpwstr;
                break;

            case _PIMPR_FLOATING_BIRTHDAY:
            {
				FILETIME fileTime = {ptrPS->val.filetime.dwLowDateTime, ptrPS->val.filetime.dwHighDateTime};
                SYSTEMTIME lpUniversalTime,lpLocalTime;
                FileTimeToSystemTime(&fileTime, &lpUniversalTime);
				_SystemTimeToTzSpecificLocalTime(NULL,&lpUniversalTime ,&lpLocalTime);
				
				WCHAR msg[32];
				swprintf_s(msg, L"%02i/%02i/%04i",lpLocalTime.wDay,lpLocalTime.wMonth,lpLocalTime.wYear);
				wcscpy((wchar_t*)contact->CONTACT_PIMPR_FLOATING_BIRTHDAY,msg);
                break;
            }
            case _PIMPR_BODY_TEXT:
				contact->CONTACT_PIMPR_BODY_TEXT=ptrPS->val.lpwstr;
                break;
        }

	}
  


}
开发者ID:BwRy,项目名称:core-winphone,代码行数:101,代码来源:PoomAddressbook.cpp

示例6: TIME_CompTimeZoneID

/***********************************************************************
 *  TIME_CompTimeZoneID
 *
 *  Computes the local time bias for a given time and time zone.
 *
 *  PARAMS
 *      pTZinfo     [in] The time zone data.
 *      lpFileTime  [in] The system or local time.
 *      islocal     [in] it is local time.
 *
 *  RETURNS
 *      TIME_ZONE_ID_INVALID    An error occurred
 *      TIME_ZONE_ID_UNKNOWN    There are no transition time known
 *      TIME_ZONE_ID_STANDARD   Current time is standard time
 *      TIME_ZONE_ID_DAYLIGHT   Current time is daylight savings time
 */
static DWORD TIME_CompTimeZoneID ( const TIME_ZONE_INFORMATION *pTZinfo,
                                   FILETIME *lpFileTime, BOOL islocal )
{
    int ret, year;
    BOOL beforeStandardDate, afterDaylightDate;
    DWORD retval = TIME_ZONE_ID_INVALID;
    LONGLONG llTime = 0; /* initialized to prevent gcc complaining */
    SYSTEMTIME SysTime;
    FILETIME ftTemp;

    if (pTZinfo->DaylightDate.wMonth != 0)
    {
        /* if year is 0 then date is in day-of-week format, otherwise
         * it's absolute date.
         */
        if (pTZinfo->StandardDate.wMonth == 0 ||
                (pTZinfo->StandardDate.wYear == 0 &&
                 (pTZinfo->StandardDate.wDay<1 ||
                  pTZinfo->StandardDate.wDay>5 ||
                  pTZinfo->DaylightDate.wDay<1 ||
                  pTZinfo->DaylightDate.wDay>5)))
        {
            SetLastError(ERROR_INVALID_PARAMETER);
            return TIME_ZONE_ID_INVALID;
        }

        if (!islocal) {
            FILETIME2LL( lpFileTime, llTime );
            llTime -= pTZinfo->Bias * (LONGLONG)600000000;
            LL2FILETIME( llTime, &ftTemp)
            lpFileTime = &ftTemp;
        }

        FileTimeToSystemTime(lpFileTime, &SysTime);
        year = SysTime.wYear;

        if (!islocal) {
            llTime -= pTZinfo->DaylightBias * (LONGLONG)600000000;
            LL2FILETIME( llTime, &ftTemp)
            FileTimeToSystemTime(lpFileTime, &SysTime);
        }

        /* check for daylight savings */
        if(year == SysTime.wYear) {
            ret = TIME_DayLightCompareDate( &SysTime, &pTZinfo->StandardDate);
            if (ret == -2)
                return TIME_ZONE_ID_INVALID;

            beforeStandardDate = ret < 0;
        } else
            beforeStandardDate = SysTime.wYear < year;

        if (!islocal) {
            llTime -= ( pTZinfo->StandardBias - pTZinfo->DaylightBias )
                      * (LONGLONG)600000000;
            LL2FILETIME( llTime, &ftTemp)
            FileTimeToSystemTime(lpFileTime, &SysTime);
        }

        if(year == SysTime.wYear) {
            ret = TIME_DayLightCompareDate( &SysTime, &pTZinfo->DaylightDate);
            if (ret == -2)
                return TIME_ZONE_ID_INVALID;

            afterDaylightDate = ret >= 0;
        } else
            afterDaylightDate = SysTime.wYear > year;

        retval = TIME_ZONE_ID_STANDARD;
        if( pTZinfo->DaylightDate.wMonth <  pTZinfo->StandardDate.wMonth ) {
            /* Northern hemisphere */
            if( beforeStandardDate && afterDaylightDate )
                retval = TIME_ZONE_ID_DAYLIGHT;
        } else    /* Down south */
            if( beforeStandardDate || afterDaylightDate )
                retval = TIME_ZONE_ID_DAYLIGHT;
    } else
        /* No transition date */
        retval = TIME_ZONE_ID_UNKNOWN;

    return retval;
}
开发者ID:pombredanne,项目名称:wine,代码行数:98,代码来源:time.c

示例7: APR_DECLARE

APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
                                          apr_time_t input)
{
    SYSTEMTIME st;
    FILETIME ft, localft;

    AprTimeToFileTime(&ft, input);

#if APR_HAS_UNICODE_FS && !defined(_WIN32_WCE)
    IF_WIN_OS_IS_UNICODE
    {
        TIME_ZONE_INFORMATION *tz;
        SYSTEMTIME localst;
        apr_time_t localtime;

        get_local_timezone(&tz);

        FileTimeToSystemTime(&ft, &st);

        /* The Platform SDK documents that SYSTEMTIME/FILETIME are
         * generally UTC.  We use SystemTimeToTzSpecificLocalTime
         * because FileTimeToLocalFileFime is documented that the
         * resulting time local file time would have DST relative
         * to the *present* date, not the date converted.
         */
        SystemTimeToTzSpecificLocalTime(tz, &st, &localst);
        SystemTimeToAprExpTime(result, &localst);
        result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC);


        /* Recover the resulting time as an apr time and use the
         * delta for gmtoff in seconds (and ignore msec rounding) 
         */
        SystemTimeToFileTime(&localst, &localft);
        FileTimeToAprTime(&localtime, &localft);
        result->tm_gmtoff = (int)apr_time_sec(localtime) 
                          - (int)apr_time_sec(input);

        /* To compute the dst flag, we compare the expected 
         * local (standard) timezone bias to the delta.
         * [Note, in war time or double daylight time the
         * resulting tm_isdst is, desireably, 2 hours]
         */
        result->tm_isdst = (result->tm_gmtoff / 3600)
                         - (-(tz->Bias + tz->StandardBias) / 60);
    }
#endif
#if APR_HAS_ANSI_FS || defined(_WIN32_WCE)
    ELSE_WIN_OS_IS_ANSI
    {
        TIME_ZONE_INFORMATION tz;
	/* XXX: This code is simply *wrong*.  The time converted will always
         * map to the *now current* status of daylight savings time.
         */

        FileTimeToLocalFileTime(&ft, &localft);
        FileTimeToSystemTime(&localft, &st);
        SystemTimeToAprExpTime(result, &st);
        result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC);

        switch (GetTimeZoneInformation(&tz)) {
            case TIME_ZONE_ID_UNKNOWN:
                result->tm_isdst = 0;
                /* Bias = UTC - local time in minutes
                 * tm_gmtoff is seconds east of UTC
                 */
                result->tm_gmtoff = tz.Bias * -60;
                break;
            case TIME_ZONE_ID_STANDARD:
                result->tm_isdst = 0;
                result->tm_gmtoff = (tz.Bias + tz.StandardBias) * -60;
                break;
            case TIME_ZONE_ID_DAYLIGHT:
                result->tm_isdst = 1;
                result->tm_gmtoff = (tz.Bias + tz.DaylightBias) * -60;
                break;
            default:
                /* noop */;
        }
    }
#endif

    return APR_SUCCESS;
}
开发者ID:AAthresh,项目名称:quantlib,代码行数:84,代码来源:time.c

示例8: GetWin32

void RarTime::GetLocal(RarLocalTime *lt)
{
#ifdef _WIN_ALL
  FILETIME ft;
  GetWin32(&ft);
  FILETIME lft;

  if (WinNT() < WNT_VISTA)
  {
    // SystemTimeToTzSpecificLocalTime based code produces 1 hour error on XP.
    FileTimeToLocalFileTime(&ft,&lft);
  }
  else
  {
    // We use these functions instead of FileTimeToLocalFileTime according to
    // MSDN recommendation: "To account for daylight saving time
    // when converting a file time to a local time ..."
    SYSTEMTIME st1,st2;
    FileTimeToSystemTime(&ft,&st1);
    SystemTimeToTzSpecificLocalTime(NULL,&st1,&st2);
    SystemTimeToFileTime(&st2,&lft);

    // Correct precision loss (low 4 decimal digits) in FileTimeToSystemTime.
    FILETIME rft;
    SystemTimeToFileTime(&st1,&rft);
    int64 Corrected=INT32TO64(ft.dwHighDateTime,ft.dwLowDateTime)-
                    INT32TO64(rft.dwHighDateTime,rft.dwLowDateTime)+
                    INT32TO64(lft.dwHighDateTime,lft.dwLowDateTime);
    lft.dwLowDateTime=(DWORD)Corrected;
    lft.dwHighDateTime=(DWORD)(Corrected>>32);
  }

  SYSTEMTIME st;
  FileTimeToSystemTime(&lft,&st);
  lt->Year=st.wYear;
  lt->Month=st.wMonth;
  lt->Day=st.wDay;
  lt->Hour=st.wHour;
  lt->Minute=st.wMinute;
  lt->Second=st.wSecond;
  lt->wDay=st.wDayOfWeek;
  lt->yDay=lt->Day-1;

  static int mdays[12]={31,28,31,30,31,30,31,31,30,31,30,31};
  for (uint I=1;I<lt->Month && I<=ASIZE(mdays);I++)
    lt->yDay+=mdays[I-1];

  if (lt->Month>2 && IsLeapYear(lt->Year))
    lt->yDay++;

  st.wMilliseconds=0;
  FILETIME zft;
  SystemTimeToFileTime(&st,&zft);

  // Calculate the time reminder, which is the part of time smaller
  // than 1 second, represented in 100-nanosecond intervals.
  lt->Reminder=INT32TO64(lft.dwHighDateTime,lft.dwLowDateTime)-
               INT32TO64(zft.dwHighDateTime,zft.dwLowDateTime);
#else
  time_t ut=GetUnix();
  struct tm *t;
  t=localtime(&ut);

  lt->Year=t->tm_year+1900;
  lt->Month=t->tm_mon+1;
  lt->Day=t->tm_mday;
  lt->Hour=t->tm_hour;
  lt->Minute=t->tm_min;
  lt->Second=t->tm_sec;
  lt->Reminder=itime % 10000000;
  lt->wDay=t->tm_wday;
  lt->yDay=t->tm_yday;
#endif
}
开发者ID:Cpasjuste,项目名称:nzbm,代码行数:74,代码来源:timefn.cpp

示例9: _T

// This method compresses the files contained in the report and produces a ZIP archive.
BOOL CErrorReportExporter::CompressReportFiles(CErrorReportInfo* eri)
{ 
	BOOL bStatus = FALSE;
	strconv_t strconv;
	zipFile hZip = NULL;
	CString sMsg;
	LONG64 lTotalSize = 0;
	LONG64 lTotalCompressed = 0;
	BYTE buff[1024];
	DWORD dwBytesRead=0;
	HANDLE hFile = INVALID_HANDLE_VALUE;  
	std::map<CString, ERIFileItem>::iterator it;
	FILE* f = NULL;
	CString sMD5Hash;

	// Add a different log message depending on the current mode.
	if(m_bExport)
		m_Assync.SetProgress(_T("[exporting_report]"), 0, false);
	else
		m_Assync.SetProgress(_T("[compressing_files]"), 0, false);

	// Calculate the total size of error report files
	lTotalSize = eri->GetTotalSize();

	// Add a message to log
	sMsg.Format(_T("Total file size for compression is %I64d bytes"), lTotalSize);
	m_Assync.SetProgress(sMsg, 0, false);

	// Determine what name to use for the output ZIP archive file.
	if(m_bExport)
		m_sZipName = m_sExportFileName;  
	else
		m_sZipName = eri->GetErrorReportDirName() + _T(".zip");  

	// Update progress
	sMsg.Format(_T("Creating ZIP archive file %s"), m_sZipName);
	m_Assync.SetProgress(sMsg, 1, false);

	// Create ZIP archive
	hZip = zipOpen((const char*)m_sZipName.GetBuffer(0), APPEND_STATUS_CREATE);
	if(hZip==NULL)
	{
		m_Assync.SetProgress(_T("Failed to create ZIP file."), 100, true);
		goto cleanup;
	}

	// Enumerate files contained in the report
	int i;
	for(i=0; i<eri->GetFileItemCount(); i++)
	{ 
		ERIFileItem* pfi = eri->GetFileItemByIndex(i);

		// Check if the operation was cancelled by user
		if(m_Assync.IsCancelled())    
			goto cleanup;

		// Define destination file name in ZIP archive
		CString sDstFileName = pfi->m_sDestFile.GetBuffer(0);
		// Define source file name
		CString sFileName = pfi->m_sSrcFile.GetBuffer(0);
		// Define file description
		CString sDesc = pfi->m_sDesc;

		// Update progress
		sMsg.Format(_T("Compressing file %s"), sDstFileName);
		m_Assync.SetProgress(sMsg, 0, false);

		// Open file for reading
		hFile = CreateFile(sFileName, 
			GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); 
		if(hFile==INVALID_HANDLE_VALUE)
		{
			sMsg.Format(_T("Couldn't open file %s"), sFileName);
			m_Assync.SetProgress(sMsg, 0, false);
			continue;
		}

		// Get file information.
		BY_HANDLE_FILE_INFORMATION fi;
		GetFileInformationByHandle(hFile, &fi);

		// Convert file creation time to system file time.
		SYSTEMTIME st;
		FileTimeToSystemTime(&fi.ftLastWriteTime, &st);

		// Fill in the ZIP file info
		zip_fileinfo info;
		info.dosDate = 0;
		info.tmz_date.tm_year = st.wYear;
		info.tmz_date.tm_mon = st.wMonth-1;
		info.tmz_date.tm_mday = st.wDay;
		info.tmz_date.tm_hour = st.wHour;
		info.tmz_date.tm_min = st.wMinute;
		info.tmz_date.tm_sec = st.wSecond;
		info.external_fa = FILE_ATTRIBUTE_NORMAL;
		info.internal_fa = FILE_ATTRIBUTE_NORMAL;

		// Create new file inside of our ZIP archive
		int n = zipOpenNewFileInZip( hZip, (const char*)strconv.t2a(sDstFileName.GetBuffer(0)), &info,
//.........这里部分代码省略.........
开发者ID:geemion,项目名称:crash-exporter,代码行数:101,代码来源:ErrorReportExporter.cpp

示例10: FileTimeToStr

void FileTimeToStr (FILETIME *time, LPSTR pszDate, LPSTR pszTime, BOOL bSeconds)
{
	SYSTEMTIME s;
	FileTimeToSystemTime (time, &s);
	SystemTimeToStr (&s, pszDate, pszTime, bSeconds);
}
开发者ID:ratever930,项目名称:freedownload,代码行数:6,代码来源:misc.cpp

示例11: token


//.........这里部分代码省略.........
    // Copy the application's File Version String
    strcpyW (lpw, wszFileVer);

    // Skip to the trailing zero
    lpw += lstrlenW (lpw);
    *lpw++ = L' ';      // Blank separators
    *lpw++ = L' ';

    // Open the executable file so we get its last write time
    hFile =
      CreateFileW (wszAppDPFE,              // lpwFileName
                   GENERIC_READ,            // dwDesiredAccess
                   FILE_SHARE_READ,         // dwShareMode
                   NULL,                    // lpSecurityAttributes
                   OPEN_EXISTING,           // dwCreationDistribution
                   FILE_ATTRIBUTE_NORMAL,   // dwFlagsAndAttributes
                   NULL);                   // hTemplateFile
    if (hFile NE INVALID_HANDLE_VALUE)
    {
        FILETIME   ftLastWrite;
        SYSTEMTIME systemTime;

        // Get the file's last write time
        // Note that the file's creation time need not be the
        //   same as the file's last write time.  I think the
        //   linker might sometimes rewrite the .exe file
        //   instead of recreating it.
        GetFileTime (hFile, NULL, NULL, &ftLastWrite);

        // We no longer need this handle
        CloseHandle (hFile); hFile = NULL;

        // Convert the file's last write time to system time
        FileTimeToSystemTime (&ftLastWrite, &systemTime);

        // Format the system time as
        //    "Wed Jan 02 02:03:55 1980"
        wsprintfW (lpw,
                   L"%s %s %02u %02u:%02u:%02u %u",
                   aDaysOfWeek[systemTime.wDayOfWeek],
                   aMonths[systemTime.wMonth - 1],
                   systemTime.wDay,
                   systemTime.wHour,
                   systemTime.wMinute,
                   systemTime.wSecond,
                   systemTime.wYear);
        // Skip to the trailing zero
        lpw += lstrlenW (lpw);
        *lpw++ = L' ';    // Blank separators
        *lpw++ = L' ';
    } // End IF

#ifdef _WIN64
  #define SYSTYPE     L"Win/64" DEBUGSTR
#elif defined (_WIN32)
  #define SYSTYPE     L"Win/32" DEBUGSTR
#else
  #error Need code for this architecture.
#endif

    // Copy to the result
    CopyMemoryW (lpw, SYSTYPE, strcountof (SYSTYPE));

    // Calculate the actual NELM
    aplNELMRes = lstrlenW (lpMemData);
开发者ID:PlanetAPL,项目名称:nars2000,代码行数:66,代码来源:qf_sysver.c

示例12: DlgProcAlarm


//.........这里部分代码省略.........
							}
						}
					}
				}
			}
		}
		return TRUE;

	case WM_MOVE:
		Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "Notify");
		break;

	case WMU_ADDSNOOZER:
		{
			WindowData *wd = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
			if (wd) {
				ALARM *data = wd->alarm;

				if (data) {
					// add snooze minutes to current time
					FILETIME ft;
					GetLocalTime(&data->time);
					SystemTimeToFileTime(&data->time, &ft);
					ULARGE_INTEGER uli;
					uli.LowPart = ft.dwLowDateTime;
					uli.HighPart = ft.dwHighDateTime;

					// there are 10000000 100-nanosecond blocks in a second...
					uli.QuadPart += mult.QuadPart * (int)(wParam);

					ft.dwHighDateTime = uli.HighPart;
					ft.dwLowDateTime = uli.LowPart;

					FileTimeToSystemTime(&ft, &data->time);

					data->occurrence = OC_ONCE;
					data->snoozer = true;
					data->flags = data->flags & ~ALF_NOSTARTUP;

					data->id = next_alarm_id++;

					append_to_list(data);
				}
			}
		}
		return TRUE;

	case WM_COMMAND:
		if ( HIWORD( wParam ) == BN_CLICKED ) {
			switch( LOWORD( wParam )) {
			case IDCANCEL:  // no button - esc pressed
			case IDOK:		// space?
			case IDC_SNOOZE:
				SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)options.snooze_minutes, 0);
				//drop through
			case IDC_DISMISS:
				{
					WindowData *window_data = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
					KillTimer(hwndDlg, ID_TIMER_SOUND);
					if (window_data) {
						if (window_data->alarm) {
							free_alarm_data(window_data->alarm);
							delete window_data->alarm;
						}
						delete window_data;
					}
开发者ID:chinadayang,项目名称:miranda-ng,代码行数:67,代码来源:alarm_win.cpp

示例13: hb_fsFindNextLow


//.........这里部分代码省略.........
         }

         /* Fill Harbour found file info */

         if( bFound )
         {
            HB_OSSTRDUP2( info->pFindFileData.cFileName, ffind->szName, sizeof( ffind->szName ) - 1 );

            if( info->pFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
               ffind->size = 0;
            else
            {
#if defined( __XCC__ ) || ( defined( __POCC__ ) && __POCC__ >= 500 )
               /* NOTE: PellesC 5.00.1 will go into an infinite loop if we don't
                        split this into two operations. [vszakats] */
               ffind->size  = ( HB_FOFFSET ) info->pFindFileData.nFileSizeLow;
               ffind->size += ( HB_FOFFSET ) info->pFindFileData.nFileSizeHigh << 32;
#else
               ffind->size = ( HB_FOFFSET ) info->pFindFileData.nFileSizeLow +
                           ( ( HB_FOFFSET ) info->pFindFileData.nFileSizeHigh << 32 );
#endif
            }

            raw_attr = ( HB_FATTR ) info->pFindFileData.dwFileAttributes;

            /* NOTE: One of these may fail when searching on an UNC path, I
                     don't know yet what's the reason. [vszakats] */

            {
               FILETIME ft;
               SYSTEMTIME time;

               if( FileTimeToLocalFileTime( &info->pFindFileData.ftLastWriteTime, &ft ) &&
                   FileTimeToSystemTime( &ft, &time ) )
               {
                  iYear  = time.wYear;
                  iMonth = time.wMonth;
                  iDay   = time.wDay;
                  iHour  = time.wHour;
                  iMin   = time.wMinute;
                  iSec   = time.wSecond;
                  iMSec  = time.wMilliseconds;
               }
            }
         }
      }
      hb_fsSetIOError( bFound, 0 );
   }

#elif defined( HB_OS_UNIX )

   {
      PHB_FFIND_INFO info = ( PHB_FFIND_INFO ) ffind->info;

      char dirname[ HB_PATH_MAX ];

      bFound = HB_FALSE;

      /* TODO: HB_FA_LABEL handling */

      if( ffind->bFirst )
      {
         char * pos;

         ffind->bFirst = HB_FALSE;
开发者ID:jiangxilong,项目名称:core,代码行数:66,代码来源:hbffind.c

示例14: CreateFile

// This method compresses the files contained in the report and produces ZIP archive.
BOOL CErrorReportSender::CompressReportFiles()
{ 
  BOOL bStatus = FALSE;
  strconv_t strconv;
  zipFile hZip = NULL;
  CString sMsg;
  LONG64 lTotalSize = 0;
  LONG64 lTotalCompressed = 0;
  BYTE buff[1024];
  DWORD dwBytesRead=0;
  HANDLE hFile = INVALID_HANDLE_VALUE;
  std::map<CString, FileItem>::iterator it;
  LARGE_INTEGER lFileSize;
  BOOL bGetSize = FALSE;
    
  if(m_bExport)
    m_Assync.SetProgress(_T("[exporting_report]"), 0, false);
  else
    m_Assync.SetProgress(_T("[compressing_files]"), 0, false);

  m_Assync.SetProgress(_T("Calculating total size of files to compress..."), 0, false);
  
  for(it=g_CrashInfo.m_FileItems.begin(); it!=g_CrashInfo.m_FileItems.end(); it++)
  {    
    if(m_Assync.IsCancelled())    
      goto cleanup;

    CString sFileName = it->second.m_sSrcFile.GetBuffer(0);
    hFile = CreateFile(sFileName, 
      GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); 
    if(hFile==INVALID_HANDLE_VALUE)
    {
      sMsg.Format(_T("Couldn't open file %s"), sFileName);
      m_Assync.SetProgress(sMsg, 0, false);
      continue;
    }
    
    bGetSize = GetFileSizeEx(hFile, &lFileSize);
    if(!bGetSize)
    {
      sMsg.Format(_T("Couldn't get file size of %s"), sFileName);
      m_Assync.SetProgress(sMsg, 0, false);
      CloseHandle(hFile);
      continue;
    }

    lTotalSize += lFileSize.QuadPart;
    CloseHandle(hFile);
    hFile = INVALID_HANDLE_VALUE;
  }

  sMsg.Format(_T("Total file size for compression is %I64d"), lTotalSize);
  m_Assync.SetProgress(sMsg, 0, false);

  if(m_bExport)
    m_sZipName = m_sExportFileName;  
  else
    m_sZipName = g_CrashInfo.m_sErrorReportDirName + _T(".zip");  
    
  sMsg.Format(_T("Creating ZIP archive file %s"), m_sZipName);
  m_Assync.SetProgress(sMsg, 1, false);

  hZip = zipOpen(strconv.t2a(m_sZipName.GetBuffer(0)), APPEND_STATUS_CREATE);
  if(hZip==NULL)
  {
    m_Assync.SetProgress(_T("Failed to create ZIP file."), 100, true);
    goto cleanup;
  }

  for(it=g_CrashInfo.m_FileItems.begin(); it!=g_CrashInfo.m_FileItems.end(); it++)
  { 
    if(m_Assync.IsCancelled())    
      goto cleanup;
    
    CString sDstFileName = it->second.m_sDestFile.GetBuffer(0);
    CString sFileName = it->second.m_sSrcFile.GetBuffer(0);
    CString sDesc = it->second.m_sDesc;

    sMsg.Format(_T("Compressing %s"), sDstFileName);
    m_Assync.SetProgress(sMsg, 0, false);
        
    HANDLE hFile = CreateFile(sFileName, 
      GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); 
    if(hFile==INVALID_HANDLE_VALUE)
    {
      sMsg.Format(_T("Couldn't open file %s"), sFileName);
      m_Assync.SetProgress(sMsg, 0, false);
      continue;
    }

    BY_HANDLE_FILE_INFORMATION fi;
    GetFileInformationByHandle(hFile, &fi);

    SYSTEMTIME st;
    FileTimeToSystemTime(&fi.ftCreationTime, &st);

    zip_fileinfo info;
    info.dosDate = 0;
    info.tmz_date.tm_year = st.wYear;
//.........这里部分代码省略.........
开发者ID:doo,项目名称:CrashRpt,代码行数:101,代码来源:ErrorReportSender.cpp

示例15: PropProc


//.........这里部分代码省略.........
			/*
			 *	Setup the up/down range
			 *	and the tab stop.
			 */
			SendDlgItemMessage( hDlg, IDC_PROP_TABSPIN, UDM_SETRANGE, 0, MAKELPARAM( 24,2 ));

			/*
			 *	Setup file modes.
			 */
			for ( i = FMODE_MSDOS; i <= FMODE_MACINTOSH; i++ )
				SendDlgItemMessage( hDlg, IDC_PROP_TYPE, CB_ADDSTRING, 0, ( LPARAM )lpszFileModes[ i ] );

			/*
			 *	Setup the file size and the
			 *	tab size controls.
			 */
			SetSizeControls( hDlg );

			/*
			 *	Valid file date?
			 */
			if ( lpcd->ftFileTime.dwHighDateTime == 0 && lpcd->ftFileTime.dwLowDateTime == 0 )
				SetDlgItemText( hDlg, IDC_PROP_DATE, GetString( IDS_NOT_SAVED ));
			else
			{
				FILETIME	ft;
				SYSTEMTIME	st;

				/*
				 *	Convert file time to
				 *	system time.
				 */
				FileTimeToLocalFileTime( &lpcd->ftFileTime, &ft );
				FileTimeToSystemTime( &ft, &st );

				/*
				 *	Format time.
				 */
				GetTimeFormat( LOCALE_USER_DEFAULT,
					       0, //LOCALE_NOUSEROVERRIDE,
					       &st,
					       NULL,
					       szBuffer,
					       256 );

				/*
				 *	Add space.
				 */
				_tcscat_s( szBuffer, MAX_PATH, _T(" "));

				/*
				 *	Format date.
				 */
				GetDateFormat( LOCALE_USER_DEFAULT,
					       0, //LOCALE_NOUSEROVERRIDE,
					       &st,
					       NULL,
					       &szBuffer[ _tcslen( szBuffer ) ],
					       256 - _tcslen( szBuffer ));

				/*
				 *	Output result.
				 */
				SetDlgItemText( hDlg, IDC_PROP_DATE, szBuffer );
			}
开发者ID:jcbaar,项目名称:Brainchild,代码行数:66,代码来源:prop.c


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