I know few basics of Delphi (In fact I've been using it for few years)...
I'm hitting a wall with DLL's (never really play with this).
Consider this example:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
Type FT_Result = Integer;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
FT_HANDLE : DWord = 0;
implementation
{$R *.dfm}
function I2C_GetNumChannels(numChannels: dword):FT_Result; stdcall; external 'libmpsse.dll' name 'I2C_GetNumChannels';
function I2C_OpenChannel(index:dword;handle:pointer):FT_Result; stdcall; external 'libmpsse.dll' name 'I2C_OpenChannel';
procedure TForm1.Button1Click(Sender: TObject);
var
numofchannels:dword;
begin
i2c_getnumchannels(numofchannels);
showmessage(inttostr(numofchannels));
end;
end.
I need to interface the libmpsse.dll from FTDI to access a I2C device on the USB port.
When i'm calling the function I2C_GetNumChannels I get tons of AccessViolation...
I just want to know what's wrong with the dll function?
Also I2C_GetNumChannels is supposed to returns 2 values...
From the official API guide here -->http://www.ftdichip.com/Support/Documents/AppNotes/AN_177_User_Guide_For_LibMPSSE-I2C.pdf
Thank you very much!
Regards