-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRWIni.cpp
396 lines (366 loc) · 9.9 KB
/
RWIni.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
#include "StdAfx.h"
#include "RWIni.h"
CRWIni::CRWIni(void)
{
m_strIniPath = L"";
// 得到exe执行路径.
TCHAR tcExePath[MAX_PATH] = {0};
::GetModuleFileName(NULL, tcExePath, MAX_PATH);
// 设置ini路径到exe同一目录下
#ifndef CONFIG_FILE
#define CONFIG_FILE (TEXT("Config.ini"))
#endif
//_tcsrchr() 反向搜索获得最后一个'\\'的位置,并返回该位置的指针
TCHAR *pFind = _tcsrchr(tcExePath, '\\');
if (pFind == NULL)
{
return;
}
*pFind = '\0';
CString szIniPath = tcExePath;
szIniPath += "\\";
szIniPath += CONFIG_FILE;
m_strIniPath = szIniPath;
}
CRWIni::~CRWIni(void)
{
m_strIniPath = L"";
}
void CRWIni::SetPort(int value)
{
WriteInter(L"Port", L"com_port", value);
}
int CRWIni::GetPort()
{
return ReadInter(L"Port", L"com_port");
}
void CRWIni::SetAudioPort(int value)
{
WriteInter(L"Port", L"audio_port", value);
}
int CRWIni::GetAudioPort()
{
return ReadInter(L"Port", L"audio_port");
}
void CRWIni::SetPCPort(int value)
{
WriteInter(L"Port", L"pc_port", value);
}
int CRWIni::GetPCPort()
{
return ReadInter(L"Port", L"pc_port");
}
void CRWIni::SetOutPort(int value)
{
WriteInter(L"Port", L"out_port", value);
}
int CRWIni::GetOutPort()
{
return ReadInter(L"Port", L"out_port");
}
void CRWIni::SetOutPort2(int value)
{
WriteInter(L"Port", L"out_port2", value);
}
int CRWIni::GetOutPort2()
{
return ReadInter(L"Port", L"out_port2");
}
void CRWIni::SetEvtPort(int value)
{
WriteInter(L"Port", L"evt_port", value);
}
int CRWIni::GetEvtPort()
{
return ReadInter(L"Port", L"evt_port");
}
void CRWIni::SetEvtSendPort(int value)
{
WriteInter(L"Port", L"evt_port_send", value);
}
int CRWIni::GetEvtSendPort()
{
return ReadInter(L"Port", L"evt_port_send");
}
void CRWIni::SetOuterBCControlPort(int value)
{
WriteInter(L"Port",L"outer_bc_control_port",value);
}
int CRWIni::GetOuterBCControlPort()
{
return ReadInter(L"Port",L"outer_bc_control_port");
}
void CRWIni::SetRecord(int value)
{
WriteInter(L"Params", L"record_src", value);
}
int CRWIni::GetRecord()
{
return ReadInter(L"Params", L"record_src");
}
void CRWIni::SetJT(int value)
{
WriteInter(L"Params", L"monitor_jt", value);
}
int CRWIni::GetJT()
{
return ReadInter(L"Params", L"monitor_jt");
}
void CRWIni::SetPop(int value)
{
WriteInter(L"Params", L"pop_call", value);
}
int CRWIni::GetPop()
{
return ReadInter(L"Params", L"pop_call");
}
void CRWIni::SetSocketConnect(int value)
{
WriteInter(L"Params", L"http_connect", value);
}
int CRWIni::GetSocketConnect()
{
return ReadInter(L"Params", L"http_connect");
}
void CRWIni::SetPlayTime(int value)
{
WriteInter(L"Time", L"play_time", value);
}
int CRWIni::GetPlayTime()
{
return ReadInter(L"Time", L"play_time");
}
void CRWIni::SetPath(CString strPath)
{
::WritePrivateProfileString(L"Path", L"path", strPath, m_strIniPath);
}
CString CRWIni::GetPath()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"Path", L"path", NULL, szKeyValue, MAX_PATH, m_strIniPath);
// CString strPath = szKeyValue;
// return strPath;
m_strPath = szKeyValue;
return m_strPath;
}
void CRWIni::SetPathRecord(CString strPath)
{
::WritePrivateProfileString(L"Path", L"record", strPath, m_strIniPath);
}
CString CRWIni::GetPathRecord()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"Path", L"record", NULL, szKeyValue, MAX_PATH, m_strIniPath);
// CString strPath = szKeyValue;
// return strPath;
m_strPathRecord = szKeyValue;
return m_strPathRecord;
}
void CRWIni::SetIP_Server(CString strValue)
{
::WritePrivateProfileString(L"IP", L"server_ip", strValue, m_strIniPath);
}
CString CRWIni::GetIP_Server()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"IP", L"server_ip", NULL, szKeyValue, MAX_PATH, m_strIniPath);
// CString strPath = szKeyValue;
// return strPath;
m_strIP_SERVER = szKeyValue;
return m_strIP_SERVER;
}
void CRWIni::SetIP_MIC_Reocrd(CString strValue)
{
::WritePrivateProfileString(L"IP", L"micreocrd_ip", strValue, m_strIniPath);
}
CString CRWIni::GetIP_MIC_Reocrd()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"IP", L"micreocrd_ip", L"192.168.1.7", szKeyValue, MAX_PATH, m_strIniPath);
m_strIP_MICRecord = szKeyValue;
return m_strIP_MICRecord;
}
void CRWIni::SetIP_AUX(CString strValue)
{
::WritePrivateProfileString(L"IP", L"aux_ip", strValue, m_strIniPath);
}
CString CRWIni::GetIP_AUX()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"IP", L"aux_ip", L"192.168.1.6", szKeyValue, MAX_PATH, m_strIniPath);
m_strIP_AUX = szKeyValue;
return m_strIP_AUX;
}
void CRWIni::SetIP_Monitor(CString strValue)
{
::WritePrivateProfileString(L"IP", L"monitor_ip", strValue, m_strIniPath);
}
CString CRWIni::GetIP_Monitor()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"IP", L"monitor_ip", L"192.168.1.8", szKeyValue, MAX_PATH, m_strIniPath);
m_strIP_Monitor = szKeyValue;
return m_strIP_Monitor;
}
void CRWIni::SetIP_Out(CString strValue)
{
::WritePrivateProfileString(L"IP", L"out_ip", strValue, m_strIniPath);
}
CString CRWIni::GetIP_Out()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"IP", L"out_ip", NULL, szKeyValue, MAX_PATH, m_strIniPath);
// CString strPath = szKeyValue;
// return strPath;
m_strIP_Out = szKeyValue;
return m_strIP_Out;
}
void CRWIni::SetIP_Out2(CString strValue)
{
::WritePrivateProfileString(L"IP", L"out_ip2", strValue, m_strIniPath);
}
CString CRWIni::GetIP_Out2()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"IP", L"out_ip2", NULL, szKeyValue, MAX_PATH, m_strIniPath);
// CString strPath = szKeyValue;
// return strPath;
m_strIP_Out2 = szKeyValue;
return m_strIP_Out2;
}
void CRWIni::SetIP_OUT_BC_CONTROL(CString strValue)
{
::WritePrivateProfileString(L"IP", L"outer_bc_control_ip", strValue, m_strIniPath);
}
CString CRWIni::GetIP_OUT_BC_CONTROL()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"IP", L"outer_bc_control_ip", NULL, szKeyValue, MAX_PATH, m_strIniPath);
// CString strPath = szKeyValue;
// return strPath;
m_strIP_Outer_BC_Control = szKeyValue;
return m_strIP_Outer_BC_Control;
}
void CRWIni::SetIP_MIC(CString strValue)
{
::WritePrivateProfileString(L"IP", L"mic_ip", strValue, m_strIniPath);
}
CString CRWIni::GetIP_MIC()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"IP", L"mic_ip", NULL, szKeyValue, MAX_PATH, m_strIniPath);
// CString strPath = szKeyValue;
// return strPath;
m_strIP_MIC = szKeyValue;
return m_strIP_MIC;
}
void CRWIni::SetCallA(CString strValue)
{
::WritePrivateProfileString(L"Call", L"call_a", strValue, m_strIniPath);
}
CString CRWIni::GetCallA()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"Call", L"call_a", NULL, szKeyValue, MAX_PATH, m_strIniPath);
m_strCallA = szKeyValue;
return m_strCallA;
}
void CRWIni::SetCallB(CString strValue)
{
::WritePrivateProfileString(L"Call", L"call_b", strValue, m_strIniPath);
}
CString CRWIni::GetCallB()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"Call", L"call_b", NULL, szKeyValue, MAX_PATH, m_strIniPath);
m_strCallB = szKeyValue;
return m_strCallB;
}
void CRWIni::SetOuter(CString strValue)
{
::WritePrivateProfileString(L"Call", L"outer", strValue, m_strIniPath);
}
CString CRWIni::GetOuter()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"Call", L"outer", NULL, szKeyValue, MAX_PATH, m_strIniPath);
m_strOuter = szKeyValue;
return m_strOuter;
}
void CRWIni::WriteInter(CString appName, CString keyName, int value)
{
TCHAR szKeyValue[MAX_PATH] = {0};
_itow_s(value, szKeyValue, MAX_PATH, 10);
::WritePrivateProfileString(appName, keyName, szKeyValue, m_strIniPath);
}
int CRWIni::ReadInter(CString appName, CString keyName)
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(appName, keyName, NULL, szKeyValue, MAX_PATH, m_strIniPath);
int value = _wtoi(szKeyValue);
return value;
}
void CRWIni::Set_APP_Title(CString strValue)
{
::WritePrivateProfileString(L"name", L"title", /*szTitle*/strValue, m_strIniPath);
}
CString CRWIni::Get_APP_Title()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"name", L"title", L"网络广播系统常州天涛通信有限公司", szKeyValue, MAX_PATH, m_strIniPath);
m_strAPP_Title = szKeyValue;
return m_strAPP_Title;
}
void CRWIni::Set_Sign_Left(CString strValue)
{
::WritePrivateProfileString(L"name", L"signl", /*szTitle*/strValue, m_strIniPath);
}
CString CRWIni::Get_Sign_Left()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"name", L"signl", L"广州方向", szKeyValue, MAX_PATH, m_strIniPath);
m_strAPP_SignL = szKeyValue;
return m_strAPP_SignL;
}
void CRWIni::Set_Sign_Right(CString strValue)
{
::WritePrivateProfileString(L"name", L"signr", /*szTitle*/strValue, m_strIniPath);
}
CString CRWIni::Get_Sign_Right()
{
TCHAR szKeyValue[MAX_PATH] = {0};
::GetPrivateProfileString(L"name", L"signr", L"北京方向", szKeyValue, MAX_PATH, m_strIniPath);
m_strAPP_SignR = szKeyValue;
return m_strAPP_SignR;
}
CString CRWIni::ReadStr(CString appName,CString keyName)
{
TCHAR szKeyVal[MAX_PATH] = {0};
::GetPrivateProfileString(appName, keyName, L"XX方向", szKeyVal, MAX_PATH, m_strIniPath);
m_rtnStr = szKeyVal;
return m_rtnStr;
}
void CRWIni::SetMainFlag(int nMain)
{
WriteInter(L"Params", L"main", nMain);
}
int CRWIni::GetMainFlag()
{
return ReadInter(L"Params", L"main");
}
void CRWIni::SetNetOF(int nNetOF)
{
WriteInter(L"Params", L"net_of", nNetOF);
}
int CRWIni::GetNetOF()
{
return ReadInter(L"Params", L"net_of");
}
void CRWIni::SetVolume(int nVolume)
{
WriteInter(L"Params", L"volume", nVolume);
}
int CRWIni::GetVolume()
{
return max(80, ReadInter(L"Params", L"volume"));
}