Sugerir tradução
 
Outras sugestões:

progress indicator
Sem sugestões.
Clique para classificar e enviar comentários
MSDN
Biblioteca MSDN
Core OS Services
Core OS Reference
Time Reference
Time Functions
 GetTickCount
Recolher Tudo/Expandir Tudo Recolher Tudo
Exibir Conteúdo: Lado a LadoExibir Conteúdo: Lado a Lado
Este conteúdo foi traduzido automaticamente e pode ser editado pelos membros da comunidade. Para melhorar a qualidade da tradução, clique no link Editar associado à frase que deseja modificar.
GetTickCount
Windows Mobile SupportedWindows Embedded CE Supported
8/29/2008

For Release configurations, this function returns the number of milliseconds since the device booted, excluding any time that the system was suspended. GetTickCount starts at zero on boot and then counts up from there.

For debug configurations, 180 seconds is subtracted from the the number of milliseconds since the device booted. This enables code that uses GetTickCount to be easily tested for correct overflow handling.

DWORD GetTickCount(void);

None

The number of milliseconds indicates success.

The resolution of the system timer is based on the OEM's setting. Check with the OEM for details.

The elapsed time is stored as a DWORD value. Therefore, the time will rollover to zero if the system is run continuously for 49.7 days. For Debug configurations, 180 seconds is subtracted to check for overflow conditions in code that relies on GetTickCount. If this code started within 3 minutes of the device booting, it will experience an overflow condition if it runs for a certain amount of time.

Note:
You should not use GetTickCount for drift sensitive applications.

When using GetTickCount, subtraction is safe, even if the rollover occurred, and subtraction always yields the correct difference and the number of clock ticks passed between two tick values. Comparing tick values directly does not always yield the correct results; only compare the differences. Be sure that your code can service the difference before the second rollover, that is, before another 49.7 days pass. Comparisons such as the following are not safe.

#define DELTA_TICKS sample_tick_value

// initialized somewhere in the code
DWORD dwStartTick = GetTickCount();
DWORD dwEndTick =   GetTickCount() + DELTA_TICKS;

// The following function fails on a rollover.
BOOL    no_compare_tick_difference()
{
  if ( GetTickCount() > dwEndTick )
    return ( TRUE);
  return (FALSE);
}

The following code shows how to properly use GetTickCount by comparing tick differences. This code handles the rollover situation.

BOOL compare_tick_difference()
{
  if ( (GetTickCount() – dwStartTick) > DELTA_TICKS)
    return ( TRUE);
  return (FALSE);
}

You can use the GetTickCount function to time the duration of an activity as shown in the example below.

dwOldTime = GetTickCount();
DoSomething();
dwTimeElapsed = GetTickCount() – dwOldTime;

On the STMicro platform, the time returned by GetTickCount includes a ~0.014% time drift, which is by design. This translates to a time lag of approximately 1 second every 2 hours.

Headerwinbase.h
Librarycoredll.lib
Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later
GetTickCount
Windows Mobile SupportedWindows Embedded CE Supported
9/8/2008

Para as configurações de versão, essa função retorna o número de milissegundos desde que o dispositivo inicializado, excluindo qualquer tempo que o sistema foi suspenso. ObterContagemMarcaEscala começa em zero em inicializar e, em seguida, contagens Backup a partir daí.

Para configurações depuração, 180 segundos é subtraída do o número de milissegundos desde que o dispositivo inicializado. Isso permite codificar que usa ObterContagemMarcaEscala a ser facilmente testado para manipulação estouro correto.

DWORD GetTickCount(void);

Nenhum

O número de milissegundos indica sucesso.

A resolução de timer de sistema baseia-se na configuração a OEM. Verifique com o OEM para obter detalhes.

O tempo decorrido é armazenada como um DWORD valor. Portanto, o tempo será sobreposição para zero se o sistema é executar continuamente para 49.7 Days. Para as configurações de depuração, 180 segundos é subtraída para verificar para condições estouro em codificar que depende ObterContagemMarcaEscala. Se este codificar iniciado em 3 minutos do dispositivo de inicialização, ele terão uma condição estouro se ela for executada para uma determinada quantidade de tempo.

Note:
Você não deve usar ObterContagemMarcaEscala Para confidencial dos aplicativos.

Ao utilizar a ObterContagemMarcaEscala, subtração é segura, mesmo se ocorreu a sobreposição e subtração sempre produz a diferença correta e o número de tiques relógio passados entre dois valores marcação. Comparar valores marcação diretamente não nem sempre lucro o correto resultados; Somente compare as diferenças. Certifique-se de que seu codificar pode serviço a diferença antes a segunda sobreposição, ou seja, antes outro transmitir 49.7 Days. Comparações, como o seguinte não é seguros.

#define DELTA_TICKS sample_tick_value

// initialized somewhere in the code
DWORD dwStartTick = GetTickCount();
DWORD dwEndTick =   GetTickCount() + DELTA_TICKS;

// The following function fails on a rollover.
BOOL    no_compare_tick_difference()
{
  if ( GetTickCount() > dwEndTick )
    return ( TRUE);
  return (FALSE);
}

O seguinte mostra codificar como corretamente usar ObterContagemMarcaEscala Comparando as diferenças marcação. Este codificar manipula a situação de sobreposição.

BOOL compare_tick_difference()
{
  if ( (GetTickCount() – dwStartTick) > DELTA_TICKS)
    return ( TRUE);
  return (FALSE);
}

Você pode usar o ObterContagemMarcaEscala função para tempo de duração de uma atividade como mostra o exemplo abaixo.

dwOldTime = GetTickCount();
DoSomething();
dwTimeElapsed = GetTickCount() – dwOldTime;

Sobre a plataforma STMicro, o tempo retornado por ObterContagemMarcaEscala Inclui uma flutuação tempo ~0.014%, que é por design. Isso converte para um retardo tempo de aproximadamente 1 segundo cada 2 horas.

Headerwinbase.h
Librarycoredll.lib
Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later
Conteúdo da Comunidade   O que é Conteúdo da Comunidade?
Adicionar novo conteúdo RSS  Anotações
Processing
© 2009 Microsoft Corporation. Todos os direitos reservados. Termos de Uso | Marcas Comerciais | Política de Privacidade
Page view tracker