diff --git a/device/scanner.rc b/device/scanner.rc index 3b0b78e..77ab1ce 100644 --- a/device/scanner.rc +++ b/device/scanner.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,16,10100,22218 - PRODUCTVERSION 4,16,10100,22218 + FILEVERSION 4,17,10100,22221 + PRODUCTVERSION 4,17,10100,22221 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "宁波华高信息科技有限公司" VALUE "FileDescription", "华高扫描仪应用程序" - VALUE "FileVersion", "4.16.10100.22218" + VALUE "FileVersion", "4.17.10100.22221" VALUE "InternalName", "scanner.dll" VALUE "LegalCopyright", "Copyright (C) 10100" VALUE "OriginalFilename", "scanner.dll" VALUE "ProductName", "HUAGOScan" - VALUE "ProductVersion", "4.16.10100.22218" + VALUE "ProductVersion", "4.17.10100.22221" END END BLOCK "VarFileInfo" diff --git a/device/win_usb/win_usb.cpp b/device/win_usb/win_usb.cpp index 125cdea..8c1dda2 100644 --- a/device/win_usb/win_usb.cpp +++ b/device/win_usb/win_usb.cpp @@ -127,6 +127,17 @@ ovl_cls* ovl_mgr::get_ovl(void) usb_device::usb_device(const char* name) : ref_(1), name_(name ? name : ""), is_ok_(false) , dev_desc_(NULL), handle_(NULL), online_(true), timout_ms_(1000) { + size_t pos = name_.find("#{"); + if (pos != std::string::npos) + { + HANDLE h = open_usb((name_.substr(0, pos) + "#{" + HG_SCANNER_GUID + "}").c_str()); + if (h != INVALID_HANDLE_NAME) + { + CloseHandle(h); + name_ = name_.substr(0, pos) + "#{" + HG_SCANNER_GUID + "}"; + } + } + bzero(&guid_, sizeof(guid_)); id_ = usb_device::vid_pid_from_name(name); } @@ -149,6 +160,10 @@ HANDLE usb_device::find_pipe(UCHAR addr, int type, int* index) return NULL; } +HANDLE usb_device::open_usb(const char* usb_name) +{ + return CreateFileA(usb_name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); +} int usb_device::set_timeout(HANDLE h) { USBSCAN_TIMEOUT uto = { 0 }; @@ -634,7 +649,8 @@ int usb_device::open(libusb_device_handle** dev_handle) if (!dev_desc_) init(); - HANDLE h = CreateFileA(name_.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + + HANDLE h = open_usb(name_.c_str()); if (h == INVALID_HANDLE_VALUE) { *dev_handle = NULL; @@ -653,7 +669,7 @@ int usb_device::open(libusb_device_handle** dev_handle) up.address = upc.PipeInfo[i].EndpointAddress; up.type = upc.PipeInfo[i].PipeType; sprintf_s(ind, _countof(ind) - 1, "\\%04d", i); - up.pipe = CreateFileA((name_ + ind).c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + up.pipe = open_usb((name_ + ind).c_str()); if (up.pipe != INVALID_HANDLE_VALUE) { set_timeout(up.pipe); @@ -732,8 +748,8 @@ int usb_device::transfer_bulk(unsigned endpoint, unsigned char* data, int* lengt { if (WaitForSingleObject(oc->over_lapped()->hEvent, timeout) == WAIT_OBJECT_0) { - GetOverlappedResult(h, oc->over_lapped(), oc->io_bytes(), FALSE); - *length = *oc->io_bytes(); + GetOverlappedResult(h, oc->over_lapped(), oc->io_bytes(), FALSE); + *length = *oc->io_bytes(); ret = LIBUSB_SUCCESS; } else diff --git a/device/win_usb/win_usb.h b/device/win_usb/win_usb.h index 2e0f10a..e1d1b31 100644 --- a/device/win_usb/win_usb.h +++ b/device/win_usb/win_usb.h @@ -86,6 +86,7 @@ class usb_device // consider as libusb_device std::vector pipes_; DWORD timout_ms_; HANDLE find_pipe(UCHAR addr, int type, int *index = NULL); + HANDLE open_usb(const char* usb_name); int set_timeout(HANDLE h); public: diff --git a/sane/sane.rc b/sane/sane.rc index 111636e..4f7ed3c 100644 --- a/sane/sane.rc +++ b/sane/sane.rc @@ -248,8 +248,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,16,10100,22218 - PRODUCTVERSION 4,16,10100,22218 + FILEVERSION 4,17,10100,22221 + PRODUCTVERSION 4,17,10100,22221 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -266,12 +266,12 @@ BEGIN BEGIN VALUE "CompanyName", "宁波华高信息科技有限公司" VALUE "FileDescription", "华高扫描仪应用程序" - VALUE "FileVersion", "4.16.10100.22218" + VALUE "FileVersion", "4.17.10100.22221" VALUE "InternalName", "sane.dll" VALUE "LegalCopyright", "Copyright (C) 10100" VALUE "OriginalFilename", "sane.dll" VALUE "ProductName", "HUAGOScan" - VALUE "ProductVersion", "4.16.10100.22218" + VALUE "ProductVersion", "4.17.10100.22221" END END BLOCK "VarFileInfo"