SysLib.cpp 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  1. #include "stdafx.h"
  2. #include <tlhelp32.h>
  3. #include "SysLib.h"
  4. #include <io.h>
  5. #include <odbcinst.h>
  6. #include <afxdb.h>
  7. #include "resource.h"
  8. #include "crc32.h"
  9. #include "Client2SrvType.h"
  10. #include "..\ChineseRes\ChineseRes\resource.h"
  11. #include <psapi.h>
  12. #include "Shlwapi.h"
  13. #pragma comment ( lib, "psapi.lib" )
  14. //*********************************************************
  15. //Functiopn: LogEvent
  16. //Description: 记录服务事件
  17. //Calls:
  18. //Called By:
  19. //Table Accessed:
  20. //Table Updated:
  21. //Input:
  22. //Output:
  23. //Return:
  24. //Others:
  25. //History:
  26. // <author>niying <time>2006-8-10 <version> <desc>
  27. //*********************************************************
  28. void LogEvent(LPCTSTR pFormat, ...)
  29. {
  30. TCHAR chMsg[256];
  31. HANDLE hEventSource;
  32. LPTSTR lpszStrings[1];
  33. va_list pArg;
  34. va_start(pArg, pFormat);
  35. _vstprintf(chMsg, pFormat, pArg);
  36. va_end(pArg);
  37. lpszStrings[0] = chMsg;
  38. hEventSource = RegisterEventSource(NULL, g_szServiceName);
  39. if (hEventSource != NULL)
  40. {
  41. ReportEvent(hEventSource, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (LPCTSTR*) &lpszStrings[0], NULL);
  42. DeregisterEventSource(hEventSource);
  43. }
  44. }
  45. //增加自动启动注册表项
  46. INT AddAutoSysRun(CHAR *strExeFile, INT iAutoRunSystem)
  47. {
  48. HKEY hKey = NULL;
  49. DWORD dwErrorCode = 0;
  50. //创建注册表,有该键则读取,无则创建
  51. dwErrorCode = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  52. "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
  53. 0,
  54. NULL,
  55. REG_OPTION_NON_VOLATILE,
  56. KEY_ALL_ACCESS,
  57. NULL, //Security
  58. &hKey,
  59. NULL);
  60. if (dwErrorCode == ERROR_SUCCESS)
  61. {
  62. if (iAutoRunSystem)
  63. dwErrorCode = RegSetValueEx(hKey, "DataBase Monitor Service", NULL, REG_SZ, (BYTE*)strExeFile, (DWORD)strlen(strExeFile));
  64. else
  65. dwErrorCode = RegDeleteKey(hKey, "DataBase Monitor Service");
  66. }
  67. if (NULL != hKey)
  68. RegCloseKey(hKey);
  69. hKey = NULL;
  70. return 0;
  71. }
  72. //软件时间限制代码
  73. INT ProgramEncrypt(HWND hWnd)
  74. {
  75. SYSTEMTIME systemtime;
  76. HKEY hKey = NULL;
  77. CHAR strKeyName[50] = "";
  78. CHAR strFirstDate[20] = "";
  79. CHAR strMaxDate[20] = "";
  80. CHAR strMinDate[20] = "";
  81. CHAR strNowDate[20] = "";
  82. DWORD dwErrorCode = 0;
  83. INT iNumberOfDays = 0;
  84. DWORD dwType = 0;
  85. DWORD dwSize = 0;
  86. if (g_bEnableTimeLimited == FALSE)
  87. return 1;
  88. //创建注册表,有该键则读取,无则创建
  89. strcpy(strKeyName, "Software\\stoneu");
  90. dwErrorCode = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
  91. strKeyName,
  92. 0,
  93. NULL,
  94. REG_OPTION_NON_VOLATILE,
  95. KEY_ALL_ACCESS,
  96. NULL, //Security
  97. &hKey,
  98. NULL);
  99. if (dwErrorCode == ERROR_SUCCESS)
  100. {
  101. dwType = REG_BINARY;
  102. dwSize = sizeof(strFirstDate);
  103. dwErrorCode = RegQueryValueEx(hKey,
  104. "Date",
  105. NULL,
  106. &dwType,
  107. (BYTE*)strFirstDate,
  108. &dwSize
  109. );
  110. if (dwErrorCode == ERROR_SUCCESS && strcmp(strFirstDate, ""))
  111. {
  112. ::GetLocalTime(&systemtime);
  113. CTime NowDate(systemtime.wYear, systemtime.wMonth, systemtime.wDay, systemtime.wHour, systemtime.wMinute, systemtime.wSecond);
  114. CTime MaxDate(systemtime.wYear, systemtime.wMonth, systemtime.wDay, systemtime.wHour, systemtime.wMinute, systemtime.wSecond);
  115. CTime MinDate(systemtime.wYear, systemtime.wMonth, systemtime.wDay, systemtime.wHour, systemtime.wMinute, systemtime.wSecond);
  116. iNumberOfDays = 90;
  117. MaxDate = MaxDate + CTimeSpan(iNumberOfDays, 0, 0, 0);
  118. MinDate = MinDate - CTimeSpan(iNumberOfDays, 0, 0, 0);
  119. sprintf(strMaxDate, "%04d%02d%02d", MaxDate.GetYear(), MaxDate.GetMonth(), MaxDate.GetDay());
  120. sprintf(strMinDate, "%04d%02d%02d", MinDate.GetYear(), MinDate.GetMonth(), MinDate.GetDay());
  121. if (atoi(strMaxDate) >= atoi(strFirstDate) && atoi(strMinDate) <= atoi(strFirstDate))
  122. {
  123. if (NULL != hKey)
  124. RegCloseKey(hKey);
  125. hKey = NULL;
  126. return 1;
  127. }
  128. else
  129. {
  130. LOG4C((LOG_NOTICE, "软件试用天数已经到期!"));
  131. //MessageBox(hWnd, "软件试用天数已经到期!", "提示", MB_OK+MB_ICONINFORMATION);
  132. ////超过x天,则禁止运行
  133. //::InvalidateRect(hWnd, NULL, TRUE);
  134. //::UpdateWindow(hWnd);
  135. }
  136. }
  137. else
  138. {
  139. if (NULL == hWnd)
  140. {
  141. ::GetLocalTime(&systemtime);
  142. sprintf(strFirstDate, "%04d%02d%02d", systemtime.wYear, systemtime.wMonth, systemtime.wDay);
  143. dwErrorCode = RegSetValueEx(hKey,
  144. "Date",
  145. NULL,
  146. REG_BINARY,
  147. (BYTE*)strFirstDate,
  148. sizeof(strFirstDate)
  149. );
  150. if (dwErrorCode == ERROR_SUCCESS)
  151. {
  152. if (NULL != hKey)
  153. RegCloseKey(hKey);
  154. hKey = NULL;
  155. return 1;
  156. }
  157. }
  158. }
  159. }
  160. if (NULL != hKey)
  161. RegCloseKey(hKey);
  162. hKey = NULL;
  163. return 0;
  164. }
  165. //
  166. // FindProcess
  167. // 这个函数唯一的参数是你指定的进程名,如:你的目标进程
  168. // 是 "Notepad.exe",返回值是该进程的ID,失败返回0
  169. //
  170. int FindProcessCount(char *strProcessName)
  171. {
  172. int nCount = 0;
  173. DWORD aProcesses[1024], cbNeeded, cbMNeeded;
  174. HMODULE hMods[1024];
  175. HANDLE hProcess;
  176. char szProcessName[MAX_PATH];
  177. if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) return 0;
  178. for(int i=0; i< (int) (cbNeeded / sizeof(DWORD)); i++)
  179. {
  180. //_tprintf(_T("%d\t"), aProcesses[i]);
  181. hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, aProcesses[i]);
  182. EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbMNeeded);
  183. GetModuleFileNameEx( hProcess, hMods[0], szProcessName,sizeof(szProcessName));
  184. if(strstr(szProcessName, strProcessName))
  185. {
  186. //_tprintf(_T("%s;"), szProcessName);
  187. nCount++;
  188. }
  189. //_tprintf(_T("\n"));
  190. }
  191. return nCount;
  192. }
  193. //
  194. // Function: ErrorForce
  195. // 此函数中用上面的 FindProcess 函数获得你的目标进程的ID
  196. // 用WIN API OpenPorcess 获得此进程的句柄,再以TerminateProcess
  197. // 强制结束这个进程
  198. //
  199. VOID KillProcess(DWORD dwProcess)
  200. {
  201. // When the all operation fail this function terminate the "winlogon" Process for force exit the system.
  202. HANDLE hTargetProcess = OpenProcess(PROCESS_QUERY_INFORMATION | // Required by Alpha
  203. PROCESS_CREATE_THREAD | // For CreateRemoteThread
  204. PROCESS_VM_OPERATION | // For VirtualAllocEx/VirtualFreeEx
  205. PROCESS_VM_WRITE, // For WriteProcessMemory
  206. FALSE, dwProcess);
  207. if(hTargetProcess == NULL)
  208. {
  209. return;
  210. }
  211. TerminateProcess(hTargetProcess, 0);
  212. return;
  213. }
  214. //
  215. // FindProcess
  216. // 这个函数唯一的参数是你指定的进程名,如:你的目标进程
  217. // 是 "Notepad.exe",返回值是该进程的ID,失败返回0
  218. //
  219. DWORD FindAndKillProcess(char *strProcessName)
  220. {
  221. DWORD aProcesses[1024], cbNeeded, cbMNeeded;
  222. HMODULE hMods[1024];
  223. HANDLE hProcess;
  224. char szProcessName[MAX_PATH];
  225. if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) return 0;
  226. for(int i=0; i< (int) (cbNeeded / sizeof(DWORD)); i++)
  227. {
  228. //_tprintf(_T("%d\t"), aProcesses[i]);
  229. hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, aProcesses[i]);
  230. EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbMNeeded);
  231. GetModuleFileNameEx( hProcess, hMods[0], szProcessName,sizeof(szProcessName));
  232. if(strstr(szProcessName, strProcessName))
  233. {
  234. //_tprintf(_T("%s;"), szProcessName);
  235. KillProcess(aProcesses[i]);
  236. //return(aProcesses[i]);
  237. }
  238. //_tprintf(_T("\n"));
  239. }
  240. return 0;
  241. }
  242. int Handle_DeleteTrayNullIcon( BOOL &bNullBeDel )
  243. {
  244. bNullBeDel = FALSE;
  245. HWND hStatus=::FindWindow("Shell_TrayWnd",NULL); //得到任务栏句柄
  246. if (hStatus==NULL)
  247. {
  248. //AfxMessageBox ( "Get Shell_TrayWnd error!" );
  249. return -1;
  250. }
  251. HWND hNotify=FindWindowEx(hStatus,NULL,"TrayNotifyWnd",NULL); //右下角区域
  252. if (hNotify==NULL)
  253. {
  254. //AfxMessageBox ( "Get TrayNotifyWnd error!" );
  255. return -1;
  256. }
  257. HWND hNotify1=FindWindowEx(hNotify,NULL,"SysPager",NULL);
  258. if (hNotify==NULL)
  259. {
  260. //AfxMessageBox ( "Get SysPager error!" );
  261. return -1;
  262. }
  263. HWND hNotify1_0=FindWindowEx(hNotify1,NULL,"ToolBarWindow32",NULL);//右下角区域(不包括时间)
  264. if (hNotify1_0==NULL)
  265. {
  266. //AfxMessageBox ( "Get ToolBarWindow32 error!" );
  267. return -1;
  268. }
  269. //-------------------以上是得到任务栏右下脚一块地方的句柄
  270. DWORD pid = 0;
  271. GetWindowThreadProcessId(hNotify1_0,&pid);
  272. if (pid==NULL)
  273. {
  274. //AfxMessageBox ( "Get pid error!" );
  275. return -1;
  276. }
  277. HANDLE hProcess=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_ALL_ACCESS,true,pid);
  278. if (hProcess==NULL)
  279. {
  280. //AfxMessageBox ( "Get hd error!" );
  281. return -1;
  282. }
  283. ::SendMessage(hNotify1_0,WM_PAINT ,NULL,NULL);
  284. CRect rect;
  285. ::GetWindowRect(hNotify1_0,&rect);
  286. ::InvalidateRect(hNotify1_0,&rect,false);
  287. int iNum = (int)::SendMessage(hNotify1_0,TB_BUTTONCOUNT ,NULL,NULL); //获取任务栏上图标个数
  288. unsigned long n = 0;
  289. TBBUTTON *pButton = new TBBUTTON;
  290. CString strInfo = _T("");
  291. wchar_t name[256] = {0};
  292. TBBUTTON BButton;
  293. unsigned long whd,proid;
  294. CString x;
  295. for(int i=0; i<iNum; i++)
  296. {
  297. ::SendMessage(hNotify1_0,TB_GETBUTTON,i,(LPARAM)(&BButton));
  298. ReadProcessMemory(hProcess,&BButton,pButton,sizeof(TBBUTTON),&n);
  299. if (pButton->iString != 0xffffffff)
  300. {
  301. try
  302. {
  303. ReadProcessMemory(hProcess,(void *)pButton->iString,name,255,&n);
  304. }
  305. catch(...)
  306. {
  307. }
  308. strInfo.Format("%d : %s\n",i+1,CString(name));
  309. //TRACE(strInfo);
  310. }
  311. try
  312. {
  313. whd=0;
  314. ReadProcessMemory(hProcess,(void *)pButton->dwData,&whd,4,&n);
  315. }
  316. catch(...)
  317. {
  318. }
  319. proid=NULL;
  320. GetWindowThreadProcessId((HWND)whd,&proid);
  321. if(proid==NULL)
  322. {
  323. bNullBeDel = TRUE;
  324. ::SendMessage(hNotify1_0,TB_DELETEBUTTON,i,0);
  325. }
  326. }
  327. delete pButton;
  328. return 0;
  329. }
  330. int GetSysData()
  331. {
  332. CHAR strFile[MAX_FILE_LENGTH + 1] = "";
  333. CHAR strValue[MAX_VALUE_LENGTH + 1] = "";
  334. int iPosFile = 0;
  335. int iLenghtFile = 0;
  336. ////////////////////////////////////////////////////////////////////////////
  337. //获取应用名
  338. //GetModuleFileName(AfxGetApp()->m_hInstance, g_strDirectory, MAX_PATH);
  339. GetModuleFileName(NULL, g_strDirectory, MAX_PATH);
  340. iLenghtFile = (int)strlen(g_strDirectory);
  341. for (iPosFile = iLenghtFile - 1; iPosFile >= 0; iPosFile--)
  342. {
  343. if (g_strDirectory[iPosFile] == '\\')
  344. {
  345. memset(g_strAppName, 0, sizeof(g_strAppName));
  346. memcpy(g_strAppName, g_strDirectory + iPosFile + 1, iLenghtFile - iPosFile - 1);
  347. break;
  348. }
  349. }
  350. iLenghtFile = strlen(g_strDirectory);
  351. for (iPosFile = iLenghtFile - 1; iPosFile >= 0; iPosFile--)
  352. {
  353. if (g_strDirectory[iPosFile] == '\\')
  354. {
  355. g_strDirectory[iPosFile] = '\0';
  356. break;
  357. }
  358. }
  359. wsprintf(strFile, "%s\\ServicesInfo.ini", g_strDirectory);
  360. // 是否自动启动系统;
  361. GetPrivateProfileString("Other", "AutoRunSystem", "", strValue, sizeof(strValue), strFile);
  362. if (strcmp(strValue, ""))
  363. g_iAutoRunSystem = atoi(strValue);
  364. else
  365. g_iAutoRunSystem = 0;
  366. if (g_iAutoRunSystem <= 0)
  367. g_iAutoRunSystem = 0;
  368. else
  369. g_iAutoRunSystem = 1;
  370. //WatchService
  371. GetPrivateProfileString("WatchServer", "ServerIP", "", g_strWatchServerIP, sizeof(g_strWatchServerIP), strFile);
  372. GetPrivateProfileString("WatchServer", "Port", "", g_strWatchServerPort, sizeof(g_strWatchServerPort), strFile);
  373. int nStdOut = GetPrivateProfileInt("WatchServer", "StdOut", 0, strFile);
  374. if ( nStdOut == 1 )
  375. {
  376. AllocConsole(); // 开辟控制台;
  377. SetConsoleTitle(_T("EMSoftServices调试输出")); // 设置控制台窗口标题;
  378. freopen("CONOUT$", "w+t", stdout); // 重定向输出;
  379. freopen("CONIN$", "r+t", stdin); // 重定向输入;
  380. HWND hWnd = NULL;
  381. again:
  382. hWnd = ::FindWindow(NULL, _T("EMSoftServices调试输出"));
  383. if( hWnd )
  384. {
  385. if (!::SetWindowPos(hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE))
  386. {
  387. printf(_T("前置设置失败\n"));
  388. }
  389. else
  390. {
  391. printf(_T("前置设置成功\n"));
  392. }
  393. }
  394. else
  395. {
  396. nStdOut++;
  397. if ( nStdOut <= 10 )
  398. goto again;
  399. }
  400. }
  401. // 语言;
  402. GetPrivateProfileString("Other", "Language", "", g_strLanguage, sizeof(g_strLanguage), strFile);
  403. // Database;
  404. GetPrivateProfileString("Database", "DBType", "", g_strDBType, sizeof(g_strDBType), strFile);
  405. GetPrivateProfileString("Database", "AccessFile", "", g_strAccessFile, sizeof(g_strAccessFile), strFile);
  406. GetPrivateProfileString("Database", "ServerName", "", g_strServerName, sizeof(g_strServerName), strFile);
  407. GetPrivateProfileString("Database", "DataBaseName", "", g_strDataBaseName, sizeof(g_strDataBaseName), strFile);
  408. GetPrivateProfileString("Database", "UserName", "", g_strUserName, sizeof(g_strUserName), strFile);
  409. GetPrivateProfileString("Database", "Password", "", g_strPassword, sizeof(g_strPassword), strFile);
  410. g_dwDataBasePort = GetPrivateProfileInt("Database", "DataBasePort", 5432, strFile);
  411. //数据库连接串;
  412. if (!_stricmp(g_strDBType, "SQL SERVER"))
  413. sprintf(g_strConnectString, "Provider=sqloledb;Data Source=%s,1433;Initial Catalog=%s;User Id=%s;Password=%s; ",
  414. g_strServerName, g_strDataBaseName, g_strUserName, g_strPassword);
  415. else if (!_stricmp(g_strDBType, "ACCESS97"))
  416. sprintf(g_strConnectString, "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=%s", g_strAccessFile);
  417. else if (!_stricmp(g_strDBType, "ACCESS2000"))
  418. sprintf(g_strConnectString, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s", g_strAccessFile);
  419. else if(!_stricmp(g_strDBType, "PGSQL"))
  420. sprintf(g_strConnectString, "DRIVER={PostgreSQL ODBC Driver(UNICODE)}; SERVER=%s; port=%d; DATABASE=%s; UID=%s; PWD=%s;",
  421. g_strServerName, g_dwDataBasePort, g_strDataBaseName, g_strUserName, g_strPassword);
  422. else
  423. sprintf(g_strConnectString, "Provider=sqloledb;Data Source=%s;Initial Catalog=%s;User Id=%s;Password=%s; ",
  424. g_strServerName, g_strDataBaseName, g_strUserName, g_strPassword);
  425. //Common
  426. g_nLevelWav = GetPrivateProfileInt("Common", "LevelWav", 3, strFile);
  427. g_nLevelSms = GetPrivateProfileInt("Common", "LevelSms", 3, strFile);
  428. g_nLevelEmail = GetPrivateProfileInt("Common", "LevelEmail", 3, strFile);
  429. g_nLevelDevInterrupt = GetPrivateProfileInt("Common", "LevelDevInterrupt", 8, strFile);
  430. g_nLevelDlg = GetPrivateProfileInt("Common", "LevelDlg", 1, strFile);
  431. g_nLevelLocalWav = GetPrivateProfileInt("Common", "LevelLocalWav", 1, strFile);
  432. g_nDBRecordDate = GetPrivateProfileInt("Common", "DbRecordDate", 365, strFile);
  433. GetPrivateProfileString("Common", "NoticePre", "", g_strNoticePre, sizeof(g_strNoticePre), strFile);
  434. GetPrivateProfileString("Common","NoticeDelay","",strValue,sizeof(strValue),strFile);
  435. g_nNoticeDelay = atoi( strValue );
  436. if( g_nNoticeDelay<=0 || g_nNoticeDelay>600 )
  437. g_nNoticeDelay = 20;
  438. GetPrivateProfileString("Common","EncryptionType","",strValue,sizeof(strValue),strFile);
  439. g_nEncryptionType = atoi( strValue );
  440. if( g_nEncryptionType>1 && g_nEncryptionType!=476 )
  441. g_nEncryptionType = 0;
  442. //Email
  443. g_nSendEmail = GetPrivateProfileInt("Email", "SendEmail", 0, strFile);
  444. GetPrivateProfileString("Email", "SMTPServer", "", g_strEmailSMTPSrv, sizeof(g_strEmailSMTPSrv), strFile);
  445. g_nEmailSMTPPort = GetPrivateProfileInt("Email", "SMTPPort", 25, strFile);
  446. g_nEmailIsNeed = GetPrivateProfileInt("Email", "IsNeed", 1, strFile);
  447. GetPrivateProfileString("Email", "UserAcc", "", g_strEmailUserAcc, sizeof(g_strEmailUserAcc), strFile);
  448. GetPrivateProfileString("Email", "UserPwd", "", g_strEmailUserPwd, sizeof(g_strEmailUserPwd), strFile);
  449. GetPrivateProfileString("Email", "MailFrom", "", g_strEmailFromAddr, sizeof(g_strEmailFromAddr), strFile);
  450. g_nEmailTimeOut = GetPrivateProfileInt("Email", "TimeOut", 60, strFile);
  451. GetPrivateProfileString("Email", "Subject", "", g_strEmailSubject, sizeof(g_strEmailSubject), strFile);
  452. g_nEmailCallTimes = GetPrivateProfileInt("Email", "ReCallTimes", 2, strFile);
  453. //Sms
  454. g_nSendSms = GetPrivateProfileInt("Sms", "SendSms", 0, strFile);
  455. GetPrivateProfileString("Sms", "Port", "", g_strSmsComPort, sizeof(g_strSmsComPort), strFile);
  456. g_nSmsRate = GetPrivateProfileInt("Sms", "Rate", 115200, strFile);
  457. g_nSmsDataBit = GetPrivateProfileInt("Sms", "DataBit", 8, strFile);
  458. g_nSmsStopBit = GetPrivateProfileInt("Sms", "StopBit", 1, strFile);
  459. g_nSmsParity = GetPrivateProfileInt("Sms", "Parity", 0, strFile);
  460. g_nSmsInterval = GetPrivateProfileInt("Sms", "Interval", 0, strFile);
  461. g_nSmsLanguageTrans = GetPrivateProfileInt("Sms", "LanguageTrans", 0, strFile);
  462. g_nSmsMaxChar = GetPrivateProfileInt("Sms", "MaxChar", 0, strFile);
  463. g_nSmsMakeCall = GetPrivateProfileInt("Sms", "MakeCall", 0, strFile);
  464. GetPrivateProfileString("Sms", "SMSC", "", g_strSmsSMSC, sizeof(g_strSmsSMSC), strFile);
  465. g_nSmsTimOut = GetPrivateProfileInt("Sms", "TimeOut", 60, strFile);
  466. g_nSmsCallTimes = GetPrivateProfileInt("Sms", "ReCallTimes", 2, strFile);
  467. //Voice
  468. g_bSendVoice = GetPrivateProfileInt("Voice", "SendNotice", 0, strFile);
  469. g_nNoticeCardType = GetPrivateProfileInt("Voice", "CardType", 0, strFile);
  470. GetPrivateProfileString("Voice", "PreTel", "", g_strNoticeTelPre, sizeof(g_strNoticeTelPre), strFile);
  471. g_nNoticeCallDelay = GetPrivateProfileInt("Voice", "CallRelay", 60, strFile);
  472. g_nNoticeCallTimes = GetPrivateProfileInt("Voice", "ReCallTimes", 2, strFile);
  473. //TTS
  474. g_nTTSType = GetPrivateProfileInt("TTS", "VoiceType", 0, strFile);
  475. g_nTTSRate = GetPrivateProfileInt("TTS", "VoiceRate", 0, strFile);
  476. g_nTTSVolume = GetPrivateProfileInt("TTS", "VoiceVolume", 0, strFile);
  477. if( g_nTTSType<0 )
  478. g_nTTSType = 0;
  479. if( g_nTTSType>100 )
  480. g_nTTSType = 0;
  481. if( g_nTTSRate<-10 )
  482. g_nTTSRate = -10;
  483. if( g_nTTSRate>10 )
  484. g_nTTSRate = 10;
  485. if( g_nTTSVolume<=0 )
  486. g_nTTSVolume = 100;
  487. if( g_nTTSVolume>100 )
  488. g_nTTSVolume = 100;
  489. //AlarmMode
  490. g_nAlarmModeIsDlg = GetPrivateProfileInt("AlarmMode", "Dlg", 0, strFile);
  491. g_nAlarmModeShowDlgTimes = GetPrivateProfileInt("AlarmMode", "ShowTime", 1, strFile);
  492. g_nAlarmModeIsSound = GetPrivateProfileInt("AlarmMode", "Sound", 0, strFile);
  493. g_nAlarmModeSoundNum = GetPrivateProfileInt("AlarmMode", "PlayNum", 1, strFile);
  494. //Log文件
  495. GetPrivateProfileString("Other", "SummaryLog", "", g_strSummaryLogPath, sizeof(g_strSummaryLogPath), strFile);
  496. g_nLogSaveTimes = GetPrivateProfileInt("Other", "LogSaveTimes", 0, strFile);
  497. if( g_nLogSaveTimes<=6 )
  498. g_nLogSaveTimes = 6;
  499. //定时发送短信和电话参数配置
  500. g_nTimingEnable = GetPrivateProfileInt("Timing", "Enable", 0, strFile);
  501. g_nTimingWeeks = GetPrivateProfileInt("Timing", "Weeks", 0, strFile);
  502. g_nTimingHours = GetPrivateProfileInt("Timing", "Hours", 0, strFile);
  503. g_nTimingMinutes = GetPrivateProfileInt("Timing", "Minutes", 0, strFile);
  504. g_nTimingPreiods = GetPrivateProfileInt("Timing", "Preiod", 0, strFile);
  505. //变量输出,特别为上海烟草局做的
  506. g_nOutputEnable = GetPrivateProfileInt("output", "Enable", 0, strFile);
  507. GetPrivateProfileString("output", "path", "", g_strOutputPath, sizeof(g_strOutputPath), strFile);
  508. GetPrivateProfileString("output", "filename", "", g_strOutputFileName, sizeof(g_strOutputFileName), strFile);
  509. GetPrivateProfileString("output", "clock", "", g_strOutputClock, sizeof(g_strOutputClock), strFile);
  510. GetPrivateProfileString("output", "line1", "", g_strOutputLine1, sizeof(g_strOutputLine1), strFile);
  511. GetPrivateProfileString("output", "line2", "", g_strOutputLine2, sizeof(g_strOutputLine2), strFile);
  512. GetPrivateProfileString("output", "line3", "", g_strOutputLine3, sizeof(g_strOutputLine3), strFile);
  513. GetPrivateProfileString("output", "line4", "", g_strOutputLine4, sizeof(g_strOutputLine4), strFile);
  514. GetPrivateProfileString("output", "line5", "", g_strOutputLine5, sizeof(g_strOutputLine5), strFile);
  515. GetPrivateProfileString("output", "line6", "", g_strOutputLine6, sizeof(g_strOutputLine6), strFile);
  516. GetPrivateProfileString("output", "line7", "", g_strOutputLine7, sizeof(g_strOutputLine7), strFile);
  517. GetPrivateProfileString("output", "line8", "", g_strOutputLine8, sizeof(g_strOutputLine8), strFile);
  518. GetPrivateProfileString("output", "line9", "", g_strOutputLine9, sizeof(g_strOutputLine9), strFile);
  519. GetPrivateProfileString("output", "line10", "", g_strOutputLine10, sizeof(g_strOutputLine10), strFile);
  520. g_nOutputLineCount1 = GetPrivateProfileInt("output", "lineCount1", 0, strFile);
  521. g_nOutputLineCount2 = GetPrivateProfileInt("output", "lineCount2", 0, strFile);
  522. g_nOutputLineCount3 = GetPrivateProfileInt("output", "lineCount3", 0, strFile);
  523. g_nOutputLineCount4 = GetPrivateProfileInt("output", "lineCount4", 0, strFile);
  524. g_nOutputLineCount5 = GetPrivateProfileInt("output", "lineCount5", 0, strFile);
  525. g_nOutputLineCount6 = GetPrivateProfileInt("output", "lineCount6", 0, strFile);
  526. g_nOutputLineCount7 = GetPrivateProfileInt("output", "lineCount7", 0, strFile);
  527. g_nOutputLineCount8 = GetPrivateProfileInt("output", "lineCount8", 0, strFile);
  528. g_nOutputLineCount9 = GetPrivateProfileInt("output", "lineCount9", 0, strFile);
  529. g_nOutputLineCount10 = GetPrivateProfileInt("output", "lineCount10", 0, strFile);
  530. GetPrivateProfileString("output", "lineUid1", "", g_strOutputLineUid1, sizeof(g_strOutputLineUid1), strFile);
  531. GetPrivateProfileString("output", "lineUid2", "", g_strOutputLineUid2, sizeof(g_strOutputLineUid2), strFile);
  532. GetPrivateProfileString("output", "lineUid3", "", g_strOutputLineUid3, sizeof(g_strOutputLineUid3), strFile);
  533. GetPrivateProfileString("output", "lineUid4", "", g_strOutputLineUid4, sizeof(g_strOutputLineUid4), strFile);
  534. GetPrivateProfileString("output", "lineUid5", "", g_strOutputLineUid5, sizeof(g_strOutputLineUid5), strFile);
  535. GetPrivateProfileString("output", "lineUid6", "", g_strOutputLineUid6, sizeof(g_strOutputLineUid6), strFile);
  536. GetPrivateProfileString("output", "lineUid7", "", g_strOutputLineUid7, sizeof(g_strOutputLineUid7), strFile);
  537. GetPrivateProfileString("output", "lineUid8", "", g_strOutputLineUid8, sizeof(g_strOutputLineUid8), strFile);
  538. GetPrivateProfileString("output", "lineUid9", "", g_strOutputLineUid9, sizeof(g_strOutputLineUid9), strFile);
  539. GetPrivateProfileString("output", "lineUid10", "", g_strOutputLineUid10, sizeof(g_strOutputLineUid10), strFile);
  540. g_nSnmpEnable = GetPrivateProfileInt("Snmp", "Enable", 0, strFile);
  541. GetPrivateProfileString("Snmp", "OidRoot", "", g_strSnmpOidRoot, sizeof(g_strSnmpOidRoot), strFile);
  542. GetPrivateProfileString("Snmp", "IP", "", g_strSnmpIP, sizeof(g_strSnmpIP), strFile);
  543. GetPrivateProfileString("Snmp", "Field", "", g_strSnmpField, sizeof(g_strSnmpField), strFile);
  544. ////////////////////////////////////////////////////////////////////////////
  545. ////////////////////////////////////////////////////////////////////////////
  546. //增加自动启动注册表项
  547. #if 0
  548. wsprintf(strFile, "%s\\%s", g_strDirectory, g_strAppName);
  549. AddAutoSysRun(strFile, g_iAutoRunSystem);
  550. #endif
  551. return 0;
  552. }
  553. int GetResourceString()
  554. {
  555. g_strServiceName.LoadString(IDS_SERVICE_NAME);
  556. g_strHintSysRun.LoadString(IDS_HINT_SYS_RUN);
  557. g_strHintAlarmWelcome.LoadString(IDS_HINT_ALARM_WELCOME);
  558. g_strHintVoiceEnd.LoadString(IDS_HINT_VOICE_END);
  559. g_strHintReturnNormal.LoadString(IDS_HINT_RETURN_NORMAL);
  560. g_strHintUpperLimit.LoadString(IDS_HINT_UPPER_LIMIT);
  561. g_strHintLowerLimit.LoadString(IDS_HINT_LOWER_LIMIT);
  562. g_strHintCurrValue.LoadString(IDS_HINT_CURR_VALUE);
  563. g_strHintBlance.LoadString(IDS_NOTICE_BLANCE);
  564. g_strHintDateLimit.LoadString(IDS_NOTICE_DATELIMIT);
  565. return 0;
  566. }
  567. VOID TerminateLastProcess()
  568. {
  569. HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  570. if (hSnapShot != NULL)
  571. {
  572. PROCESSENTRY32 ProcessInfo = {0};//声明进程信息变量;
  573. ProcessInfo.dwSize = sizeof(ProcessInfo);//设置ProcessInfo的大小;
  574. //返回系统中第一个进程的信息;
  575. BOOL bStatus = Process32First(hSnapShot, &ProcessInfo);
  576. while (bStatus)
  577. {
  578. if (!_stricmp(g_strAppName, ProcessInfo.szExeFile))//映像名称;
  579. {
  580. HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessInfo.th32ProcessID);
  581. ::TerminateProcess(hProcess, 1);
  582. hProcess = NULL;
  583. Sleep(1000);
  584. break;
  585. }
  586. else
  587. //获取下一个进程的信息;
  588. bStatus = Process32Next(hSnapShot, &ProcessInfo);
  589. }
  590. }
  591. }
  592. //-------------------------------------------------------------------------------------
  593. //Description:
  594. // This function maps a character string to a wide-character (Unicode) string
  595. //
  596. //Parameters:
  597. // lpcszStr: [in] Pointer to the character string to be converted
  598. // lpwszStr: [out] Pointer to a buffer that receives the translated string.
  599. // dwSize: [in] Size of the buffer
  600. //
  601. //Return Values:
  602. // TRUE: Succeed
  603. // FALSE: Failed
  604. //
  605. //Example:
  606. // MByteToWChar(szA,szW,sizeof(szW)/sizeof(szW[0]));
  607. //---------------------------------------------------------------------------------------
  608. BOOL MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize)
  609. {
  610. // Get the required size of the buffer that receives the Unicode
  611. // string.
  612. DWORD dwMinSize;
  613. dwMinSize = MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, NULL, 0);
  614. if(dwSize < dwMinSize)
  615. {
  616. return FALSE;
  617. }
  618. // Convert headers from ASCII to Unicode.
  619. MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, lpwszStr, dwMinSize);
  620. return TRUE;
  621. }
  622. //-------------------------------------------------------------------------------------
  623. //Description:
  624. // This function maps a wide-character string to a new character string
  625. //
  626. //Parameters:
  627. // lpcwszStr: [in] Pointer to the character string to be converted
  628. // lpszStr: [out] Pointer to a buffer that receives the translated string.
  629. // dwSize: [in] Size of the buffer
  630. //
  631. //Return Values:
  632. // TRUE: Succeed
  633. // FALSE: Failed
  634. //
  635. //Example:
  636. // MByteToWChar(szW,szA,sizeof(szA)/sizeof(szA[0]));
  637. //---------------------------------------------------------------------------------------
  638. BOOL WCharToMByte(LPCWSTR lpcwszStr, LPSTR lpszStr, DWORD dwSize)
  639. {
  640. DWORD dwMinSize;
  641. dwMinSize = WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,NULL,0,NULL,FALSE);
  642. if(dwSize < dwMinSize)
  643. {
  644. return FALSE;
  645. }
  646. WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,lpszStr,dwSize,NULL,FALSE);
  647. return TRUE;
  648. }
  649. //////////////////////////////////////////////////////////////////////////////
  650. //名称:GetExcelDriver
  651. //功能:获取ODBC中Excel驱动
  652. //作者:徐景周(jingzhou_xu@163.net)
  653. //组织:未来工作室(Future Studio)
  654. //日期:2002.9.1
  655. /////////////////////////////////////////////////////////////////////////////
  656. CString GetExcelDriver()
  657. {
  658. char szBuf[2001];
  659. WORD cbBufMax = 2000;
  660. WORD cbBufOut;
  661. char *pszBuf = szBuf;
  662. CString sDriver;
  663. // 获取已安装驱动的名称(涵数在odbcinst.h里)
  664. if (!SQLGetInstalledDrivers(szBuf, cbBufMax, &cbBufOut))
  665. return "";
  666. // 检索已安装的驱动是否有Excel...
  667. do
  668. {
  669. if (strstr(pszBuf, "Excel") != 0)
  670. {
  671. //发现 !
  672. sDriver = CString(pszBuf);
  673. break;
  674. }
  675. pszBuf = strchr(pszBuf, '\0') + 1;
  676. }
  677. while (pszBuf[1] != '\0');
  678. return sDriver;
  679. }
  680. ///////////////////////////////////////////////////////////////////////////////
  681. // BOOL MakeSurePathExists( CString &Path,bool FilenameIncluded)
  682. // 参数:
  683. // Path 路径
  684. // FilenameIncluded 路径是否包含文件名
  685. // 返回值:
  686. // 文件是否存在
  687. // 说明:
  688. // 判断Path文件(FilenameIncluded=true)是否存在,存在返回TURE,不存在返回FALSE
  689. // 自动创建目录
  690. //
  691. ///////////////////////////////////////////////////////////////////////////////
  692. BOOL MakeSurePathExists( CString &Path,
  693. bool FilenameIncluded)
  694. {
  695. int Pos=0;
  696. while((Pos=Path.Find('\\',Pos+1))!=-1)
  697. CreateDirectory(Path.Left(Pos),NULL);
  698. if(!FilenameIncluded)
  699. CreateDirectory(Path,NULL);
  700. // return ((!FilenameIncluded)?!_access(Path,0):
  701. // !_access(Path.Left(Path.ReverseFind('\\')),0));
  702. return !_access(Path,0);
  703. }
  704. int GetSensorType( CString strSensorType )
  705. {
  706. /*int nSensorType;
  707. if( !strSensorType.Compare((char*)(LPCTSTR)g_strTempTypeDesc) )
  708. {
  709. nSensorType = 1;
  710. }
  711. else if( !strSensorType.Compare((char*)(LPCTSTR)g_str4To20TypeDesc) )
  712. {
  713. nSensorType = 2;
  714. }
  715. else if( !strSensorType.Compare((char*)(LPCTSTR)g_strHumidityTypeDesc) )
  716. {
  717. nSensorType = 3;
  718. }
  719. else if( !strSensorType.Compare("Water") )
  720. {
  721. nSensorType = 4;
  722. }
  723. else if( !strSensorType.Compare((char*)(LPCTSTR)g_strDCTypeDesc) )
  724. {
  725. nSensorType = 5;
  726. }
  727. else if( !strSensorType.Compare((char*)(LPCTSTR)g_strSecurityTypeDesc) )
  728. {
  729. nSensorType = 6;
  730. }
  731. else if( !strSensorType.Compare("Airflow") )
  732. {
  733. nSensorType = 8;
  734. }
  735. else if( !strSensorType.Compare("Siren") )
  736. {
  737. nSensorType = 9;
  738. }
  739. else if( !strSensorType.Compare((char*)(LPCTSTR)g_strDryTypeDesc) )
  740. {
  741. nSensorType = 10;
  742. }
  743. else if( !strSensorType.Compare("AC Voltage") )
  744. {
  745. nSensorType = 12;
  746. }
  747. else if( !strSensorType.Compare((char*)(LPCTSTR)g_strRelayTypeDesc) )
  748. {
  749. nSensorType = 13;
  750. }
  751. else if( !strSensorType.Compare(SENSOR_AI_DESC) )
  752. {
  753. nSensorType = 20;
  754. }
  755. else if( !strSensorType.Compare(SENSOR_DI_DESC) )
  756. {
  757. nSensorType = 21;
  758. }
  759. else if( !strSensorType.Compare(SENSOR_DO_DESC) )
  760. {
  761. nSensorType = 22;
  762. }
  763. else
  764. {
  765. nSensorType = 0;
  766. }
  767. return nSensorType;*/
  768. return true;
  769. }
  770. CString GetSensorType( int nSensorType )
  771. {
  772. /* CString strSensorType = "";
  773. switch( nSensorType )
  774. {
  775. case 1:
  776. strSensorType = CString(" ") + g_strTempTypeDesc;
  777. break;
  778. case 2:
  779. strSensorType = CString(" ") + g_str4To20TypeDesc;
  780. break;
  781. case 3:
  782. strSensorType = CString(" ") + g_strHumidityTypeDesc;
  783. break;
  784. case 4:
  785. strSensorType = " Water";
  786. break;
  787. case 5:
  788. strSensorType = CString(" ") + g_strDCTypeDesc;
  789. break;
  790. case 6:
  791. strSensorType = CString(" ") + g_strSecurityTypeDesc;
  792. break;
  793. case 8:
  794. strSensorType = " Airflow";
  795. break;
  796. case 9:
  797. strSensorType = " Siren";
  798. break;
  799. case 10:
  800. strSensorType = CString(" ") + g_strDryTypeDesc;
  801. break;
  802. case 12:
  803. strSensorType = " AC Voltage";
  804. break;
  805. case 13:
  806. strSensorType = CString(" ") + g_strRelayTypeDesc;
  807. break;
  808. case 14:
  809. strSensorType = " Motion";
  810. break;
  811. case 20:
  812. strSensorType = " AI";
  813. break;
  814. case 21:
  815. strSensorType = " DI";
  816. break;
  817. case 22:
  818. strSensorType = " DO";
  819. break;
  820. }
  821. return strSensorType;*/
  822. return "";
  823. }
  824. CString InterceptString(int qlen, CString strSource)
  825. {
  826. int len,i,y;
  827. CString sTemp,sreturn;
  828. strSource.TrimLeft();
  829. strSource.TrimRight();
  830. len=strSource.GetLength();
  831. y=0;
  832. sTemp=strSource.Right(len-qlen);
  833. for(i=0;i<len;i++)
  834. {
  835. //if(sTemp[y]<0 || sTemp[y]>255)
  836. //if(sTemp[i]<0 || sTemp[i]>=128)
  837. //if(sTemp.GetAt(y) & 0x80 )
  838. if(::IsDBCSLeadByte(sTemp.GetAt(y)))
  839. y=y+2;
  840. else
  841. y=y+1;
  842. if(y>=70)
  843. break;
  844. }
  845. sreturn=sTemp.Left(y);
  846. return sreturn;
  847. }
  848. //显示选择文件夹窗口
  849. //参数 sFolderPath:用于返回用户选择的文件夹的路径
  850. //参数 sTitle:用于指定选择文件夹窗口的标题
  851. //返回值 :操作结果,用户取消选择或操作失败返回FALSE,否则TRUE
  852. BOOL BrowseForFolder(CString & sFolderPath, CString sTitle)
  853. {
  854. BROWSEINFO bi;
  855. char Buffer[_MAX_PATH];
  856. bi.hwndOwner = NULL;
  857. bi.pidlRoot = NULL;
  858. bi.pszDisplayName = Buffer;
  859. bi.lpszTitle = sTitle;
  860. bi.ulFlags = 0;
  861. bi.lpfn = NULL;
  862. LPITEMIDLIST pIDList = SHBrowseForFolder(& bi);
  863. if (!pIDList)
  864. return FALSE;
  865. SHGetPathFromIDList(pIDList, Buffer);
  866. sFolderPath = Buffer;
  867. LPMALLOC lpMalloc;
  868. if (FAILED(SHGetMalloc(& lpMalloc)))
  869. return FALSE;
  870. //释放内存
  871. lpMalloc->Free(pIDList);
  872. lpMalloc->Release();
  873. return TRUE;
  874. }
  875. void TimeTicksToInt(CString strSrc, unsigned long &nDest)
  876. {
  877. CString strLeft;
  878. int nIndex = strSrc.Find(":");
  879. if( nIndex != -1 )
  880. {
  881. strLeft = strSrc.Left( nIndex - 1 );
  882. nDest = atoi(strLeft);
  883. }
  884. }
  885. unsigned int CalcCheckSum( void *pData, unsigned int nSize )
  886. {
  887. unsigned int checksum = 0;
  888. if ( nSize <= sizeof( ProtocolHeader ) )
  889. {
  890. return 0;
  891. }
  892. unsigned char *pBody = &( ( unsigned char* )pData )[ sizeof( ProtocolHeader ) ];
  893. nSize -= sizeof( ProtocolHeader );
  894. if( pBody )
  895. {
  896. checksum = crc32( 0, pBody, nSize );
  897. }
  898. return checksum;
  899. }
  900. int SplitStr(CHAR *strSource, CHAR cChar, int iItem, CHAR *strGet)
  901. {
  902. int iIndex = 0;
  903. int iIndexThis = -1;
  904. int iIndexNext = -1;
  905. int iLength = 0;
  906. int iItemThis = 0;
  907. CHAR strFileName[MAX_FILE_LENGTH + 1] = "";
  908. iLength = strlen(strSource);
  909. while (iIndex < iLength)
  910. {
  911. if (strSource[iIndex] == cChar)
  912. {
  913. iItemThis++;
  914. if (iItemThis == iItem)
  915. iIndexThis = iIndex;
  916. else if (iItemThis == iItem + 1)
  917. {
  918. iIndexNext = iIndex;
  919. break;
  920. }
  921. }
  922. iIndex++;
  923. }
  924. if (iIndexNext > 0 && iIndexNext > iIndexThis)
  925. {
  926. memcpy(strGet, strSource + iIndexThis + 1, iIndexNext - iIndexThis - 1);
  927. strGet[iIndexNext - iIndexThis - 1] = '\0';
  928. }
  929. else
  930. strcpy(strGet, "");
  931. return 0;
  932. }