CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C/C++ >  C语言

为什么getdate()函数无法用?请大家帮忙

楼主luckystarfrx(星星雨)2005-07-04 18:09:06 在 C/C++ / C语言 提问

刚刚开始用c来编程,现在想取系统日期:  
   
  #include   <dos.h>    
  #include   <stdio.h>    
   
  int   main(void)    
  {    
        struct   date   d;    
   
        getdate(&d);    
        printf("The   current   year   is:   %d\n",d.da_year);    
        printf("The   current   day   is:   %d\n",d.da_day);    
        printf("The   current   month   is:   %d\n",d.da_mon);    
        return   0;    
  }  
   
  用Microsoft   Visual   C++   6.0进行开发。为什么此段程序编译不通过,报  
  error   C2079:   'd'   uses   undefined   struct   'date'  
  warning   C4013:   'getdate'   undefined;   assuming   extern   returning   int  
  error   C2224:   left   of   '.da_year'   must   have   struct/union   type  
  error   C2224:   left   of   '.da_day'   must   have   struct/union   type  
  error   C2224:   left   of   '.da_mon'   must   have   struct/union   type  
   
  难道getdate不在<dos.h>中的吗?  
   
  请大家帮忙。谢谢! 问题点数:20、回复次数:1Top

1 楼xbsmail(夏阳)回复于 2005-07-04 18:17:02 得分 20

用VC应该用GetDateTime  
       
    Platform   SDK:   Windows   Management   Instrumentation    
  CInstance::GetDateTime  
  The   GetDateTime   method   returns   a   datetime   property.  
   
  bool   GetDateTime(  
      LPCWSTR   name,  
      WBEMTime&   wbemtime  
  );  
   
  Parameters  
  name    
  Name   of   the   datetime   property   retrieved.    
  wbemtime    
  Buffer   to   receive   the   datetime   property.    
  Return   Values  
  Returns   TRUE   if   the   operation   was   successful   and   FALSE   if   an   attempt   was   made   to   retrieve   a   property   that   is   not   a   datetime   value   or   a   property   that   does   not   exist.   More   information   is   available   in   the   log   file,   Framework.log.  
   
  Requirements  
  Client:   Included   in   Windows   XP,   Windows   2000   Professional,   Windows   NT   Workstation   4.0   SP4   and   later,   Windows   Me,   Windows   98,   and   Windows   95.  
  Server:   Included   in   Windows   Server   2003,   Windows   2000   Server,   and   Windows   NT   Server   4.0   SP4   and   later.  
  Header:   Declared   in   Instance.h;   include   FwCommon.h.  
  Library:   Use   Framedyn.lib.  
   
   
  Platform   SDK   Release:   February   2003     What   did   you   think   of   this   topic?  
      Order   a   Platform   SDK   CD    
  Top

相关问题

  • CreateTimerQueueTimer函数为什么无法编译?
  • SQLSERVER的用户定义函数里为什么不能用GETDATE函数???
  • 为什么我在自定义函数里使用GETDATE()函数会提示‘在函数里不正确的使用了 'getdate'’的错误?
  • 为什么DLL里的API函数无法调用
  • 为什么我这里无法调用inet_addr等函数
  • 100分!ATL开发activex为什么无法用fopen等函数
  • 新手请教:为什么socket函数无法使用?
  • 为什么我的TC无法运行图形库函数?
  • 我明明定义了窗口的回调函数,为什么说无法转换成(DLGPROC)?难道回调函数不能是成员函数吗?
  • 编写一个winsock函数编译后,无法运行为什么

关键词

  • server
  • wbemtime
  • getdate
  • getdatetime
  • da
  • datetime
  • union
  • struct
  • year
  • current

得分解答快速导航

  • 帖主:luckystarfrx
  • xbsmail

相关链接

  • C/C++ Blog
  • C/C++类图书
  • C/C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo