mydll.cpp

来自「经典的 读写usb设备的 dll」· C++ 代码 · 共 67 行

CPP
67
字号
#include "stdafx.h"
#include "mydll.h"
#include "USB.H"

static USBDevice JLJC;

/*
		temp = Device_Report[7] - 0x30;
		temp = temp * 10 + Device_Report[8] - 0x30;
		temp = temp * 10 + Device_Report[9] - 0x30;
		temp = temp * 10 + Device_Report[10] - 0x30;
		temp = temp * 10 + Device_Report[11] - 0x30;

		TempID = temp;

		temp =			    Device_Report[4] - 0x41;
		temp = temp * 100 + Device_Report[5] - 0x41;
		temp = temp * 100 + Device_Report[6] - 0x41;	
		CloseHandle(DeviceHandler);
*/


extern "C"__declspec(dllexport) bool GetReport(unsigned char report[])
{
	int	temp;
	if(JLJC.GetDeviceHandler())
	{ 
		//temp = temp * 10 + Device_Report[8] - 0x30;
		JLJC.WriteCommandToDevice(4);
		Sleep(10);
		return true;
	}
	else
		return false;

}

extern "C"__declspec(dllexport) unsigned long GetDeviceID0(void)
{
	unsigned long TempID;
	if(JLJC.GetDeviceHandler())
	{
		JLJC.WriteCommandToDevice(4);
		Sleep(10);
		TempID = JLJC.ReadIDData0();
		return(TempID);
	}
	else
		return 0;
}

extern "C"__declspec(dllexport) unsigned long WriteID0(void)
{
	if(JLJC.GetDeviceHandler())
	{ 
		JLJC.WriteCommandToDevice(6);
		Sleep(10);
		return 1;
	}
	else
		return 0;
}

extern "C"__declspec(dllexport) void WritePara(unsigned long x)
{
    JLJC.TempID = x;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?