硬汉嵌入式论坛

 找回密码
 立即注册
查看: 2329|回复: 3
收起左侧

emwin仿真时如何获取windows系统时间

[复制链接]

4

主题

9

回帖

21

积分

新手上路

积分
21
发表于 2019-7-18 08:30:16 | 显示全部楼层 |阅读模式
我在做RTC时钟部分,emwin仿真时如何获取windows系统时间,比如现在是2019年7月18号8:28
回复

使用道具 举报

5

主题

85

回帖

100

积分

初级会员

积分
100
发表于 2019-7-18 09:36:49 | 显示全部楼层
本帖最后由 huohua1991 于 2019-7-18 09:39 编辑

如果你的emwin仿真是在visual studio上做,只需用以下代码就行了:
  1. #include <windows.h>
  2. SYSTEMTIME xSysTime;
  3. GetLocalTime(&xSysTime);
复制代码

如果你的emwin仿真是在开发板运行,想获取Windows系统的系统时间是不可能的。
回复

使用道具 举报

23

主题

1444

回帖

1513

积分

至尊会员

积分
1513
发表于 2019-7-18 12:12:32 | 显示全部楼层
__DATE__
__TIME__
代码不规范,亲人两行泪!
回复

使用道具 举报

1

主题

14

回帖

17

积分

新手上路

积分
17
发表于 2019-8-7 13:24:57 | 显示全部楼层
  1. #include "time.h"

  2. {
  3.         char buff[8];
  4. #ifdef WIN32
  5.         time_t t;
  6.         struct tm *lt;
  7.         time(&t);
  8.         lt=localtime(&t);
  9.         sprintf(buff, "%02d:%02d", lt->tm_hour, lt->tm_min);
  10. #else
  11.         sprintf(buff, "%02d:%02d", calendar.hour, calendar.min);
  12. #endif
  13.         TEXT_SetText(hWin_TextTime, buff);
  14. }
复制代码


我仿真的时候我是这样处理的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-8-12 13:21 , Processed in 0.037428 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表