UNICODE_STRING
GetCurrentTimeString()
{
 static CHAR  szTime[128];
 LARGE_INTEGER SystemTime;
 LARGE_INTEGER LocalTime;
 TIME_FIELDS  timeFiled;
UNICODE_STRING jieguo;
ANSI_STRING tmptime; KeQuerySystemTime(&SystemTime);
 ExSystemTimeToLocalTime(&SystemTime, &LocalTime);
 RtlTimeToTimeFields(&LocalTime, &timeFiled);
 sprintf(szTime, "%d-%02d-%02d %02d:%02d:%02d"
  , timeFiled.Year
  , timeFiled.Month
  , timeFiled.Day
  , timeFiled.Hour
  , timeFiled.Minute
  , timeFiled.Second
  );
RtlInitAnsiString(&tmptime,szTime);
RtlAnsiStringToUnicodeString(&jieguo,&tmptime,TRUE);
return jieguo;
}如何不使用sprintf但仍能使这个函数返回正确的结果呢
用哪个函数能代替sprintf呢?
望大侠们像教白痴那样的教我,我一用C就怕得要尿裤子附上这个结构
typedef struct TIME_FIELDS 

CSHORT Year; 
CSHORT Month; 
CSHORT Day; 
CSHORT Hour; 
CSHORT Minute; 
CSHORT Second; 
CSHORT Milliseconds; 
CSHORT Weekday; 
} TIME_FIELDS; 

解决方案 »

  1.   

    C++一般都就是用 sprintf,还可以用snprintf,snprintf_s
      

  2.   

    我不想显示  只要把timeFiled中各个字段放到szTime中就行了
      

  3.   

    wsprintf 吧, ms 提供的函数
      

  4.   

    这段函数是驱动中的 如果编译时Free Build的话 sprintf之类的东西可能就被去掉了
    所以我想转换  不用sprintf
      

  5.   

    用wsprintf吧,是API,而sprintf是CRT
      

  6.   

    天哪  就这么一个简单的问题
    把CSHORT转换成char  这个总有办法吧CSHORT是什么型的东东啊 看模样是整型的  怎么把它换成char的呢
      

  7.   

    驱动程序也可以使用sprintf,包含stdio.h。