Skip to content

Commit 203368e

Browse files
committed
Add Windows Demo
1 parent d2adb48 commit 203368e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+11041
-0
lines changed

Windows/Config.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#include "Config.h"
2+
#include "json.h"
3+
4+
#include <stdio.h>
5+
6+
Config::Config()
7+
: m_sdkAppId(0)
8+
, m_userInfos()
9+
{
10+
11+
}
12+
13+
Config::~Config()
14+
{
15+
16+
}
17+
18+
Config& Config::instance()
19+
{
20+
static Config uniqueInstance;
21+
return uniqueInstance;
22+
}
23+
24+
bool Config::load()
25+
{
26+
FILE* file = NULL;
27+
fopen_s(&file, "Config.json", "rb");
28+
if (!file)
29+
{
30+
return false;
31+
}
32+
33+
std::string data;
34+
while (true)
35+
{
36+
char buffer[512] = { 0 };
37+
size_t count = ::fread(buffer, 1, 512, file);
38+
if (count == 0)
39+
{
40+
break;
41+
}
42+
43+
data.append(buffer, count);
44+
}
45+
46+
Json::Reader reader;
47+
Json::Value root;
48+
if (!reader.parse(data, root))
49+
{
50+
return false;
51+
}
52+
53+
if (!root.isMember("sdkappid") || !root.isMember("users"))
54+
{
55+
return false;
56+
}
57+
58+
m_sdkAppId = root["sdkappid"].asUInt();
59+
60+
Json::Value users = root["users"];
61+
for (size_t i = 0; i < users.size(); ++i)
62+
{
63+
Json::Value item = users[i];
64+
if (!item.isMember("userId") || !item.isMember("userToken"))
65+
{
66+
return false;
67+
}
68+
69+
UserInfo info;
70+
info.userId = item["userId"].asString();
71+
info.userSig = item["userToken"].asString();
72+
73+
m_userInfos.push_back(info);
74+
}
75+
76+
return true;
77+
}
78+
79+
uint32_t Config::getSdkAppId() const
80+
{
81+
return m_sdkAppId;
82+
}
83+
84+
std::vector<UserInfo> Config::getUserInfos() const
85+
{
86+
return m_userInfos;
87+
}

Windows/Config.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <vector>
5+
#include <stdint.h>
6+
7+
struct UserInfo
8+
{
9+
std::string userId;
10+
std::string userSig;
11+
};
12+
13+
class Config
14+
{
15+
protected:
16+
Config();
17+
Config(const Config&);
18+
Config operator =(const Config&);
19+
public:
20+
~Config();
21+
22+
static Config& instance();
23+
24+
bool load();
25+
26+
uint32_t getSdkAppId() const;
27+
std::vector<UserInfo> getUserInfos() const;
28+
private:
29+
uint32_t m_sdkAppId;
30+
std::vector<UserInfo> m_userInfos;
31+
};

Windows/ReadMe.txt

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
================================================================================
2+
MICROSOFT 基础类库 : TRTCDemo 项目概述
3+
===============================================================================
4+
5+
应用程序向导已为您创建了此 TRTCDemo 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。
6+
7+
本文件概要介绍组成 TRTCDemo 应用程序的每个文件的内容。
8+
9+
TRTCDemo.vcxproj
10+
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
11+
12+
TRTCDemo.vcxproj.filters
13+
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
14+
15+
TRTCDemo.h
16+
这是应用程序的主头文件。
17+
其中包括其他项目特定的标头(包括 Resource.h),并声明 CTRTCDemo 应用程序类。
18+
19+
TRTCDemo.cpp
20+
这是包含应用程序类 CTRTCDemo 的主应用程序源文件。
21+
22+
TRTCDemo.rc
23+
这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源包含在 2052 中。
24+
25+
res\TRTCDemo.ico
26+
这是用作应用程序图标的图标文件。此图标包括在主资源文件 TRTCDemo.rc 中。
27+
28+
res\TRTCDemo.rc2
29+
此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。
30+
31+
32+
/////////////////////////////////////////////////////////////////////////////
33+
34+
应用程序向导创建一个对话框类:
35+
36+
TRTCDemoDlg.h、TRTCDemoDlg.cpp - 对话框
37+
这些文件包含 CTRTCDemoDlg 类。此类定义应用程序的主对话框的行为。对话框模板包含在 TRTCDemo.rc 中,该文件可以在 Microsoft Visual C++ 中编辑。
38+
39+
/////////////////////////////////////////////////////////////////////////////
40+
41+
其他功能:
42+
43+
ActiveX 控件
44+
该应用程序包含对使用 ActiveX 控件的支持。
45+
46+
打印和打印预览支持
47+
应用程序向导通过从 MFC 库调用 CView 类中的成员函数生成代码,来处理打印、打印设置和打印预览命令。
48+
49+
/////////////////////////////////////////////////////////////////////////////
50+
51+
其他标准文件:
52+
53+
StdAfx.h, StdAfx.cpp
54+
这些文件用于生成名为 TRTCDemo.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
55+
56+
Resource.h
57+
这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。
58+
59+
TRTCDemo.manifest
60+
Windows XP 使用应用程序清单文件来描述特定版本的并行程序集的应用程序依赖项。加载程序使用这些信息来从程序集缓存中加载相应的程序集,并保护其不被应用程序访问。应用程序清单可能会包含在内,以作为与应用程序可执行文件安装在同一文件夹中的外部 .manifest 文件进行重新分发,它还可能以资源的形式包含在可执行文件中。
61+
/////////////////////////////////////////////////////////////////////////////
62+
63+
其他注释:
64+
65+
应用程序向导使用“TODO:”来指示应添加或自定义的源代码部分。
66+
67+
如果应用程序使用共享 DLL 中的 MFC,您将需要重新分发 MFC DLL。如果应用程序所使用的语言与操作系统的区域设置不同,则还需要重新分发相应的本地化资源 mfc110XXX.DLL。
68+
有关上述话题的更多信息,请参见 MSDN 文档中有关重新分发 Visual C++ 应用程序的部分。
69+
70+
/////////////////////////////////////////////////////////////////////////////
36.1 KB
Binary file not shown.
Binary file not shown.
23.2 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)