1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #include "StdAfx.h"
- #include "Utility.h"
- namespace Utility
- {
- // 当前DLL模块句柄;
- HMODULE g_hDLLModule = NULL;
- // 当前DLL内部工作者线程句柄;
- HANDLE hWorkThreadProc = NULL;
- // 当前DLL所在路径;
- TCHAR g_szCurModulePath[MAX_PATH] = {0};
- // 管道实例;
- CPipeClient *g_pPipeClient = NULL;
- // 配置文件名称;
- TCHAR g_szConfigFile[MAX_PATH] = {0};
- // 配置文件内容;
- CFG_CTX g_cfgCtx;
- //////////////////////////////////////////////////////////////////////////
- // 全局函数;
- // 获取配置文件内容;
- void GetConfigContent()
- {
- // 获取dll的目录;
- TCHAR szDrive[MAX_PATH] = { 0 };
- TCHAR szDir[MAX_PATH] = { 0 };
- TCHAR szExt[MAX_PATH] = { 0 };
- TCHAR szFna[MAX_PATH] = { 0 };
- ::GetModuleFileName(g_hDLLModule, g_szCurModulePath, sizeof(g_szCurModulePath) / sizeof(TCHAR));
- _tsplitpath_s(g_szCurModulePath, szDrive, szDir, szFna, szExt);
- _tcscpy_s(g_szCurModulePath, szDrive);
- _tcscat_s(g_szCurModulePath, szDir);
- // 设置配置文件;
- _stprintf_s(g_szConfigFile, _T("%s%s"), g_szCurModulePath, _T("Assist.ini"));
- // 读取配置文件;
- TCHAR szValue[MAX_PATH] = {0};
- GetPrivateProfileString(_T("Windows"), _T("Title"), _T(""), g_cfgCtx.szWindowTitel, MAX_PATH, g_szConfigFile);
- GetPrivateProfileString(_T("Pipe"), _T("Name"), _T("Assist"), szValue, MAX_PATH, g_szConfigFile);
- _stprintf_s(g_cfgCtx.szPipeName, _T("\\\\.\\pipe\\%s"), szValue);
- GetPrivateProfileString(_T("Process"), _T("Name"), _T("Game.exe"), g_cfgCtx.szWndProcessName, MAX_PATH, g_szConfigFile);
- }
- void FreeLibraryAndExit()
- {
- if ( g_hDLLModule )
- FreeLibraryAndExitThread(g_hDLLModule, 0);
- }
- };
|