From 9347a4b752e30adc849d2fd49d1a11e7ad718582 Mon Sep 17 00:00:00 2001
From: gb <741021719@qq.com>
Date: Wed, 22 Nov 2023 12:10:52 +0800
Subject: [PATCH] re-construct files arch
---
device/scannerqd.vcxproj | 1 +
device/scannerqd.vcxproj.filters | 7 +++++-
device/win_usb/win_usb.cpp | 41 +++++++++++++-------------------
device/win_usb/win_usb.h | 1 +
twain/dllmain.cpp | 8 +++++++
twain/twain.vcxproj | 8 +++----
twain/twain.vcxproj.filters | 24 +++++++++----------
7 files changed, 48 insertions(+), 42 deletions(-)
diff --git a/device/scannerqd.vcxproj b/device/scannerqd.vcxproj
index 60db23e..763b6fa 100644
--- a/device/scannerqd.vcxproj
+++ b/device/scannerqd.vcxproj
@@ -361,6 +361,7 @@ move /Y "$(TargetDir)$(ProjectName).exp" "$(ProjectDir)..\..\sdk\lib\win\$(Platf
+
diff --git a/device/scannerqd.vcxproj.filters b/device/scannerqd.vcxproj.filters
index 08765a3..0630306 100644
--- a/device/scannerqd.vcxproj.filters
+++ b/device/scannerqd.vcxproj.filters
@@ -474,7 +474,12 @@
-
+
+ dev
+
+
+ 源文件
+
diff --git a/device/win_usb/win_usb.cpp b/device/win_usb/win_usb.cpp
index 5aa8d4b..c526da6 100644
--- a/device/win_usb/win_usb.cpp
+++ b/device/win_usb/win_usb.cpp
@@ -28,6 +28,7 @@
#endif
#include "usbview/enum.h"
#include "../../../sdk/include/huagao/brand.h"
+#include
#pragma warning(disable: 4996)
#define MSG_DEVICE_PNP WM_USER + 1 // wParam: (bool)arrive; lParam: usb_device*
@@ -1184,14 +1185,7 @@ void usb_monitor::thread_run_device_event_wnd(void)
SetTimer(wnd_monitor_, usb_monitor::find_usb_timer_, 1000, NULL);
}
ret = GetLastError();
- while (run_ && (ret = GetMessageW(&msg, wnd_monitor_, 0, 0)))
- {
- if (ret == -1)
- break;
-
- TranslateMessage(&msg);
- DispatchMessageW(&msg);
- }
+ while (run_ && utils::run_get_message(wnd_monitor_, 0, 0));
UnregisterDeviceNotification(notify);
}
@@ -1200,32 +1194,29 @@ void usb_monitor::thread_run_device_event_wnd(void)
}
void usb_monitor::thread_handle_device_change_msg(void)
{
- MSG msg = { 0 };
- BOOL ret = FALSE;
-
- handle_msg_id_ = GetCurrentThreadId();
- while ((ret = GetMessageW(&msg, NULL, 0, 0)))
+ auto pnp = [&](MSG* msg, bool* handled) -> bool
{
- if (ret == -1)
- break;
-
- if (msg.message == MSG_DEVICE_PNP)
+ if (msg->message == MSG_DEVICE_PNP)
{
char buf[40] = { 0 };
- usb_device* dev = (usb_device*)msg.lParam;
+ usb_device* dev = (usb_device*)msg->lParam;
//if(msg.wParam)
// dev->init();
- notify_usb_event(dev, msg.wParam);
+ notify_usb_event(dev, msg->wParam);
// dev->release ?
dev->release();
+ if (handled)
+ *handled = true;
}
- else
- {
- TranslateMessage(&msg);
- DispatchMessageW(&msg);
- }
- }
+ else if(handled)
+ *handled = false;
+
+ return true;
+ };
+
+ handle_msg_id_ = GetCurrentThreadId();
+ while (utils::run_get_message(NULL, 0, 0, pnp));
}
void usb_monitor::quit(void)
{
diff --git a/device/win_usb/win_usb.h b/device/win_usb/win_usb.h
index 558d11f..b4e48c5 100644
--- a/device/win_usb/win_usb.h
+++ b/device/win_usb/win_usb.h
@@ -10,6 +10,7 @@
#include
#include
#include
+#include
#include
#include "libusb-1.0/libusb.h"
diff --git a/twain/dllmain.cpp b/twain/dllmain.cpp
index 2ca3ead..5319578 100644
--- a/twain/dllmain.cpp
+++ b/twain/dllmain.cpp
@@ -1,4 +1,5 @@
#include "pch.h"
+#include
HMODULE me_ = NULL;
@@ -9,12 +10,19 @@ BOOL APIENTRY DllMain(HMODULE hModule , DWORD ul_reason_for_call, LPVOID /* lpR
case DLL_PROCESS_ATTACH:
//sane_invoker::initialize(hModule);
me_ = hModule;
+#ifdef _DEBUG
+ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+ _CrtSetBreakAlloc(-1);
+#endif
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
//sane_invoker::uninitialize();
+#ifdef _DEBUG
+ OutputDebugStringA("\r\nDS module unloading ...\r\n");
+#endif
break;
}
return TRUE;
diff --git a/twain/twain.vcxproj b/twain/twain.vcxproj
index c24f1fb..69cd350 100644
--- a/twain/twain.vcxproj
+++ b/twain/twain.vcxproj
@@ -215,8 +215,8 @@ move /Y "$(TargetPath)" "$(TargetDir)$(TargetName)"
-
-
+
+
@@ -276,13 +276,13 @@ move /Y "$(TargetPath)" "$(TargetDir)$(TargetName)"
-
+
NotUsing
NotUsing
NotUsing
NotUsing
-
+
NotUsing
NotUsing
NotUsing
diff --git a/twain/twain.vcxproj.filters b/twain/twain.vcxproj.filters
index 522220f..cb0d7dc 100644
--- a/twain/twain.vcxproj.filters
+++ b/twain/twain.vcxproj.filters
@@ -28,12 +28,6 @@
Sources
-
- imports
-
-
- imports
-
imports
@@ -52,6 +46,12 @@
imports
+
+ imports
+
+
+ imports
+
@@ -189,12 +189,6 @@
Headers\twain\twpp
-
- imports
-
-
- imports
-
imports
@@ -231,6 +225,12 @@
Headers
+
+ imports
+
+
+ imports
+