Jump to content

Recommended Posts

Posted

There is an API for hardware, which is implemented through Lusbapi.dll

In the C ++ reference it looks like this:
1) if (GetDllVersion() != 2) { printf("error 1"); }
2) pModule = static_cast<ILE440 *>(CreateInstance("e440"));
if (pModule == NULL) { printf("error 2"); }
3) if (!pModule->GetModuleName()) { printf("error 3"); }

For AutoIt I rewrote:
$hDLL = DllOpen('Lusbapi.dll')
1) $aRes = DllCall($hDLL, 'LRESULT', 'GetDllVersion')
if $aRes[0] <> 2 then Exit
2) $tDeviceName = DllStructCreate("char DeviceName[9]")
DllStructSetData($tDeviceName, "DeviceName", 'e440')
$aRes = DllCall($hDLL, 'PTR', 'CreateLInstance', 'STRUCT*', $tDeviceName)
$pModule = $aRes[0]
if $pModule == Null then Exit
3) At this step, the error
$aRes = DllCall($hDLL, 'PTR', 'GetModuleName')

The function GetModuleName was not found (since this is a method from the CreateLInstance function), I could not implement a call to the method

Posted

Hello.  this should work.

 

Local $sDeviceName="e440"
Local $aCall = DllCall($hDLL, 'dword', 'CreateLInstance', 'str', $sDeviceName)

Saludos

Posted

So part of your include lusbapi.h has some struct constructs where the pointer reference is to the function

extern "C" DWORD WINAPI GetDllVersion(void);
extern "C" LPVOID WINAPI CreateLInstance(PCHAR const DeviceName);

enum { USB11_LUSBAPI, USB20_LUSBAPI, INVALID_USB_SPEED_LUSBAPI };
enum { NO_MODULE_MODIFICATION_LUSBAPI = -1 };
const WORD MAX_VIRTUAL_SLOTS_QUANTITY_LUSBAPI = 127;


// ==========================================================================
// *************************** L-Card USB BASE ******************************
// ==========================================================================
struct ILUSBBASE
{
	virtual BOOL WINAPI OpenLDevice(WORD VirtualSlot) = 0;
	virtual BOOL WINAPI CloseLDevice(void) = 0;
	virtual BOOL WINAPI ReleaseLInstance(void) = 0;
	virtual HANDLE WINAPI GetModuleHandle(void) = 0;
	virtual BOOL WINAPI GetModuleName(PCHAR const ModuleName) = 0;
	virtual BOOL WINAPI GetUsbSpeed(BYTE* const UsbSpeed) = 0;
	virtual BOOL WINAPI LowPowerMode(BOOL LowPowerFlag) = 0;
	virtual BOOL WINAPI GetLastErrorInfo(LAST_ERROR_INFO_LUSBAPI* const LastErrorInfo) = 0;
};

struct ILE140 : public ILUSBBASE
{
	virtual BOOL WINAPI GET_ADC_PARS(ADC_PARS_E140* const AdcPars) = 0;
	virtual BOOL WINAPI SET_ADC_PARS(ADC_PARS_E140* const AdcPars) = 0;
	virtual BOOL WINAPI START_ADC(void) = 0;
...

 

For that to work you probably need

 

Posted

You need to do something like this.

 

Local $tFunctions = DllStructCreate("ptr[" $iNumberOfFunctions "]", $pModule)
DllCallAddress("none", DllStructGetData($tFunctions,1, 4)) ;GetModuleHandle

Saludos
 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...