98 lines
2.2 KiB
C++
98 lines
2.2 KiB
C++
#include "HBDSystem.h"
|
|
|
|
UserType g_Admin;
|
|
string g_AppPath;
|
|
string g_AppDisk;
|
|
Logger* g_log;
|
|
LanguageManager* g_LngManager;
|
|
Toast* g_Toast;
|
|
bool g_isDebug;
|
|
uint32_t g_ScanSerial;
|
|
string g_gno;
|
|
SystemInfo* g_SystemInfo;
|
|
|
|
|
|
HBDSystem::HBDSystem()
|
|
: m_dataHandle(new DataHandle()){
|
|
|
|
}
|
|
|
|
|
|
HBDSystem::~HBDSystem() {
|
|
DELP(g_log);
|
|
DELP(g_SystemInfo);
|
|
DELP(g_Toast);
|
|
DELP(g_LngManager);
|
|
|
|
DELP(m_dataHandle);
|
|
}
|
|
|
|
void HBDSystem::Init() {
|
|
char szFilePath[MAX_PATH + 1] = { 0 };
|
|
GetModuleFileName(NULL, szFilePath, MAX_PATH);
|
|
(strrchr(szFilePath, '\\'))[1] = 0;
|
|
g_AppPath = szFilePath;
|
|
g_AppDisk = g_AppPath.substr(0, 2);
|
|
|
|
g_Admin = ADMIN;
|
|
|
|
g_isDebug = false;
|
|
g_log = new Logger();
|
|
g_log->m_LogDao->Init();
|
|
g_SystemInfo = new SystemInfo();
|
|
g_Toast = new Toast();
|
|
|
|
m_dataHandle->Init();
|
|
|
|
GetVersion();
|
|
}
|
|
|
|
|
|
void HBDSystem::GetVersion()
|
|
{
|
|
char cPath[MAX_PATH];
|
|
DWORD dwHandle, InfoSize;
|
|
string strVersion;
|
|
::GetModuleFileName(NULL, cPath, sizeof(cPath));
|
|
InfoSize = GetFileVersionInfoSize(cPath, &dwHandle);
|
|
printf("version:%d\n", GetLastError());
|
|
if (InfoSize == 0L) return;
|
|
unsigned char* InfoBuf = new unsigned char[InfoSize];
|
|
GetFileVersionInfo(cPath, 0, InfoSize, InfoBuf); //获得生成文件使用的代码页及文件版本
|
|
unsigned int cbTranslate = 0;
|
|
struct LANGANDCODEPAGE {
|
|
WORD wLanguage;
|
|
WORD wCodePage;
|
|
} *lpTranslate;
|
|
VerQueryValue(InfoBuf, TEXT("\\VarFileInfo\\Translation"), (LPVOID*)&lpTranslate, &cbTranslate);
|
|
// Read the file description for each language and code page.
|
|
for (unsigned int i = 0; i < (cbTranslate / sizeof(struct LANGANDCODEPAGE)); i++)
|
|
{
|
|
char SubBlock[200];
|
|
wsprintf(SubBlock,
|
|
TEXT("\\StringFileInfo\\%04x%04x\\ProductVersion"),
|
|
lpTranslate[i].wLanguage,
|
|
lpTranslate[i].wCodePage);
|
|
void* lpBuffer = NULL;
|
|
unsigned int dwBytes = 0;
|
|
VerQueryValue(InfoBuf,
|
|
SubBlock,
|
|
&lpBuffer,
|
|
&dwBytes);
|
|
string strTemp = (char*)lpBuffer;
|
|
strVersion += strTemp;
|
|
|
|
}
|
|
delete[] InfoBuf;
|
|
g_SystemInfo->m_ProductVersion = strVersion;
|
|
}
|
|
|
|
|
|
void HBDSystem::Usage() {
|
|
printf("print service usage:\n");
|
|
printf(" r(run):start run...\n");
|
|
printf(" s(stop):stop run...\n");
|
|
printf(" e(exit):exit program...\n");
|
|
printf(" h(help):print this information...\n");
|
|
|
|
} |