델파이에 대한 몇 가지 기본 지식을 알고 있습니다. (사실 저는 몇 년 동안이 파일을 사용하고 있습니다 ...)Delphi에서 외부 DLL을 올바르게 호출 하시겠습니까?
저는 DLL로 벽을 치고 있습니다.
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.
내가 USB 포트에 I2C 장치에 액세스 할 수 FTDI에서 libmpsse.dll 인터페이스해야합니다
이 예를 생각해 보자.I2C_GetNumChannels 함수를 호출 할 때 AccessViolation 톤이 발생합니다 ...
dll 함수의 문제점을 알고 싶습니다. 또한 I2C_GetNumChannels 반품에이 개 값을 가정한다
... 여기 공식 API 가이드에서
-
>http://www.ftdichip.com/Support/Documents/AppNotes/AN_177_User_Guide_For_LibMPSSE-I2C.pdf 대단히 감사합니다!
감사합니다.
'numChannels'는'DWORD'가 아니라'DWORD'를 가리키는 포인터입니다. 함수 선언이 잘못되었습니다. –
그에 따라 코드를 수정했습니다 ... 감사합니다! – ELCouz