Переглянути джерело

准备开始做自动清台

zhangyang 5 роки тому
батько
коміт
7a868a99d1

+ 5 - 0
bin/Win32/Debug/zhipuzi_pay_plugin/skin/system_setting.xml

@@ -20,6 +20,7 @@
 				<Option name="system_setting_option_dayinji" text="打印机" font="0" group="system_setting_item" height="40" hotimage="tab_hot.bmp" selectedimage="setting_tab_bkg.png" selectedtextcolor="0xFFFFFFFF"/>
 				<Option name="system_setting_option_shoukuanshezhi" text="收款设置" font="0" group="system_setting_item" height="40" hotimage="tab_hot.bmp" selectedimage="setting_tab_bkg.png" selectedtextcolor="0xFFFFFFFF"/>
 				<Option name="system_setting_option_kuaijiejian" text="快捷键" font="0" group="system_setting_item" height="40" hotimage="tab_hot.bmp" selectedimage="setting_tab_bkg.png" selectedtextcolor="0XFFFFFFFF"/>
+				<Option name="system_setting_option_zidongqingtai" text="自动清台" font="0" group="system_setting_item" height="40" hotimage="tab_hot.bmp" selectedimage="setting_tab_bkg.png" selectedtextcolor="0XFFFFFFFF"/>
 				<Option name="system_setting_option_about" text="关于" font="0" group="system_setting_item" height="40" hotimage="tab_hot.bmp" selectedimage="setting_tab_bkg.png" selectedtextcolor="0XFFFFFFFF"/>
 				
 				<Button name="system_setting_logout" height="38" padding="20,50,20,0" text="退出账号" textcolor="#FFFFFFFF" normalimage="file='Btn_Red.png' corner='5,5,5,5'" hotimage="file='Btn_Red_Hover.png' corner='5,5,5,5'" pushedimage="file='Btn_Red_Click.png' corner='5,5,5,5'"/>
@@ -45,6 +46,10 @@
 				</HorizontalLayout>
 				
 				<HorizontalLayout vscrollbar="true">
+					<Include source="zidongqingtai_setting.xml" />
+				</HorizontalLayout>
+				
+				<HorizontalLayout vscrollbar="true">
 					<Include source="about.xml" />
 				</HorizontalLayout>
 			</TabLayout>

Різницю між файлами не показано, бо вона завелика
+ 22 - 0
bin/Win32/Debug/zhipuzi_pay_plugin/skin/zidongqingtai_setting.xml


+ 219 - 0
zhipuzi_pay_plugin/helper/CSystem.cpp

@@ -31,6 +31,143 @@ void CSystem::my_sleep(int second)
 #endif
 }
 
+std::wstring CSystem::getExePath()
+{
+	wchar_t exeFullPath[MAX_PATH]; // Full path
+	std::wstring strPath = L"";
+
+	GetModuleFileName(NULL, exeFullPath, MAX_PATH);
+	strPath = (wstring)exeFullPath;    // Get full path of the file
+
+	return strPath;
+}
+
+std::wstring CSystem::GetProgramDir()
+{
+	wchar_t exeFullPath[MAX_PATH]; // Full path
+	std::wstring strPath = L"";
+
+	GetModuleFileName(NULL, exeFullPath, MAX_PATH);
+	strPath = (wstring)exeFullPath;    // Get full path of the file
+
+	int pos = strPath.find_last_of('\\', strPath.length());
+	return strPath.substr(0, pos);  // Return the directory without the file name
+}
+
+// 程序开机自动启动
+void CSystem::autostart()
+{
+	HKEY hKey;
+	wstring strRegPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
+
+	//1、找到系统的启动项
+	if (RegOpenKeyEx(HKEY_CURRENT_USER, strRegPath.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)  ///打开启动项
+	{
+		//2、得到本程序自身的全路径
+		TCHAR strExeFullDir[MAX_PATH];
+		GetModuleFileName(NULL, strExeFullDir, MAX_PATH);
+
+		//3、添加一个子Key,并设置值,"GISRestart"是应用程序名字(不加后缀.exe)
+		RegSetValueEx(hKey, L"智铺子收银插件", 0, REG_SZ, (LPBYTE)strExeFullDir, (lstrlen(strExeFullDir) + 1) * sizeof(TCHAR));
+
+		//4、关闭注册表
+		RegCloseKey(hKey);
+	}
+
+	else
+	{
+		cout << "系统参数错误, 不能随系统启动";
+	}
+}
+
+// 取消开机自动启动
+void CSystem::cancelAutoStart()
+{
+	HKEY hKey;
+	wstring strRegPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
+
+	//1、找到系统的启动项
+	if (RegOpenKeyEx(HKEY_CURRENT_USER, strRegPath.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
+	{
+		//2、删除值
+		RegDeleteValue(hKey, L"智铺子收银插件");
+
+		//3、关闭注册表
+		RegCloseKey(hKey);
+	}
+}
+
+bool CSystem::IsAutoStart()
+{
+	HKEY hKey;
+	wstring strRegPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
+
+	//1、找到系统的启动项
+	if (RegOpenKeyEx(HKEY_CURRENT_USER, strRegPath.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
+	{
+		char dwValue[256];
+		DWORD dwSzType = REG_SZ;
+		DWORD dwSize = sizeof(dwValue);
+
+		if (::RegQueryValueEx(hKey, _T("智铺子收银插件"), 0, &dwSzType, (LPBYTE)&dwValue, &dwSize) != ERROR_SUCCESS)
+		{
+			return false;
+		}
+
+		//关闭注册表
+		RegCloseKey(hKey);
+
+		return true;
+	}
+
+	return false;
+}
+
+// 判断文件是否存在
+BOOL CSystem::IsFileExist(const wstring& csFile)
+{
+	DWORD dwAttrib = GetFileAttributes(csFile.c_str());
+	return INVALID_FILE_ATTRIBUTES != dwAttrib && 0 == (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+// 判断文件夹是否存在
+BOOL CSystem::IsDirExist(const wstring& csDir)
+{
+	DWORD dwAttrib = GetFileAttributes(csDir.c_str());
+	return INVALID_FILE_ATTRIBUTES != dwAttrib && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+// 判断文件或文件夹是否存在
+BOOL CSystem::IsPathExist(const wstring& csPath)
+{
+	DWORD dwAttrib = GetFileAttributes(csPath.c_str());
+	return INVALID_FILE_ATTRIBUTES != dwAttrib;
+}
+
+std::string CSystem::GetVersion()
+{
+	std::string r = "";
+
+	UINT sz = GetFileVersionInfoSize(getExePath().c_str(), 0);
+	if (sz != 0)
+	{
+		r.resize(sz, 0);
+		char* pBuf = NULL;
+		pBuf = new char[sz];
+		VS_FIXEDFILEINFO* pVsInfo;
+		if (GetFileVersionInfo(getExePath().c_str(), 0, sz, pBuf))
+		{
+			if (VerQueryValue(pBuf, L"\\", (void**)&pVsInfo, &sz))
+			{
+				sprintf(pBuf, "%d.%d.%d.%d", HIWORD(pVsInfo->dwFileVersionMS), LOWORD(pVsInfo->dwFileVersionMS), HIWORD(pVsInfo->dwFileVersionLS), LOWORD(pVsInfo->dwFileVersionLS));
+				r = pBuf;
+			}
+		}
+		delete pBuf;
+	}
+	return r;
+}
+
 BOOL CSystem::IsRunasAdmin()
 {
 	BOOL bElevated = FALSE;
@@ -55,3 +192,85 @@ BOOL CSystem::IsRunasAdmin()
 	CloseHandle(hToken);
 	return bElevated;
 }
+
+BOOL CSystem::processIdToName(LPTSTR lpszProcessName, DWORD PID)
+{
+	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+	PROCESSENTRY32 pe;
+	pe.dwSize = sizeof(PROCESSENTRY32);
+	if (!Process32First(hSnapshot, &pe))
+	{
+		return FALSE;
+	}
+	while (Process32Next(hSnapshot, &pe))
+	{
+		if (pe.th32ProcessID == PID)
+		{
+			wcscpy(lpszProcessName, pe.szExeFile);
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
+BOOL CSystem::IsAppRunning()
+{
+	PROCESSENTRY32 pe32;
+	//在使用这个结构前,先设置它的大小
+	pe32.dwSize = sizeof(pe32);
+	//给系统内所有的进程拍个快照
+	HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+
+	if (hProcessSnap == INVALID_HANDLE_VALUE)
+	{
+		return FALSE;
+	}
+
+	//遍历进程快照,轮流显示每个进程的信息
+	BOOL bMore = ::Process32First(hProcessSnap, &pe32);
+
+	int nCount = 0;
+
+	while (bMore)
+	{
+		//找到了进程
+		if (wstring(pe32.szExeFile) == L"zhipuzi_pay_plugin.exe")
+		{
+			nCount++;
+		}
+
+		bMore = ::Process32Next(hProcessSnap, &pe32);
+	}
+
+	if (nCount > 1)
+	{
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+void CSystem::RunHotKey(int mod, int key)
+{
+	BYTE mod_key;
+
+	if (mod == 1)
+	{
+		mod_key = VK_MENU;
+	}
+	else if (mod == 2)
+	{
+		mod_key = VK_CONTROL;
+	}
+	else if (mod == 3)
+	{
+		mod_key = VK_SHIFT;
+	}
+
+	keybd_event(mod_key, (BYTE)0, 0, 0);
+	keybd_event((BYTE)key, (BYTE)0, 0, 0);
+
+	keybd_event((BYTE)key, (BYTE)0, KEYEVENTF_KEYUP, 0);
+	keybd_event(mod_key, (BYTE)0, KEYEVENTF_KEYUP, 0);
+}

+ 16 - 182
zhipuzi_pay_plugin/helper/CSystem.h

@@ -14,200 +14,34 @@ public:
     //程序休眠X秒
     static void my_sleep(int second);
 
-    static std::wstring getExePath()
-    {
-        wchar_t exeFullPath[MAX_PATH]; // Full path
-        std::wstring strPath = L"";
+	static std::wstring getExePath();
 
-        GetModuleFileName(NULL, exeFullPath, MAX_PATH);
-        strPath = (wstring)exeFullPath;    // Get full path of the file
-
-        return strPath;
-    }
-
-    static std::wstring GetProgramDir()
-    {
-        wchar_t exeFullPath[MAX_PATH]; // Full path
-        std::wstring strPath = L"";
-
-        GetModuleFileName(NULL, exeFullPath, MAX_PATH);
-        strPath = (wstring)exeFullPath;    // Get full path of the file
-
-        int pos = strPath.find_last_of('\\', strPath.length());
-        return strPath.substr(0, pos);  // Return the directory without the file name
-    }
+	static std::wstring GetProgramDir();
 
     // 程序开机自动启动
-    static void autostart()
-    {
-        HKEY hKey;
-        wstring strRegPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
-
-        //1、找到系统的启动项
-        if(RegOpenKeyEx(HKEY_CURRENT_USER, strRegPath.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)  ///打开启动项
-        {
-            //2、得到本程序自身的全路径
-            TCHAR strExeFullDir[MAX_PATH];
-            GetModuleFileName(NULL, strExeFullDir, MAX_PATH);
-
-            //3、添加一个子Key,并设置值,"GISRestart"是应用程序名字(不加后缀.exe)
-            RegSetValueEx(hKey, L"智铺子收银插件", 0, REG_SZ, (LPBYTE)strExeFullDir, (lstrlen(strExeFullDir) + 1) * sizeof(TCHAR));
-
-            //4、关闭注册表
-            RegCloseKey(hKey);
-        }
-
-        else
-        {
-            cout << "系统参数错误, 不能随系统启动";
-        }
-    }
+	static void autostart();
 
     // 取消开机自动启动
-    static void cancelAutoStart()
-    {
-        HKEY hKey;
-        wstring strRegPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
-
-        //1、找到系统的启动项
-        if(RegOpenKeyEx(HKEY_CURRENT_USER, strRegPath.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
-        {
-            //2、删除值
-            RegDeleteValue(hKey, L"智铺子收银插件");
-
-            //3、关闭注册表
-            RegCloseKey(hKey);
-        }
-    }
-
-    static bool IsAutoStart()
-    {
-        HKEY hKey;
-        wstring strRegPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
-
-        //1、找到系统的启动项
-        if(RegOpenKeyEx(HKEY_CURRENT_USER, strRegPath.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
-        {
-            char dwValue[256];
-            DWORD dwSzType = REG_SZ;
-            DWORD dwSize = sizeof(dwValue);
-
-            if(::RegQueryValueEx(hKey, _T("智铺子收银插件"), 0, &dwSzType, (LPBYTE)&dwValue, &dwSize) != ERROR_SUCCESS)
-            {
-                return false;
-            }
-
-            //关闭注册表
-            RegCloseKey(hKey);
-
-            return true;
-        }
-
-        return false;
-    }
+	static void cancelAutoStart();
+
+	static bool IsAutoStart();
 
     // 判断文件是否存在
-    static BOOL IsFileExist(const wstring& csFile)
-    {
-        DWORD dwAttrib = GetFileAttributes(csFile.c_str());
-        return INVALID_FILE_ATTRIBUTES != dwAttrib && 0 == (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
-    }
+	static BOOL IsFileExist(const wstring& csFile);
 
     // 判断文件夹是否存在
-    static BOOL IsDirExist(const wstring& csDir)
-    {
-        DWORD dwAttrib = GetFileAttributes(csDir.c_str());
-        return INVALID_FILE_ATTRIBUTES != dwAttrib && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
-    }
+	static BOOL IsDirExist(const wstring& csDir);
 
     // 判断文件或文件夹是否存在
-    static BOOL IsPathExist(const wstring& csPath)
-    {
-        DWORD dwAttrib = GetFileAttributes(csPath.c_str());
-        return INVALID_FILE_ATTRIBUTES != dwAttrib;
-    }
-
-    static std::string GetVersion()
-    {
-        std::string r = "";
-
-        UINT sz = GetFileVersionInfoSize(getExePath().c_str(), 0);
-        if(sz != 0)
-        {
-            r.resize(sz, 0);
-            char* pBuf = NULL;
-            pBuf = new char[sz];
-            VS_FIXEDFILEINFO* pVsInfo;
-            if(GetFileVersionInfo(getExePath().c_str(), 0, sz, pBuf))
-            {
-                if(VerQueryValue(pBuf, L"\\", (void**)&pVsInfo, &sz))
-                {
-                    sprintf(pBuf, "%d.%d.%d.%d", HIWORD(pVsInfo->dwFileVersionMS), LOWORD(pVsInfo->dwFileVersionMS), HIWORD(pVsInfo->dwFileVersionLS), LOWORD(pVsInfo->dwFileVersionLS));
-                    r = pBuf;
-                }
-            }
-            delete pBuf;
-        }
-        return r;
-    }
+	static BOOL IsPathExist(const wstring& csPath);
+
+	static std::string GetVersion();
 
     static BOOL IsRunasAdmin();
 
-    static BOOL processIdToName(LPTSTR lpszProcessName, DWORD PID)
-    {
-        HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-        PROCESSENTRY32 pe;
-        pe.dwSize = sizeof(PROCESSENTRY32);
-        if(!Process32First(hSnapshot, &pe))
-        {
-            return FALSE;
-        }
-        while(Process32Next(hSnapshot, &pe))
-        {
-            if(pe.th32ProcessID == PID)
-            {
-                wcscpy(lpszProcessName, pe.szExeFile);
-                return TRUE;
-            }
-        }
-
-        return FALSE;
-    }
-
-	static BOOL IsAppRunning()
-	{
-		PROCESSENTRY32 pe32;
-		//在使用这个结构前,先设置它的大小
-		pe32.dwSize = sizeof(pe32);
-		//给系统内所有的进程拍个快照
-		HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-
-		if (hProcessSnap == INVALID_HANDLE_VALUE)
-		{
-			return FALSE;
-		}
-
-		//遍历进程快照,轮流显示每个进程的信息
-		BOOL bMore = ::Process32First(hProcessSnap, &pe32);
-
-		int nCount = 0;
-
-		while (bMore)
-		{
-			//找到了进程
-			if (wstring(pe32.szExeFile) == L"zhipuzi_pay_plugin.exe")
-			{
-				nCount++;
-			}
-
-			bMore = ::Process32Next(hProcessSnap, &pe32);
-		}
-
-		if (nCount > 1)
-		{
-			return TRUE;
-		}
-
-		return FALSE;
-	}
+	static BOOL processIdToName(LPTSTR lpszProcessName, DWORD PID);
+
+	static BOOL IsAppRunning();
+
+	static void RunHotKey(int mod, int key);
 };

+ 14 - 4
zhipuzi_pay_plugin/wnd/CSystemSettingWnd.cpp

@@ -630,7 +630,7 @@ LRESULT CSystemSettingWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
 LRESULT CSystemSettingWnd::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
     //先按控制键
-    if(m_is_kuaijiepan_page)
+    if(m_is_kuaijiejian_page)
     {
         if(uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)
         {
@@ -1231,16 +1231,26 @@ void CSystemSettingWnd::HandleSelectChangeMsg(TNotifyUI& msg)
             pControl->SelectItem(3);
         }
 
-        m_is_kuaijiepan_page = true;
+        m_is_kuaijiejian_page = true;
     }
 
+	else if (name == _T("system_setting_option_zidongqingtai"))
+	{
+		CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("switch")));
+
+		if (pControl && pControl->GetCurSel() != 4)
+		{
+			pControl->SelectItem(4);
+		}
+	}
+
     else if(name == _T("system_setting_option_about"))
     {
         CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("switch")));
 
-        if(pControl && pControl->GetCurSel() != 4)
+        if(pControl && pControl->GetCurSel() != 5)
         {
-            pControl->SelectItem(4);
+            pControl->SelectItem(5);
         }
     }
 

+ 1 - 1
zhipuzi_pay_plugin/wnd/CSystemSettingWnd.h

@@ -101,7 +101,7 @@ private:
 	UINT m_vk = 0;
 	bool m_isSet = false;
 
-	bool m_is_kuaijiepan_page = false;
+	bool m_is_kuaijiejian_page = false;
 	int m_kuaijiejian_type = 0;
 };