diff --git a/device/win_usb/usbview/enum.c b/device/win_usb/usbview/enum.c
index 6ffc9a3..3486128 100644
--- a/device/win_usb/usbview/enum.c
+++ b/device/win_usb/usbview/enum.c
@@ -72,6 +72,7 @@ Revision History:
#define NUM_STRING_DESC_TO_GET 32
+
//*****************************************************************************
// L O C A L F U N C T I O N P R O T O T Y P E S
//*****************************************************************************
@@ -455,7 +456,7 @@ EnumerateHostController (
size_t cbDriverName = 0;
HRESULT hr = S_OK;
- hr = StringCbLength(driverKeyName, MAX_DRIVER_KEY_NAME, &cbDriverName);
+ hr = StringCbLengthA(driverKeyName, MAX_DRIVER_KEY_NAME, &cbDriverName);
if (SUCCEEDED(hr))
{
DevProps = DriverNameToDeviceProperties(driverKeyName, cbDriverName);
@@ -577,7 +578,7 @@ EnumerateHostController (
size_t cbHubName = 0;
HRESULT hr = S_OK;
- hr = StringCbLength(rootHubName, MAX_DRIVER_KEY_NAME, &cbHubName);
+ hr = StringCbLengthA(rootHubName, MAX_DRIVER_KEY_NAME, &cbHubName);
if (SUCCEEDED(hr))
{
EnumerateHub(hHCItem,
@@ -723,7 +724,7 @@ EnumerateHub (
// Allocate a temp buffer for the full hub device name.
//
- hr = StringCbLength("\\\\.\\", MAX_DEVICE_PROP, &cchHeader);
+ hr = StringCbLengthA("\\\\.\\", MAX_DEVICE_PROP, &cchHeader);
if (FAILED(hr))
{
goto EnumerateHubError;
@@ -738,12 +739,12 @@ EnumerateHub (
// Create the full hub device name
//
- hr = StringCchCopyN(deviceName, cchFullHubName, "\\\\.\\", cchHeader);
+ hr = StringCchCopyNA(deviceName, cchFullHubName, "\\\\.\\", cchHeader);
if (FAILED(hr))
{
goto EnumerateHubError;
}
- hr = StringCchCatN(deviceName, cchFullHubName, HubName, cbHubName);
+ hr = StringCchCatNA(deviceName, cchFullHubName, HubName, cbHubName);
if (FAILED(hr))
{
goto EnumerateHubError;
@@ -751,7 +752,7 @@ EnumerateHub (
// Try to hub the open device
//
- hHubDevice = CreateFile(deviceName,
+ hHubDevice = CreateFileA(deviceName,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
@@ -849,11 +850,11 @@ EnumerateHub (
dwSizeOfLeafName = sizeof(leafName);
if (ConnectionInfo)
{
- StringCchPrintf(leafName, dwSizeOfLeafName, "[Port%d] ", ConnectionInfo->ConnectionIndex);
- StringCchCat(leafName,
+ StringCchPrintfA(leafName, dwSizeOfLeafName, "[Port%d] ", ConnectionInfo->ConnectionIndex);
+ StringCchCatA(leafName,
dwSizeOfLeafName,
ConnectionStatuses[ConnectionInfo->ConnectionStatus]);
- StringCchCatN(leafName,
+ StringCchCatNA(leafName,
dwSizeOfLeafName,
" : ",
sizeof(" : "));
@@ -862,10 +863,10 @@ EnumerateHub (
if (DevProps)
{
size_t cbDeviceDesc = 0;
- hr = StringCbLength(DevProps->DeviceDesc, MAX_DRIVER_KEY_NAME, &cbDeviceDesc);
+ hr = StringCbLengthA(DevProps->DeviceDesc, MAX_DRIVER_KEY_NAME, &cbDeviceDesc);
if(SUCCEEDED(hr))
{
- StringCchCatN(leafName,
+ StringCchCatNA(leafName,
dwSizeOfLeafName,
DevProps->DeviceDesc,
cbDeviceDesc);
@@ -876,7 +877,7 @@ EnumerateHub (
if(ConnectionInfo != NULL)
{
// External hub
- StringCchCatN(leafName,
+ StringCchCatNA(leafName,
dwSizeOfLeafName,
HubName,
cbHubName);
@@ -884,7 +885,7 @@ EnumerateHub (
else
{
// Root hub
- StringCchCatN(leafName,
+ StringCchCatNA(leafName,
dwSizeOfLeafName,
"RootHub",
sizeof("RootHub"));
@@ -1262,7 +1263,7 @@ EnumerateHubPorts (
{
size_t cbDriverName = 0;
- hr = StringCbLength(driverKeyName, MAX_DRIVER_KEY_NAME, &cbDriverName);
+ hr = StringCbLengthA(driverKeyName, MAX_DRIVER_KEY_NAME, &cbDriverName);
if (SUCCEEDED(hr))
{
DevProps = DriverNameToDeviceProperties(driverKeyName, cbDriverName);
@@ -1325,7 +1326,7 @@ EnumerateHubPorts (
extHubName = GetExternalHubName(hHubDevice, index);
if (extHubName != NULL)
{
- hr = StringCbLength(extHubName, MAX_DRIVER_KEY_NAME, &cbHubName);
+ hr = StringCbLengthA(extHubName, MAX_DRIVER_KEY_NAME, &cbHubName);
if (SUCCEEDED(hr))
{
EnumerateHub(hTreeParent, //hPortItem,
@@ -1383,10 +1384,10 @@ EnumerateHubPorts (
info->UsbDeviceProperties = DevProps;
info->DeviceInfoNode = pNode;
- StringCchPrintf(leafName, sizeof(leafName), "[Port%d] ", index);
+ StringCchPrintfA(leafName, sizeof(leafName), "[Port%d] ", index);
// Add error description if ConnectionStatus is other than NoDeviceConnected / DeviceConnected
- StringCchCat(leafName,
+ StringCchCatA(leafName,
sizeof(leafName),
ConnectionStatuses[connectionInfoEx->ConnectionStatus]);
@@ -1394,17 +1395,17 @@ EnumerateHubPorts (
{
size_t cchDeviceDesc = 0;
- hr = StringCbLength(DevProps->DeviceDesc, MAX_DEVICE_PROP, &cchDeviceDesc);
+ hr = StringCbLengthA(DevProps->DeviceDesc, MAX_DEVICE_PROP, &cchDeviceDesc);
if (FAILED(hr))
{
OOPS();
}
dwSizeOfLeafName = sizeof(leafName);
- StringCchCatN(leafName,
+ StringCchCatNA(leafName,
dwSizeOfLeafName - 1,
" : ",
sizeof(" : "));
- StringCchCatN(leafName,
+ StringCchCatNA(leafName,
dwSizeOfLeafName - 1,
DevProps->DeviceDesc,
cchDeviceDesc );
@@ -3593,7 +3594,7 @@ enumerate_hub_port(HANDLE hHubDevice, ULONG port_index)
{
size_t cbDriverName = 0;
- hr = StringCbLength(driverKeyName, MAX_DRIVER_KEY_NAME, &cbDriverName);
+ hr = StringCbLengthA(driverKeyName, MAX_DRIVER_KEY_NAME, &cbDriverName);
if (SUCCEEDED(hr))
{
DevProps = DriverNameToDeviceProperties(driverKeyName, cbDriverName);
@@ -3715,10 +3716,10 @@ enumerate_hub_port(HANDLE hHubDevice, ULONG port_index)
info->UsbDeviceProperties = DevProps;
info->DeviceInfoNode = pNode;
- StringCchPrintf(leafName, sizeof(leafName), "[Port%d] ", index);
+ StringCchPrintfA(leafName, sizeof(leafName), "[Port%d] ", index);
// Add error description if ConnectionStatus is other than NoDeviceConnected / DeviceConnected
- StringCchCat(leafName,
+ StringCchCatA(leafName,
sizeof(leafName),
ConnectionStatuses[connectionInfoEx->ConnectionStatus]);
@@ -3726,17 +3727,17 @@ enumerate_hub_port(HANDLE hHubDevice, ULONG port_index)
{
size_t cchDeviceDesc = 0;
- hr = StringCbLength(DevProps->DeviceDesc, MAX_DEVICE_PROP, &cchDeviceDesc);
+ hr = StringCbLengthA(DevProps->DeviceDesc, MAX_DEVICE_PROP, &cchDeviceDesc);
if (FAILED(hr))
{
OOPS();
}
dwSizeOfLeafName = sizeof(leafName);
- StringCchCatN(leafName,
+ StringCchCatNA(leafName,
dwSizeOfLeafName - 1,
" : ",
sizeof(" : "));
- StringCchCatN(leafName,
+ StringCchCatNA(leafName,
dwSizeOfLeafName - 1,
DevProps->DeviceDesc,
cchDeviceDesc);
diff --git a/device/win_usb/win_usb.cpp b/device/win_usb/win_usb.cpp
index 3eea0d2..f8c0513 100644
--- a/device/win_usb/win_usb.cpp
+++ b/device/win_usb/win_usb.cpp
@@ -881,7 +881,7 @@ usb_monitor::usb_monitor() : wnd_monitor_(NULL), handle_msg_id_(0), run_(true)
thread_handle_device_change_msg();
};
void(usb_monitor:: * pnp)(void) = &usb_monitor::thread_handle_device_change_msg;
- handle_msg_.start(tf, "usb_monitor::thread_handle_device_change_msg", *(void**)&pnp);
+ handle_msg_.start(tf, 0, "usb_monitor::thread_handle_device_change_msg", *(void**)&pnp);
#else
handle_msg_.reset(new std::thread(&usb_monitor::thread_handle_device_change_msg, this));
#endif
diff --git a/sln/usb_tools/DlgScanner.cpp b/sln/usb_tools/DlgScanner.cpp
index fd49afc..ba7bb10 100644
--- a/sln/usb_tools/DlgScanner.cpp
+++ b/sln/usb_tools/DlgScanner.cpp
@@ -977,6 +977,7 @@ void CDlgScanner::thread_fetch_image(void)
while (1)
{
SANE_Parameters sp;
+ bool bmp = false;
memset(&sp, 0, sizeof(sp));
scanner_->get_image_info(&sp);
@@ -993,9 +994,17 @@ void CDlgScanner::thread_fetch_image(void)
wchar_t name[40] = { 0 };
FILE *dst = nullptr;
- swprintf_s(name, _countof(name) - 1, L"\\scanner_%04u.bmp", img_cnt_ + 1);
+ if(sp.format == (SANE_Frame)SANE_FRAME_PNG)
+ swprintf_s(name, _countof(name) - 1, L"\\scanner_%04u.png", img_cnt_ + 1);
+ else if (sp.format == (SANE_Frame)SANE_FRAME_JPEG)
+ swprintf_s(name, _countof(name) - 1, L"\\scanner_%04u.jpg", img_cnt_ + 1);
+ else
+ {
+ swprintf_s(name, _countof(name) - 1, L"\\scanner_%04u.bmp", img_cnt_ + 1);
+ bmp = true;
+ }
dst = _wfopen((save_root_ + name).c_str(), L"wb");
- if (dst)
+ if (dst && bmp)
{
fwrite(bfh.c_str(), 1, bfh.length(), dst);
fwrite(bih.c_str(), 1, bih.length(), dst);
@@ -1004,7 +1013,7 @@ void CDlgScanner::thread_fetch_image(void)
{
if (dst)
{
- if (line_l == sp.bytes_per_line)
+ if (!bmp || line_l == sp.bytes_per_line)
{
fwrite(buf, 1, rd, dst);
}
@@ -1511,7 +1520,7 @@ void CDlgScanner::OnBnClickedButtonScan()
thread_fetch_image();
};
- threads_.start(rcv, "thread_fetch_image");
+ threads_.start(rcv, 0, "thread_fetch_image");
utils::to_log(LOG_LEVEL_DEBUG, "Device configuration: %s\n", cfg.c_str());
::SetDlgItemTextW(m_hWnd, IDC_BUTTON_SCAN, L"Stop");
OnDeviceStatus(0, (LPARAM)SCANNER_ERR_DEVICE_BUSY);
@@ -1548,7 +1557,7 @@ void CDlgScanner::OnBnClickedButtonSendFile()
{
thread_auto_tx_file();
};
- auto_tx_file_ = threads_.start(txf, "CDlgScanner::thread_auto_tx_file", NULL);
+ auto_tx_file_ = threads_.start(txf, 0, "CDlgScanner::thread_auto_tx_file", NULL);
//char l[256] = { 0 },
// r[256] = { 0 };
//int err = 0;
@@ -1570,7 +1579,7 @@ void CDlgScanner::OnBnClickedButtonRecvFile()
{
thread_auto_tx_file();
};
- auto_tx_file_ = threads_.start(txf, "CDlgScanner::thread_auto_tx_file", NULL);
+ auto_tx_file_ = threads_.start(txf, 0, "CDlgScanner::thread_auto_tx_file", NULL);
//char l[256] = { 0 },
// r[256] = { 0 };
//int err = 0;
@@ -1657,7 +1666,7 @@ void CDlgScanner::OnBnClickedCheckRepeat()
thread_auto_tx_file();
};
auto_tx_ = FILE_TX_RECEIVE | FILE_TX_SEND;
- auto_tx_file_ = threads_.start(txf, "CDlgScanner::thread_auto_tx_file", NULL);
+ auto_tx_file_ = threads_.start(txf, 0, "CDlgScanner::thread_auto_tx_file", NULL);
}
else
{
diff --git a/sln/usb_tools/usb_tools.vcxproj b/sln/usb_tools/usb_tools.vcxproj
index f2a2ade..e39197d 100644
--- a/sln/usb_tools/usb_tools.vcxproj
+++ b/sln/usb_tools/usb_tools.vcxproj
@@ -82,29 +82,31 @@
true
$(ProjectDir)..\..\..\code_device\sdk
- $(SolutionDir)sdk\lib\$(Configuration);$(LibraryPath)
+ $(SolutionDir)sdk\lib\$(Configuration);$(LibraryPath);$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)
false
$(ProjectDir)..\..\..\code_device\sdk;$(ProjectDir)..\sdk\include;$(ProjectDir)..\..\..\sdk\include;$(ProjectDir)..\..\device;$(ProjectDir)..\..\..\code_device\hgdriver\3rdparty\opencv\include;$(ProjectDir)..\..\..\code_device\hgsane\sane_opt;$(IncludePath)
- $(ProjectDir)..\sdk\lib\$(Configuration);$(LibraryPath)
+ $(ProjectDir)..\sdk\lib\$(Configuration);$(LibraryPath);$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)
false
$(ProjectDir)..\..\..\code_device\sdk
- $(SolutionDir)sdk\lib\$(Configuration);$(LibraryPath)
+ $(SolutionDir)sdk\lib\$(Configuration);$(LibraryPath);$(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)
Use
Level3
true
- WIN32;_WINDOWS;HGSCANNER_EXPORT;PRODUCT_VENDOR="HuaGo";TEST_HGSCANNER;HGSCANNER_EXPORT;PRODUCT_VENDOR="HuaGo";_DEBUG;%(PreprocessorDefinitions);CUSTOM_USBVIEW
+ WIN32;_WINDOWS;HGSCANNER_EXPORT;PRODUCT_VENDOR="HuaGo";TEST_HGSCANNER;_DEBUG;%(PreprocessorDefinitions);CUSTOM_USBVIEW
pch.h
4996
+ MultiThreadedDebugDLL
Windows
+ %(AdditionalDependencies)
false
@@ -128,6 +130,7 @@
Windows
+ opencv_core3416.lib;opencv_imgproc3416.lib;opencv_imgcodecs3416.lib;IlmImf.lib;ittnotify.lib;libjasper.lib;libjpeg-turbo.lib;libpng.lib;libtiff.lib;libwebp.lib;zlib.lib;user32.lib;cryptlib.lib;%(AdditionalDependencies)
false
@@ -156,6 +159,7 @@
Windows
true
true
+ opencv_core3416.lib;opencv_imgproc3416.lib;opencv_imgcodecs3416.lib;IlmImf.lib;ittnotify.lib;libjasper.lib;libjpeg-turbo.lib;libpng.lib;libtiff.lib;libwebp.lib;zlib.lib;user32.lib;cryptlib.lib;%(AdditionalDependencies)
false
@@ -183,6 +187,7 @@
Windows
true
true
+ opencv_core3416.lib;opencv_imgproc3416.lib;opencv_imgcodecs3416.lib;IlmImf.lib;ittnotify.lib;libjasper.lib;libjpeg-turbo.lib;libpng.lib;libtiff.lib;libwebp.lib;zlib.lib;user32.lib;cryptlib.lib;%(AdditionalDependencies)
false
@@ -216,6 +221,13 @@
+
+
+
+
+
+
+
diff --git a/sln/usb_tools/usb_tools.vcxproj.filters b/sln/usb_tools/usb_tools.vcxproj.filters
index d41a6a1..269ffc0 100644
--- a/sln/usb_tools/usb_tools.vcxproj.filters
+++ b/sln/usb_tools/usb_tools.vcxproj.filters
@@ -138,6 +138,27 @@
Imports\sdk
+
+ Imports\sdk
+
+
+ Imports\sdk
+
+
+ Imports\sdk
+
+
+ Imports\sdk
+
+
+ Imports\sdk
+
+
+ Imports\sdk
+
+
+ Imports\sdk
+