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


C++ GetSystemTimeAsFileTime函数代码示例

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


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

示例1: GetCurrentUTCTimeInUI64

inline uint64_t GetCurrentUTCTimeInUI64()
{
	FILETIME Timestamp;
	GetSystemTimeAsFileTime(&Timestamp); // in UTC
	return FileTimeToUI64(Timestamp);
}
开发者ID:Firebie,项目名称:FarManager,代码行数:6,代码来源:datetime.hpp

示例2: NaClGetTimeOfDayIntern

int NaClGetTimeOfDayIntern(struct nacl_abi_timeval *tv,
                           struct NaClTimeState    *ntsp) {
  FILETIME  ft_now;
  DWORD     ms_counter_now;
  uint64_t  t_ms;
  DWORD     ms_counter_at_ft_now;
  uint32_t  ms_counter_diff;
  uint64_t  unix_time_ms;

  GetSystemTimeAsFileTime(&ft_now);
  ms_counter_now = timeGetTime();
  t_ms = NaClFileTimeToMs(&ft_now);

  NaClMutexLock(&ntsp->mu);

  NaClLog(5, "ms_counter_now       %"NACL_PRIu32"\n",
          (uint32_t) ms_counter_now);
  NaClLog(5, "t_ms                 %"NACL_PRId64"\n", t_ms);
  NaClLog(5, "system_time_start_ms %"NACL_PRIu64"\n",
          ntsp->system_time_start_ms);

  ms_counter_at_ft_now = (DWORD)
      (ntsp->ms_counter_start +
       (uint32_t) (t_ms - ntsp->system_time_start_ms));

  NaClLog(5, "ms_counter_at_ft_now %"NACL_PRIu32"\n",
          (uint32_t) ms_counter_at_ft_now);

  ms_counter_diff = ms_counter_now - (uint32_t) ms_counter_at_ft_now;

  NaClLog(5, "ms_counter_diff      %"NACL_PRIu32"\n", ms_counter_diff);

  if (ms_counter_diff <= kMaxMillsecondDriftBeforeRecalibration) {
    t_ms = t_ms + ms_counter_diff;
  } else {
    NaClCalibrateWindowsClockMu(ntsp);
    t_ms = ntsp->system_time_start_ms;
  }

  NaClLog(5, "adjusted t_ms =      %"NACL_PRIu64"\n", t_ms);

  unix_time_ms = t_ms - ntsp->epoch_start_ms;

  /*
   * Time is monotonically non-decreasing.
   */
  if (unix_time_ms < ntsp->last_reported_time_ms) {
    unix_time_ms = ntsp->last_reported_time_ms;
  } else {
    ntsp->last_reported_time_ms = unix_time_ms;
  }

  NaClMutexUnlock(&ntsp->mu);

  NaClLog(5, "unix_time_ms  =      %"NACL_PRId64"\n", unix_time_ms);
  /*
   * Unix time is measured relative to a different epoch, Jan 1, 1970.
   * See the module initialization for epoch_start_ms.
   */

  tv->nacl_abi_tv_sec = (nacl_abi_time_t) (unix_time_ms / 1000);
  tv->nacl_abi_tv_usec = (nacl_abi_suseconds_t) ((unix_time_ms % 1000) * 1000);

  NaClLog(5, "nacl_avi_tv_sec =    %"NACL_PRIdNACL_TIME"\n",
          tv->nacl_abi_tv_sec);
  NaClLog(5, "nacl_avi_tv_usec =   %"NACL_PRId32"\n", tv->nacl_abi_tv_usec);

  return 0;
}
开发者ID:eseidel,项目名称:native_client_patches,代码行数:69,代码来源:nacl_time.c

示例3: dmnsn_get_times

void
dmnsn_get_times(dmnsn_timer *timer)
{
#if DMNSN_GETRUSAGE
  struct timeval real;
  gettimeofday(&real, NULL);

  struct rusage usage;
  if (getrusage(RUSAGE_SELF, &usage) == 0) {
    timer->real   = dmnsn_timeval2double(real);
    timer->user   = dmnsn_timeval2double(usage.ru_utime);
    timer->system = dmnsn_timeval2double(usage.ru_stime);
  } else {
    dmnsn_warning("getrusage() failed.");
    timer->real = timer->user = timer->system = 0.0;
  }
#elif DMNSN_TIMES
  static long clk_tck = 0;

  // Figure out the clock ticks per second
  if (!clk_tck) {
    clk_tck = sysconf(_SC_CLK_TCK);
    if (clk_tck == -1) {
      dmnsn_warning("sysconf(_SC_CLK_TCK) failed.");
      clk_tck = 1000000L;
    }
  }

  struct tms buf;
  clock_t real = times(&buf);
  if (real == (clock_t)-1) {
    dmnsn_warning("times() failed.");
    timer->real = timer->user = timer->system = 0.0;
  } else {
    timer->real   = (double)real/clk_tck;
    timer->user   = (double)buf.tms_utime/clk_tck;
    timer->system = (double)buf.tms_stime/clk_tck;
  }
#elif defined(_WIN32)
  FILETIME real;
  GetSystemTimeAsFileTime(&real);

  FILETIME user, system, creation, exit;
  HANDLE current_process = GetCurrentProcess();
  if (GetProcessTimes(current_process,
                      &creation, &exit, &system, &user) != 0)
  {
    timer->real
      = (((uint64_t)real.dwHighDateTime << 32) + real.dwLowDateTime)/1.0e7;
    timer->user
      = (((uint64_t)user.dwHighDateTime << 32) + user.dwLowDateTime)/1.0e7;
    timer->system
      = (((uint64_t)system.dwHighDateTime << 32) + system.dwLowDateTime)/1.0e7;
  } else {
    dmnsn_warning("GetProcessTimes() failed.");
    timer->real = timer->user = timer->system = 0.0;
  }
#else
  timer->real = timer->user = timer->system = 0.0;
#endif
}
开发者ID:tavianator,项目名称:dimension,代码行数:61,代码来源:platform.c

示例4: ReadWakaTimeConfigFile

#include "CommonUtility.h"
#include "INIReader.h"
#include <Knownfolders.h>
#include <Shlobj.h>
#include <Pathcch.h>
#include <sstream>

// Mandatory initialization of static class variable outside the header file.
static FILETIME local;
FILETIME EditRecordTimer::lastUpdatedTimeStamp = (GetSystemTimeAsFileTime(&local), local);
ManageWakaTimeConfigFile gConfigFileManager;
static const std::wstring pythoncmd = L"python.exe";
static const std::wstring WAKATIME_CONFIG_NAME(L".wakatime.cfg");

#include <Shlwapi.h>
bool ManageWakaTimeConfigFile::ReadWakaTimeConfigFile()
{
	// Read the wakatime.cfg file under users home directory if it exists.
	WCHAR* path;
	bool status = false;
	if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Profile, SHGFP_TYPE_CURRENT, 0, &path)))
	{
		WCHAR fullPath[MAX_PATH];
#pragma  warning(disable : 4995)
		if (SUCCEEDED(PathCombine(fullPath, path, WAKATIME_CONFIG_NAME.c_str())))
		{
			m_FileName = fullPath;
			status = true;
		}

		CoTaskMemFree(path);
开发者ID:pritianka,项目名称:photoshopwindows,代码行数:31,代码来源:CommonUtility.cpp

示例5: CertTrustFinalPolicy

/***********************************************************************
 *		CertTrustFinalPolicy ([email protected])
 */
HRESULT WINAPI CertTrustFinalPolicy(CRYPT_PROVIDER_DATA *data)
{
    BOOL ret;
    DWORD err = S_OK;
    CERT_VERIFY_CERTIFICATE_TRUST *pCert = CRYPTDLG_GetVerifyData(data);

    TRACE("(%p)\n", data);

    if (data->pWintrustData->dwUIChoice != WTD_UI_NONE)
        FIXME("unimplemented for UI choice %d\n",
         data->pWintrustData->dwUIChoice);
    if (pCert)
    {
        DWORD flags = 0;
        CERT_CHAIN_PARA chainPara;
        HCERTCHAINENGINE engine;

        memset(&chainPara, 0, sizeof(chainPara));
        chainPara.cbSize = sizeof(chainPara);
        if (CRYPTDLG_CheckOnlineCRL())
            flags |= CERT_CHAIN_REVOCATION_CHECK_END_CERT;
        engine = CRYPTDLG_MakeEngine(pCert);
        GetSystemTimeAsFileTime(&data->sftSystemTime);
        ret = CRYPTDLG_IsCertAllowed(pCert->pccert);
        if (ret)
        {
            PCCERT_CHAIN_CONTEXT chain;

            ret = CertGetCertificateChain(engine, pCert->pccert,
             &data->sftSystemTime, NULL, &chainPara, flags, NULL, &chain);
            if (ret)
            {
                if (chain->cChain != 1)
                {
                    FIXME("unimplemented for more than 1 simple chain\n");
                    err = TRUST_E_SUBJECT_FORM_UNKNOWN;
                    ret = FALSE;
                }
                else if ((ret = CRYPTDLG_CopyChain(data, chain)))
                {
                    if (CertVerifyTimeValidity(&data->sftSystemTime,
                     pCert->pccert->pCertInfo))
                    {
                        ret = FALSE;
                        err = CERT_E_EXPIRED;
                    }
                }
                else
                    err = TRUST_E_SYSTEM_ERROR;
                CertFreeCertificateChain(chain);
            }
            else
                err = TRUST_E_SUBJECT_NOT_TRUSTED;
        }
        CertFreeCertificateChainEngine(engine);
    }
    else
    {
        ret = FALSE;
        err = TRUST_E_NOSIGNATURE;
    }
    /* Oddly, native doesn't set the error in the trust step error location,
     * probably because this action is more advisory than anything else.
     * Instead it stores it as the final error, but the function "succeeds" in
     * any case.
     */
    if (!ret)
        data->dwFinalError = err;
    TRACE("returning %d (%08x)\n", S_OK, data->dwFinalError);
    return S_OK;
}
开发者ID:devyn,项目名称:wine,代码行数:74,代码来源:main.c

示例6: LoadFile

BOOL

LoadFile(
    int doc
    )
{
    LPDOCREC d =&Docs[doc];
    char line[MAX_USER_LINE + 1];
    int offset; //Current offset of storage in block
    int lineLen;
    BYTE prevLength; //Previous line size
    HCURSOR hSaveCursor;
    WORD res;
    WORD nbLines = 0;

    //
    // Documents are now always read only. Because WinDbg is no longer and IDE, it
    // is strictly a debugger now.
    //

    hFileDoc = CreateFile(d->szFileName, GENERIC_READ, FILE_SHARE_READ, 
        NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

    if (INVALID_HANDLE_VALUE == hFileDoc) {
        ErrorBox( ERR_File_Open, (LPSTR)d->szFileName );
        return FALSE;
    }

    d->readOnly = TRUE;

    //Store file date

    if (!GetFileTimeByName( d->szFileName, NULL, NULL, &d->time ) ) {
        GetSystemTimeAsFileTime(&d->time);
    }

    if ((pszBufferDoc = DocAlloc(DISK_BLOCK_SIZE)) == NULL) {
        ErrorBox(SYS_Allocate_Memory);
        goto error1;
    }

    //Alloc first block

    if (!AllocateBlock(NULL, NULL, &d->FirstBlock)) {
        return FALSE;
    }

    //If we are in reload mode, and a message box shows up, a repaint
    //of the document being loaded is done, so force number of lines
    //to a value != 0

    d->NbLines = MAX_LINE_NUMBER;

    d->LastBlock = d->FirstBlock;
    dwBytesReadDoc = DISK_BLOCK_SIZE;
    dwOffsetDoc = DISK_BLOCK_SIZE;
    offset = 0;
    prevLength = 0;

    //Set the Hour glass cursor

    hSaveCursor = SetCursor (LoadCursor(NULL, IDC_WAIT));

    //Read file line after line

    res = LoadLine(line, &lineLen, nbLines);
    while (res == END_OF_LINE) {

        //Truncate a file too large

        if (nbLines >= MAX_LINE_NUMBER - 1) {
            ErrorBox(ERR_Truncate_Doc);
            res = END_OF_FILE;
            break;
        }

        if (!StoreLine(line, lineLen, &offset, &prevLength, &d->LastBlock)) {
            res = END_ABORT;
            break;
        }

        res = LoadLine(line, &lineLen, ++nbLines);
    }

    //Take decisions

    switch (res) {

      case END_OF_FILE:

        //Store last line

        if (StoreLine(line, lineLen, &offset, &prevLength, &d->LastBlock)) {

            nbLines++;

            //Free memory

            if (!DocFree(pszBufferDoc))
                  InternalErrorBox(SYS_Free_Memory);
//.........这里部分代码省略.........
开发者ID:maerson,项目名称:windbg,代码行数:101,代码来源:docfile.cpp

示例7: Cookie_Parse

    static void Cookie_Parse(HTTP_SESSION_HANDLE *lpSession,WCHAR *lpCookieDomain,WCHAR *lpCookiePath,WCHAR *lpCookieName,WCHAR *lpData)
    {
        WCHAR *lpPtr=lpData,
              *lpPorts=NULL;

        DWORD dwCookieFlags=0,
              dwFlags=0,
              dwPortsCount=0;

        FILETIME ftExpiry={0};
        while (true)
        {
            if (!(lpPtr=StrChrW(lpPtr,L';')))
                break;

            *lpPtr++=0;

            while ((*lpPtr) && (*lpPtr == L' '))
                lpPtr++;

            if (IsKnownParam(dcrW_c7ed8bb1("domain"),6))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                lpCookieDomain=lpPtr;
            }
            else if (IsKnownParam(dcrW_1ab74e01("path"),4))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                lpCookiePath=lpPtr;
            }
            else if (IsKnownParam(dcrW_a3df71ef("expires"),7))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                if ((!(dwCookieFlags & COOKIE_FLAG_EXPIRES_SET)) && (!(dwFlags & COOKIE_HANDLER_MAXAGE_SET)))
                {
                    SYSTEMTIME st;
                    if (InternetTimeToSystemTimeW(lpPtr,&st,0))
                    {
                        dwCookieFlags|=COOKIE_FLAG_EXPIRES_SET;
                        SystemTimeToFileTime(&st,&ftExpiry);
                        FILETIME tm;
                        GetSystemTimeAsFileTime(&tm);

                        if (CompareFileTime(&tm,&ftExpiry) > 0)
                            dwFlags|=COOKIE_HANDLER_EXPIRED;
                    }
                }
            }
            else if (IsKnownParam(dcrW_77b02e79("secure"),6))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                dwCookieFlags|=COOKIE_FLAG_SECURE;
            }
            else if (IsKnownParam(dcrW_60249e06("discard"),7))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                dwCookieFlags|=COOKIE_FLAG_DISCARD;
            }
            else if (IsKnownParam(dcrW_53e691c9("max-age"),7))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                GetSystemTimeAsFileTime(&ftExpiry);

                /**
                    MSDN:
                    It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times.
                    Instead, you should copy the low- and high-order parts of the file time to a LARGE_INTEGER structure, perform
                    64-bit arithmetic on the QuadPart member, and copy the LowPart and HighPart members into the FILETIME structure.

                    Do not cast a pointer to a FILETIME structure to either a LARGE_INTEGER* or __int64* value because it can cause
                    alignment faults on 64-bit Windows.
                **/

                LARGE_INTEGER liTime={ftExpiry.dwLowDateTime,ftExpiry.dwHighDateTime};
                liTime.QuadPart+=StrToIntW(lpPtr)*_100NS_IN_SEC;
                ftExpiry.dwLowDateTime=liTime.LowPart;
                ftExpiry.dwHighDateTime=liTime.HighPart;

                dwFlags|=COOKIE_HANDLER_MAXAGE_SET;
                dwCookieFlags|=COOKIE_FLAG_EXPIRES_SET;
            }
            else if (IsKnownParam(dcrW_f98fd7e9("port"),4))
            {
                lpPtr=GetCookieParamValuePtr(lpPtr);
                do
                {
                    if (dwCookieFlags & COOKIE_FLAG_PORT_SET)
                        break;

                    if (*lpPtr != L'"')
                        break;

                    WCHAR *lpPortsStart=lpPtr+1,
                          *lpPortsEnd=StrChrW(lpPortsStart,L'"');

                    if (!lpPortsEnd)
                        break;

                    dwPortsCount=1;
                    WCHAR *lpCurPort=lpPortsStart;
//.........这里部分代码省略.........
开发者ID:seledka,项目名称:syslib,代码行数:101,代码来源:cookie.cpp

示例8: KeyStoreAdd

//
//	Adds a new pressed key information into the key store.
//
WINERROR KeyStoreAdd(
	PKEY_INFO	pKeyInfo
	)
{
	WINERROR		Status = ERROR_NOT_ENOUGH_MEMORY;
	ULONG			KeyHandle;
	PKEY_CONTEXT	Ctx;
	BOOL            bDeref = FALSE;

	KeyHandle = Crc32((PCHAR)&pKeyInfo->Client, sizeof(CLIENT_INFO));
	
	if (Ctx = GetContext(KeyHandle))
	{
		bDeref = Ctx->bDirty;		
		if (Ctx->bDirty == FALSE) // just created
		{
			// Context has just been created, initializing
			HANDLE	hProcess;

			// Resolving process path
			if (hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pKeyInfo->Client.ProcessId))
			{
				GetModuleFileNameExW(hProcess, NULL, (LPWSTR)&Ctx->ProcessPath, MAX_PATH);
				CloseHandle(hProcess);
			}

			Ctx->bActive = TRUE;

			// Saving current date and time
			GetSystemTimeAsFileTime(&Ctx->Time);
			
			// Resolving parent window text
			GetWindowTextW(pKeyInfo->Client.ParentWindow, (LPWSTR)&Ctx->WindowText, MAX_WINDOW_TEXT);
		}	// if (Ctx->bDirty == FALSE) // just created

		Ctx->bDirty = TRUE;

		if (Ctx->bActive)
		{
			if (pKeyInfo->wChar && Ctx->Count < MAX_KEY_BUFFER_SIZE)
			{
				if (pKeyInfo->wChar == VK_BACK)
				{
					if (Ctx->Count)
						Ctx->Count -= 1;
				}
				else
				{
					Ctx->KeyBuffer[Ctx->Count] = pKeyInfo->wChar;
					Ctx->Count += 1;
					DbgPrint("KEYLOG: Adding key to a buffer: 0x%x, %C\n", pKeyInfo->wChar, pKeyInfo->wChar);
				}
				Status = NO_ERROR;
			}	// if (Ctx->Count < MAX_KEY_BUFFER_SIZE)
			else
				Status = ERROR_BUFFER_OVERFLOW;

			if ( pKeyInfo->clipboard )
			{
				PCLIPBOARD_ENTRY Entry = (PCLIPBOARD_ENTRY)AppAlloc( sizeof(CLIPBOARD_ENTRY) );
				if ( Entry )
				{
					// Saving current date and time
					GetSystemTimeAsFileTime(&Entry->Time);
					Entry->Buffer = pKeyInfo->clipboard;
					pKeyInfo->clipboard = NULL; // we'll free it later
					InsertTailList(&Ctx->ClipboardChain,&Entry->qLink);
				}
			}	// if ( pKeyInfo->clipboard )
		}	// if (Ctx->bActive)

		if ( bDeref )
			// Context has been reused, dereferencing it
			ReleaseContext(Ctx);
	}	// if (Ctx = GetContext(KeyHandle))

	return(Status);
}
开发者ID:0x00dec0de,项目名称:GMbot,代码行数:81,代码来源:keystore.c

示例9: PRMJ_Now

JSInt64
PRMJ_Now(void)
{
#ifdef XP_OS2
    JSInt64 s, us, ms2us, s2us;
    struct timeb b;
#endif
#ifdef XP_WIN
    JSInt64 s, us,
    win2un = JSLL_INIT(0x19DB1DE, 0xD53E8000),
    ten = JSLL_INIT(0, 10);
    FILETIME time, midnight;
#endif
#if defined(XP_UNIX) || defined(XP_BEOS)
    struct timeval tv;
    JSInt64 s, us, s2us;
#endif /* XP_UNIX */

#ifdef XP_OS2
    ftime(&b);
    JSLL_UI2L(ms2us, PRMJ_USEC_PER_MSEC);
    JSLL_UI2L(s2us, PRMJ_USEC_PER_SEC);
    JSLL_UI2L(s, b.time);
    JSLL_UI2L(us, b.millitm);
    JSLL_MUL(us, us, ms2us);
    JSLL_MUL(s, s, s2us);
    JSLL_ADD(s, s, us);
    return s;
#endif
#ifdef XP_WIN
    /* The windows epoch is around 1600. The unix epoch is around 1970.
       win2un is the difference (in windows time units which are 10 times
       more precise than the JS time unit) */
    GetSystemTimeAsFileTime(&time);
    /* Win9x gets confused at midnight
       http://support.microsoft.com/default.aspx?scid=KB;en-us;q224423
       So if the low part (precision <8mins) is 0 then we get the time
       again. */
    if (!time.dwLowDateTime) {
        GetSystemTimeAsFileTime(&midnight);
        time.dwHighDateTime = midnight.dwHighDateTime;
    }
    JSLL_UI2L(s, time.dwHighDateTime);
    JSLL_UI2L(us, time.dwLowDateTime);
    JSLL_SHL(s, s, 32);
    JSLL_ADD(s, s, us);
    JSLL_SUB(s, s, win2un);
    JSLL_DIV(s, s, ten);
    return s;
#endif

#if defined(XP_UNIX) || defined(XP_BEOS)
#ifdef _SVID_GETTOD   /* Defined only on Solaris, see Solaris <sys/types.h> */
    gettimeofday(&tv);
#else
    gettimeofday(&tv, 0);
#endif /* _SVID_GETTOD */
    JSLL_UI2L(s2us, PRMJ_USEC_PER_SEC);
    JSLL_UI2L(s, tv.tv_sec);
    JSLL_UI2L(us, tv.tv_usec);
    JSLL_MUL(s, s, s2us);
    JSLL_ADD(s, s, us);
    return s;
#endif /* XP_UNIX */
}
开发者ID:84danielwhite,项目名称:smartos-live,代码行数:65,代码来源:prmjtime.c

示例10: store

/* init_global_prog_store()
Initialize the global program store by storing command line arguments, OS version, etc.

This function must only be called from the main thread.
For now there is only one program store implemented and it's a global store (G->prog).
*/
void init_global_prog_store( 
	int argc,   // in
	char **argv   // in deref
)
{
	unsigned offsetof_cHandleEntries = 0;
	
	FAIL_IF( !G );   // The global store must exist.
	
	FAIL_IF( G->prog->init_time );   // Fail if this store has already been initialized.
	
	
	/* get_SharedInfo() or die.
	This function loads user32.dll and must be called before any other pointer to GUI related info 
	is initialized.
	*/
	G->prog->pSharedInfo = get_SharedInfo();
	
	
	G->prog->argc = argc;
	G->prog->argv = argv;
	
	/* point pszBasename to this program's basename */
	if( argc && argv[ 0 ][ 0 ] )
	{
		char *clip = NULL;
		
		clip = strrchr( argv[ 0 ], '\\' );
		if( clip )
			++clip;
		
		G->prog->pszBasename = ( clip && *clip ) ? clip : argv[ 0 ];
	}
	else
		G->prog->pszBasename = "<unknown>";
	
	
	/* main thread id */
	G->prog->dwMainThreadId = GetCurrentThreadId();
	
	/* operating system version and platform */
	G->prog->dwOSVersion = GetVersion();
	G->prog->dwOSMajorVersion = (BYTE)G->prog->dwOSVersion;
	G->prog->dwOSMinorVersion = (BYTE)( G->prog->dwOSVersion >> 8 );
	G->prog->dwOSBuild = 
		( G->prog->dwOSVersion < 0x80000000 ) ? ( G->prog->dwOSVersion >> 16 ) : 0;
	
	/* the name of this program's window station */
	if( !get_user_obj_name( &G->prog->pwszWinstaName, GetProcessWindowStation() ) )
	{
		MSG_FATAL_GLE( "get_user_obj_name() failed." );
		printf( "Failed to get this program's window station name.\n" );
		printf( "If you can reproduce this error contact [email protected]\n" );
		exit( 1 );
	}
	
	
	/* Determine the offset of cHandleEntries in SERVERINFO.
	In NT4 the offset is 4 but this program isn't for NT4 so ignore.
	In Win2k and XP the offset is 8.
	In Vista and Win7 the offset is 4.
	*/
	offsetof_cHandleEntries = ( G->prog->dwOSMajorVersion >= 6 ) ? 4 : 8;
	
	offsetof_cHandleEntries = 8;

	/* The first member of SHAREDINFO is pointer to SERVERINFO.
	Add offsetof_cHandleEntries to the SERVERINFO pointer to get the address of cHandleEntries.
	*/
	G->prog->pcHandleEntries = 
		(volatile DWORD *)( (char *)G->prog->pSharedInfo->psi + offsetof_cHandleEntries );
	
	
	/* G->prog has been initialized */
	GetSystemTimeAsFileTime( (FILETIME *)&G->prog->init_time );
	return;
}
开发者ID:tigros,项目名称:HookTools,代码行数:83,代码来源:prog.c

示例11: anAutoLock

bool StPlayList::walkToNext(const bool theToForce) {
    StMutexAuto anAutoLock(myMutex);
    if(myCurrent == NULL
    || (myToLoopSingle && !theToForce)) {
        return false;
    } else if(myIsShuffle && myItemsCount >= 3) {
        StPlayItem* aPrev = myCurrent;
        if(!myStackNext.empty()) {
            myCurrent = myStackNext.front();
            myStackNext.pop_front();
        } else {
            if((myPlayedCount >= (myItemsCount - 1)) || (myPlayedCount == 0)) {
                // reset the playback counter
            #ifdef _WIN32
                FILETIME aTime;
                GetSystemTimeAsFileTime(&aTime);
                myRandGen.setSeed(aTime.dwLowDateTime);
            #else
                timeval aTime;
                gettimeofday(&aTime, NULL);
                myRandGen.setSeed(aTime.tv_usec);
            #endif
                myPlayedCount = 0;
                myCurrent->setPlayedFlag(!myCurrent->getPlayedFlag());
                ST_DEBUG_LOG("Restart the shuffle");
            }

            // determine next random position
            const size_t aCurrPos  = myCurrent->getPosition();
            bool         aCurrFlag = myCurrent->getPlayedFlag();
            StPlayItem*  aNextItem = myCurrent;
            const size_t aNextPos  = stMin(size_t(myRandGen.next() * myItemsCount), myItemsCount - 1);
            if(aNextPos > aCurrPos) {
                // forward direction
                for(size_t aNextDiff = aNextPos - aCurrPos; aNextItem != NULL && aNextDiff != 0; --aNextDiff) {
                    aNextItem = aNextItem->getNext();
                }
            } else {
                // backward direction
                for(size_t aNextDiff = aCurrPos - aNextPos; aNextItem != NULL && aNextDiff != 0; --aNextDiff) {
                    aNextItem = aNextItem->getPrev();
                }
            }
            if(aCurrFlag == aNextItem->getPlayedFlag()) {
                // find nearest position not yet played - prefer item farther from current one
                StPlayItem* aNextItem1 = aNextPos > aCurrPos ? aNextItem->getNext() : aNextItem->getPrev();
                StPlayItem* aNextItem2 = aNextPos > aCurrPos ? aNextItem->getPrev() : aNextItem->getNext();
                for(; aNextItem1 != NULL || aNextItem2 != NULL;) {
                    if(aNextItem1 != NULL) {
                        if(aCurrFlag != aNextItem1->getPlayedFlag()) {
                            aNextItem = aNextItem1;
                            break;
                        }
                        aNextItem1 = aNextPos > aCurrPos ? aNextItem1->getNext() : aNextItem1->getPrev();
                    }
                    if(aNextItem2 != NULL) {
                        if(aCurrFlag != aNextItem2->getPlayedFlag()) {
                            aNextItem = aNextItem2;
                            break;
                        }
                        aNextItem2 = aNextPos > aCurrPos ? aNextItem2->getPrev() : aNextItem2->getNext();
                    }
                }
                if(aCurrFlag == aNextItem->getPlayedFlag()) {
                    // something wrong!
                    ST_DEBUG_LOG("Disaster - next shuffle position not found!");
                    aCurrFlag     = !aCurrFlag;
                    myPlayedCount = 0;
                }
            }

            ST_DEBUG_LOG(aCurrPos + " -> " + aNextItem->getPosition());
            ++myPlayedCount;

            aNextItem->setPlayedFlag(aCurrFlag);
            myCurrent = aNextItem;
        }

        if(aPrev != myCurrent
        && aPrev != NULL) {
            myStackPrev.push_back(aPrev);
            if(myStackPrev.size() > THE_UNDO_LIMIT) {
                myStackPrev.pop_front();
            }
        }

        const size_t anItemId = myCurrent->getPosition();
        anAutoLock.unlock();
        signals.onPositionChange(anItemId);
        return true;
    } else if(myCurrent != myLast) {
        myCurrent = myCurrent->getNext();
        const size_t anItemId = myCurrent->getPosition();
        anAutoLock.unlock();
        signals.onPositionChange(anItemId);
        return true;
    } else if(myIsLoopFlag) {
        return walkToFirst();
    }
    return false;
//.........这里部分代码省略.........
开发者ID:KindDragon,项目名称:sview,代码行数:101,代码来源:StPlayList.cpp

示例12: SKSE64_Initialize

void SKSE64_Initialize(void)
{
	if(isInit) return;
	isInit = true;

	gLog.OpenRelative(CSIDL_MYDOCUMENTS, "\\My Games\\Skyrim Special Edition\\SKSE\\skse64.log");

#ifndef _DEBUG
	__try {
#endif

		FILETIME	now;
		GetSystemTimeAsFileTime(&now);

		_MESSAGE("SKSE64 runtime: initialize (version = %d.%d.%d %08X %08X%08X, os = %s)",
			SKSE_VERSION_INTEGER, SKSE_VERSION_INTEGER_MINOR, SKSE_VERSION_INTEGER_BETA, RUNTIME_VERSION,
			now.dwHighDateTime, now.dwLowDateTime, GetOSInfoStr().c_str());

		_MESSAGE("imagebase = %016I64X", GetModuleHandle(NULL));
		_MESSAGE("reloc mgr imagebase = %016I64X", RelocationManager::s_baseAddr);

#ifdef _DEBUG
		SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);

		WaitForDebugger();
#endif

		if(!g_branchTrampoline.Create(1024 * 64))
		{
			_ERROR("couldn't create branch trampoline. this is fatal. skipping remainder of init process.");
			return;
		}

		if(!g_localTrampoline.Create(1024 * 64, g_moduleHandle))
		{
			_ERROR("couldn't create codegen buffer. this is fatal. skipping remainder of init process.");
			return;
		}

		// Add Hooks_XXX_Init calls here
		Hooks_Debug_Init();
		Hooks_ObScript_Init();
		Hooks_Papyrus_Init();
		Hooks_NetImmerse_Init();
		Hooks_Threads_Init();
		Hooks_Handlers_Init();

		g_pluginManager.Init();

		// Add Hooks_XXX_Commit calls here in the same order
		Hooks_Debug_Commit();
		Hooks_ObScript_Commit();
		Hooks_Papyrus_Commit();
		Hooks_UI_Commit();
		Hooks_Camera_Commit();
		Hooks_NetImmerse_Commit();
		Hooks_Threads_Commit();
		Hooks_Handlers_Commit();
		Hooks_Scaleform_Commit();
		Hooks_Gameplay_Commit();
		Hooks_Event_Commit();
		Hooks_SaveLoad_Commit();
		Hooks_Data_Commit();
		Init_CoreSerialization_Callbacks();
		Hooks_DirectInput_Commit();
		
		FlushInstructionCache(GetCurrentProcess(), NULL, 0);

#ifndef _DEBUG
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		_ERROR("exception thrown during startup");
	}
#endif

	_MESSAGE("init complete");
}
开发者ID:kassent,项目名称:SkyrimSouls-SE,代码行数:78,代码来源:skse64.cpp

示例13: TabCtrlProc

BOOL CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct TabCtrlData *dat;
	dat = (struct TabCtrlData *) GetWindowLong(hwnd, GWL_USERDATA);
    switch(msg) {
        case WM_MBUTTONDOWN:
		{
			TCITEM tci;
			int tabId;
			struct MessageWindowData *mwd;
			TCHITTESTINFO thinfo;
			thinfo.pt.x = (lParam<<16)>>16;
			thinfo.pt.y = lParam>>16;
			tabId = TabCtrl_HitTest(hwnd, &thinfo);
			if (tabId >= 0) {
				tci.mask = TCIF_PARAM;
				TabCtrl_GetItem(hwnd, tabId, &tci);
				mwd = (struct MessageWindowData *) tci.lParam;
				if (mwd != NULL) {
					SendMessage(mwd->hwnd, WM_CLOSE, 0, 0);
    			}
			}
	        return TRUE;
        }
		case WM_LBUTTONDBLCLK:
		{
			TCHITTESTINFO thinfo;
			int tabId;
			thinfo.pt.x = (lParam<<16)>>16;
			thinfo.pt.y = lParam>>16;
			tabId = TabCtrl_HitTest(hwnd, &thinfo);
			if (tabId >=0 ) {
				void * clickChild = GetChildFromTab(hwnd, tabId)->hwnd;
				if (clickChild == dat->lastClickChild) {
					SendMessage(clickChild, WM_CLOSE, 0, 0);
				}
			}
			dat->lastClickChild = NULL;
		}
		break;
		case WM_LBUTTONDOWN:
		{
			if (!dat->bDragging) {
				FILETIME ft;
				TCHITTESTINFO thinfo;
				GetSystemTimeAsFileTime(&ft);
				thinfo.pt.x = (lParam<<16)>>16;
				thinfo.pt.y = lParam>>16;
				dat->srcTab = dat->destTab = TabCtrl_HitTest(hwnd, &thinfo);
				if (dat->srcTab >=0 ) {
					dat->lastClickChild = GetChildFromTab(hwnd, dat->srcTab)->hwnd;
				} else {
					dat->lastClickChild = NULL;
				}
				dat->bDragging = TRUE;
				dat->bDragged = FALSE;
				dat->clickLParam = lParam;
				dat->clickWParam = wParam;
				dat->lastClickTime = ft.dwLowDateTime;
				dat->mouseLBDownPos.x = thinfo.pt.x;
				dat->mouseLBDownPos.y = thinfo.pt.y;
				SetCapture(hwnd);
				return 0;
			}
		}
		break;
		case WM_CAPTURECHANGED:
		case WM_LBUTTONUP:
			if (dat->bDragging) {
				TCHITTESTINFO thinfo;
				thinfo.pt.x = (lParam<<16)>>16;
				thinfo.pt.y = lParam>>16;
				if (dat->bDragged) {
					ImageList_DragLeave(GetDesktopWindow());
					ImageList_EndDrag();
					ImageList_Destroy(dat->hDragImageList);
					SetCursor(LoadCursor(NULL, IDC_ARROW));
					dat->destTab = TabCtrl_HitTest(hwnd, &thinfo);
					if (thinfo.flags != TCHT_NOWHERE && dat->destTab != dat->srcTab)  {
						NMHDR nmh;
						TCHAR  sBuffer[501];
						TCITEM item;
						int curSel;
						curSel = TabCtrl_GetCurSel(hwnd);
						item.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT;
						item.pszText = sBuffer;
						item.cchTextMax = sizeof(sBuffer)/sizeof(TCHAR);
						TabCtrl_GetItem(hwnd, dat->srcTab, &item);
						sBuffer[sizeof(sBuffer)/sizeof(TCHAR)-1] = '\0';
						if (curSel == dat->srcTab) {
							curSel = dat->destTab;
						} else {
							if (curSel > dat->srcTab && curSel <= dat->destTab) {
								curSel--;
							} else if (curSel < dat->srcTab && curSel >= dat->destTab) {
								curSel++;
							}
						}
						TabCtrl_DeleteItem(hwnd, dat->srcTab);
						TabCtrl_InsertItem(hwnd, dat->destTab, &item );
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:mgoodies-svn,代码行数:101,代码来源:msgwindow.c

示例14: xOpen

int xOpen(sqlite3_vfs*, const char *zName, sqlite3_file* p_file,int flags, int *pOutFlags)
{
	sqlite3_file_fb2k * p_fb2kfile = static_cast<sqlite3_file_fb2k*>(p_file);
	p_fb2kfile->pMethods = &xIoMethod;
	p_fb2kfile->m_file = NULL;
	filesystem::t_open_mode fb2kMode = filesystem::open_mode_read;
	pfc::string8 temp;
	if (!zName)
	{
		uGetTempPath(temp);
		temp;// << "\\";
		FILETIME ft;
		GetSystemTimeAsFileTime(&ft);
		srand(ft.dwLowDateTime);
		temp << (unsigned) ft.dwHighDateTime << (unsigned) ft.dwLowDateTime << rand() << ".dop.temp";
		zName = temp.get_ptr();
	}
	if (flags & SQLITE_OPEN_READONLY)
	{
		fb2kMode = filesystem::open_mode_read;
		if (pOutFlags)
			*pOutFlags = SQLITE_OPEN_READONLY;
	}
	else if (flags & SQLITE_OPEN_READWRITE)
	{
		fb2kMode = filesystem::open_mode_write_existing;
		if (pOutFlags)
			*pOutFlags = SQLITE_OPEN_READWRITE;
	}
	else if ( (flags & (SQLITE_OPEN_CREATE|SQLITE_OPEN_EXCLUSIVE)) == (SQLITE_OPEN_CREATE|SQLITE_OPEN_EXCLUSIVE) )
	{
		fb2kMode = filesystem::open_mode_write_new;
		*pOutFlags = SQLITE_OPEN_CREATE|SQLITE_OPEN_EXCLUSIVE;
	}
	else if (flags & (SQLITE_OPEN_CREATE))
	{
		fb2kMode = filesystem::open_mode_write_existing;
		*pOutFlags = SQLITE_OPEN_CREATE;
	}
	else return SQLITE_NOLFS;

	try
	{
		file::ptr ptr;
		try {
		filesystem::g_open(ptr, zName, fb2kMode, abort_callback_dummy());
		}
		catch (exception_io_not_found const &)
		{
			if (flags & (SQLITE_OPEN_CREATE))
			{
				filesystem::g_open_write_new(ptr, zName, abort_callback_dummy());
				if (pOutFlags)
					*pOutFlags |= SQLITE_OPEN_CREATE;
			}
			else throw;			
		}

		p_fb2kfile->m_file = new file::ptr(ptr.get_ptr());
	}
	catch (const exception_io & ex) 
	{
		console::formatter() << "iPod manager: xOpen error: " << ex.what();
		return SQLITE_IOERR;
	}

	return SQLITE_OK;
}
开发者ID:reupen,项目名称:ipod_manager,代码行数:68,代码来源:sqlite.cpp

示例15: GetCurrentProcess

/*
	The following block is copied from the Java source code. It documents the counters array.

	 * @param counters the results are returned in this array.
	 * <ol>
	 * <li>working set in bytes for this process
	 * <li>peak working set in bytes for this process
	 * <li>elapsed time in milliseconds
	 * <li>user time in milliseconds
	 * <li>kernel time in milliseconds
	 * <li>page faults for the process
	 * <li>commit charge total in bytes (working set for the entire machine). On some 
	 * machines we have problems getting this value so we return -1 in that case.
	 * <li>number of GDI objects in the process
	 * <li>number of USER objects in the process
	 * <li>number of open handles in the process. returns -1 if this information is not available
	 * <li>Number of read operations
	 * <li>Number of write operations
	 * <li>Number of bytes read
	 * <li>Number of bytes written
	 * </ol>

*/
JNIEXPORT jboolean JNICALL Java_org_eclipse_perfmsr_core_PerformanceMonitor_nativeGetPerformanceCounters
  (JNIEnv * jniEnv, jclass jniClass, jlongArray counters)
{
	FILETIME creationTime, exitTime, kernelTime, userTime, systemTime;
	ULARGE_INTEGER uliCreation, uliSystem, uliKernel, uliUser;
	ULONGLONG diff;
	IO_COUNTERS ioCounters;

	jboolean result = TRUE;
	jsize len = (*jniEnv)->GetArrayLength(jniEnv, counters);
	jlong *body = (*jniEnv)->GetLongArrayElements(jniEnv, counters, 0);
	HANDLE me = GetCurrentProcess();
	PROCESS_MEMORY_COUNTERS memCounters;
	DWORD cb = sizeof(PROCESS_MEMORY_COUNTERS);
	BOOL rc = GetProcessMemoryInfo(me, &memCounters, cb);
	if (rc != 0)
	{
		body[0] = memCounters.WorkingSetSize;
		body[1] = memCounters.PeakWorkingSetSize;
		body[5] = memCounters.PageFaultCount;
	}
	else
	{
		handleSystemError(jniEnv);
		return FALSE;
	}

	if (!GetProcessTimes(me, &creationTime, &exitTime, &kernelTime, &userTime))
	{
		handleSystemError(jniEnv);
		return FALSE;
	}
	GetSystemTimeAsFileTime(&systemTime);

	memcpy(&uliCreation, &creationTime, sizeof(uliCreation));  
	memcpy(&uliSystem, &systemTime, sizeof(uliSystem));
	memcpy(&uliKernel, &kernelTime, sizeof(uliSystem));
	memcpy(&uliUser, &userTime, sizeof(ULARGE_INTEGER));
	diff = uliSystem.QuadPart - uliCreation.QuadPart;
	body[2] = diff / 10000;
	body[3] = uliUser.QuadPart / 10000;
	body[4] = uliKernel.QuadPart / 10000;
	body[6] = getTotalCommitted(jniEnv);

	body[7] = GetGuiResources(me, GR_GDIOBJECTS);
	body[8] = GetGuiResources(me, GR_USEROBJECTS);
	body[9] = getHandleCount(jniEnv, me);

	if (!GetProcessIoCounters(me, &ioCounters))
	{
		handleSystemError(jniEnv);
		return FALSE;
	}
	body[10] = ioCounters.ReadOperationCount;
	body[11] = ioCounters.WriteOperationCount;
	body[12] = ioCounters.ReadTransferCount;
	body[13] = ioCounters.WriteTransferCount;

	(*jniEnv)->ReleaseLongArrayElements(jniEnv, counters, body, 0);

	return result;
}
开发者ID:Overruler,项目名称:eclipse.platform.releng,代码行数:85,代码来源:ivjperf.c


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