我在SDK中使用GETSYSTEMTIME或GETLOCALTIME怎么都不行?
总是产生异常,我的系统是XP+VC6!
总是产生异常,我的系统是XP+VC6!
解决方案 »
- CEdit SetSel问题
- 我想要建立个c++兴趣小组,希望愿意加入的顶下(散分)
- 关于asn1开发的问题
- 【求救!】mfc消息映射
- 请问我设定了CStatic的区域(SetWindowRgn),然后在CStatic的OnEraseBkgnd里面画背景,为什么背景会画到CStatic外面
- Help me!!! MFC框架程序窗口如何永远不被激活? 超烦!!!
- 这个地方时应该返回一个引用还是返回一个实际的对象?
- 如何在引用全局对象的类成员时有提示?见内
- 急得要上吊!
- 我学vc已经半年了,怎么编东东时还是力不从心,我还要多久才能改变这种局面呢。
- 怎样通过String Table修改menu的caption
- 帮我看看,急
GetLocalTime(&sysTime);
用TRY……CATCH看看能不能接到错误。
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <sys\timeb.h>
#include <windows.h>
#include <process.h>
#include <errno.h>
#include <process.h>
#define BIAS1 ( *((DWORD*)0x7FFe0020) )
#define BIAS2 ( *((DWORD*)0x7FFe0024) )CHAR buf[200]; // message bufferVOID FormatSt( SYSTEMTIME st, CHAR* buf)
{
sprintf(buf,"%02d/%02d/%02d %02d:%02d:%02d",
st.wYear, st.wMonth, st.wDay,
st.wHour, st.wMinute, st.wSecond );
}VOID PrintTZInfo()
{
TIME_ZONE_INFORMATION tzi;
DWORD dwSta; dwSta= GetTimeZoneInformation( &tzi );
printf("GetTimeZoneInformation: \n ");
switch( dwSta )
{
case TIME_ZONE_ID_UNKNOWN:
printf("returned TIME_ZONE_ID_UNKNOWN\n");
break; case TIME_ZONE_ID_STANDARD:
FormatSt( tzi.StandardDate, buf );
printf("Bias %d Name: %S SysDate: %s Bias: %d\n",
tzi.Bias, tzi.StandardName, buf, tzi.StandardBias );
break; case TIME_ZONE_ID_DAYLIGHT:
FormatSt( tzi.DaylightDate, buf );
printf("Bias %d Name: %S SysDate: %s Bias: %d\n",
tzi.Bias, tzi.DaylightName, buf, tzi.DaylightBias );
break; default:
printf("returned undoced status: %d",dwSta);
break;
}
printf(" User_Shared_Data bias: %08x %08x\n\n",BIAS2, BIAS1 );
}VOID TstSetTime( int year, int mon, int day, int hour, int minute, int sec)
{
SYSTEMTIME st,tst;
BOOL bSta; st.wYear= year;
st.wMonth= mon;
st.wDay= day;
st.wHour= hour;
st.wMinute= minute;
st.wSecond= sec; st.wDayOfWeek= 0;
st.wMilliseconds= 0; bSta= SetLocalTime( &st ); if( bSta == FALSE )
{
FormatSt( st, buf);
printf("Failed to set date/time: %s\n",buf);
}
else
{
FormatSt( st, buf);
printf("SetLocalTime: %s\n",buf); GetLocalTime( &tst );
FormatSt( tst, buf);
printf("GetLocalTime: %s\n", buf); GetSystemTime( &tst );
FormatSt( tst, buf );
printf("GetSystemTime: %s\n", buf);
}
printf("\n");}VOID PrintTime( CHAR* msg )
{
SYSTEMTIME st; GetLocalTime( &st ); FormatSt( st, (CHAR*) buf ); printf("%s %s\n", msg, buf);}int _cdecl main(int argc, char** argv)
{ // pick date in savings time TstSetTime( 1998, 8, 30, 22, 59, 0 );
PrintTZInfo(); // pick date outside of savings time printf("\n");
TstSetTime( 1998, 12, 29, 22, 59, 0 );
PrintTZInfo(); return(0);
}