瀏覽代碼

一些改动

zhangyang 6 年之前
父節點
當前提交
84eef5342a

二進制
bin/Win32/Debug/zhipuzi_pos_windows/zhipuzi_pos_windows.exe


+ 37 - 5
zhipuzi_pos_windows/tool/CPosPrinter.cpp

@@ -300,13 +300,27 @@ int CPosPrinter::GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath)
 
                 if(bResult)
                 {
-                    // 复制设备路径到输出缓冲区
-                    ::_tcscpy_s(pszDevicePath[nCount], 256, pDetail->DevicePath);
+					wstring DevicePath = pDetail->DevicePath;
 
-                    // 调整计数值
-                    nCount++;
+					wstring vid = DevicePath.substr(DevicePath.find(_T("vid_"), 0) + 4, 4);
+					wstring pid = DevicePath.substr(DevicePath.find(_T("pid_"), 0) + 4, 4);
 
-                    //LOG_INFO("Cnt = " << nCount << ",pDetail->DevicePath =" << pDetail->DevicePath);
+					LOG_INFO("Vid:" << vid.c_str() << ", Pid:" << pid.c_str());
+
+					if (GetPrinterType(vid, pid) == 2)
+					{
+						//标签打印机,暂时不处理打印
+						LOG_INFO("标签打印机,暂时不打印!");
+						continue;
+					}
+
+					// 复制设备路径到输出缓冲区
+					::_tcscpy_s(pszDevicePath[nCount], 256, pDetail->DevicePath);
+
+					// 调整计数值
+					nCount++;
+
+					LOG_INFO("Cnt = " << nCount << ",pDetail->DevicePath =" << pDetail->DevicePath);
                 }
             }
         }
@@ -324,6 +338,24 @@ int CPosPrinter::GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath)
     return nCount;
 }
 
+/*
+ *返回打印机的类型, 1:普通热敏打印机 2:标签打印机
+ **/
+int CPosPrinter::GetPrinterType(wstring vid, wstring pid)
+{
+	if (vid == L"6868" && pid == L"0500")
+	{
+		//佳博标签打印机
+		return 2;
+	}
+	else if (vid == L"0fe6" && pid == L"811e")
+	{
+		return 2;
+	}
+
+	return 1;
+}
+
 void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
 {
     //设置模式,后面输出数据不会错

+ 1 - 0
zhipuzi_pos_windows/tool/CPosPrinter.h

@@ -33,6 +33,7 @@ public:
 private:
     bool InitShouyin();
     int GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath);
+	int GetPrinterType(wstring vid, wstring pid);
 
     int WriteData(string meg);
     int WriteBuf(const char* buf, int len);