我在API中,想调用VC本身的类,比如CTime,及这个类的成员函数,但是在API中,总显示报错是这个类和这些成员函数没被声明,我如何在api中引用呢,现在我都是自己创建的窗体和编辑框,就是想在创建的编辑框中显示当前时间

解决方案 »

  1.   

    你建的是win32工程吗#include <afx.h>
      

  2.   

    GetSystemTime(建议使用GetLocalTime)
    或者直接用标准C中的tm结构及其相关函数。Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
    Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server.
    Header: Declared in Winbase.h; include Windows.h.
    Library: Use Kernel32.lib.
      

  3.   

    去掉windows.h,然后在所有的.h文件前加入#include "stdafx.h"菜单Project Setting->C/C++
    选择Code Generation ,在Use Run-Time Library 下拉框中选择Debug Multithread菜单Project->Setting->General中
    选择Using MFC in a Shared DLL或Using MFC in a static Library
      

  4.   

    我添加了AFX.H,说这个错误c:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
      

  5.   

    试试小三的方法 
    你建的是WIN 32的工程吗?
      

  6.   

    UP
    -----------------------------打造国内最大免费编程资源站招聘C/C++版主 硬件嵌入式开发版主。有兴趣的来瞧瞧,网址:www.dvpx.com
      

  7.   

    我用了小三的方法,但是我开始写的API函数,调用的DLL,全都报错了,都说没被声明,怎么办