资源简介

该压缩文件中包含有hidapi代码源码以及使用vs2015软件编译完成的hidapi.dll,hidapi.lib和hidapi.h文件,可以直接使用,分别包含有Debug和Release两个版本的动态库文件

资源截图

代码片段和文件信息

/*******************************************************
 Windows HID simplification

 Alan Ott
 Signal 11 Software

 8/22/2009

 Copyright 2009
 
 This contents of this file may be used by anyone
 for any reason without any conditions and may be
 used as a starting point for your own applications
 which use HIDAPI.
********************************************************/

#include 
#include 
#include 
#include 
#include “hidapi.h“

// Headers needed for sleeping.
#ifdef _WIN32
#include 
#else
#include 
#endif

int main(int argc char* argv[])
{
int res;
unsigned char buf[256];
#define MAX_STR 255
wchar_t wstr[MAX_STR];
hid_device *handle;
int i;

#ifdef WIN32
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
#endif

struct hid_device_info *devs *cur_dev;

if (hid_init())
return -1;

devs = hid_enumerate(0x0 0x0);
cur_dev = devs;
while (cur_dev) {
printf(“Device Found\n  type: %04hx %04hx\n  path: %s\n  serial_number: %ls“ cur_dev->vendor_id cur_dev->product_id cur_dev->path cur_dev->serial_number);
printf(“\n“);
printf(“  Manufacturer: %ls\n“ cur_dev->manufacturer_string);
printf(“  Product:      %ls\n“ cur_dev->product_string);
printf(“  Release:      %hx\n“ cur_dev->release_number);
printf(“  Interface:    %d\n“  cur_dev->interface_number);
printf(“\n“);
cur_dev = cur_dev->next;
}
hid_free_enumeration(devs);

// Set up the command buffer.
memset(buf0x00sizeof(buf));
buf[0] = 0x01;
buf[1] = 0x81;


// Open the device using the VID PID
// and optionally the Serial number.
////handle = hid_open(0x4d8 0x3f L“12345“);
handle = hid_open(0x4d8 0x3f NULL);
if (!handle) {
printf(“unable to open device\n“);
  return 1;
}

// Read the Manufacturer String
wstr[0] = 0x0000;
res = hid_get_manufacturer_string(handle wstr MAX_STR);
if (res < 0)
printf(“Unable to read manufacturer string\n“);
printf(“Manufacturer String: %ls\n“ wstr);

// Read the Product String
wstr[0] = 0x0000;
res = hid_get_product_string(handle wstr MAX_STR);
if (res < 0)
printf(“Unable to read product string\n“);
printf(“Product String: %ls\n“ wstr);

// Read the Serial Number String
wstr[0] = 0x0000;
res = hid_get_serial_number_string(handle wstr MAX_STR);
if (res < 0)
printf(“Unable to read serial number string\n“);
printf(“Serial Number String: (%d) %ls“ wstr[0] wstr);
printf(“\n“);

// Read Indexed String 1
wstr[0] = 0x0000;
res = hid_get_indexed_string(handle 1 wstr MAX_STR);
if (res < 0)
printf(“Unable to read indexed string 1\n“);
printf(“Indexed String 1: %ls\n“ wstr);

// Set the hid_read() function to be non-blocking.
hid_set_nonblocking(handle 1);

// Try to read from the device. There should be no
// data here but execution should not block.
res = hid_read(handle buf 17);

// Send a Feature Report to the device
buf[0] = 0x2;
buf[1] = 0xa0;
buf[2] = 0x0a;
buf[3] = 0x00;
buf[4] = 0x00

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-11-01 10:41  hidapi\
     目录           0  2019-11-01 10:40  hidapi\hidapi dll\
     目录           0  2019-11-01 10:40  hidapi\hidapi dll\dll\
     目录           0  2019-11-01 10:40  hidapi\hidapi dll\dll\Debug\
     文件       48128  2019-11-01 10:35  hidapi\hidapi dll\dll\Debug\hidapi.dll
     目录           0  2019-11-01 10:40  hidapi\hidapi dll\dll\Release\
     文件       79360  2019-11-01 10:35  hidapi\hidapi dll\dll\Release\hidapi.dll
     文件       14739  2019-10-31 18:56  hidapi\hidapi dll\hidapi.h
     目录           0  2019-11-01 10:40  hidapi\hidapi dll\lib\
     目录           0  2019-11-01 10:40  hidapi\hidapi dll\lib\Debug\
     文件        5270  2019-11-01 10:35  hidapi\hidapi dll\lib\Debug\hidapi.lib
     目录           0  2019-11-01 10:40  hidapi\hidapi dll\lib\Release\
     文件        5270  2019-11-01 10:35  hidapi\hidapi dll\lib\Release\hidapi.lib
     目录           0  2019-10-31 18:56  hidapi\hidapi-master\
     文件        1102  2019-10-31 18:56  hidapi\hidapi-master\.appveyor.yml
     目录           0  2019-10-31 18:56  hidapi\hidapi-master\.builds\
     文件         279  2019-10-31 18:56  hidapi\hidapi-master\.builds\alpine.yml
     文件         194  2019-10-31 18:56  hidapi\hidapi-master\.builds\archlinux.yml
     文件         278  2019-10-31 18:56  hidapi\hidapi-master\.builds\fedora-mingw.yml
     文件         262  2019-10-31 18:56  hidapi\hidapi-master\.builds\freebsd.yml
     文件         104  2019-10-31 18:56  hidapi\hidapi-master\.gitattributes
     文件         265  2019-10-31 18:56  hidapi\hidapi-master\.gitignore
     文件         127  2019-10-31 18:56  hidapi\hidapi-master\.travis.yml
     目录           0  2019-10-31 18:56  hidapi\hidapi-master\android\
     目录           0  2019-10-31 18:56  hidapi\hidapi-master\android\jni\
     文件         349  2019-10-31 18:56  hidapi\hidapi-master\android\jni\Android.mk
     文件         421  2019-10-31 18:56  hidapi\hidapi-master\AUTHORS.txt
     文件          52  2019-10-31 18:56  hidapi\hidapi-master\bootstrap
     文件        7188  2019-10-31 18:56  hidapi\hidapi-master\configure.ac
     目录           0  2019-10-31 18:56  hidapi\hidapi-master\dist\
     文件        1355  2019-10-31 18:56  hidapi\hidapi-master\dist\hidapi.podspec
............此处省略122个文件信息

评论

共有 条评论

相关资源