Bescheid...
Positiv-Meldung: Ich hab meinen Text auf dem Display
Das ABER:
Wie ich oben schon sagte, führt der Aufruf der INIT-Funktion mit stdcall zur einer
Access-Violation an Adresse 00000000.
Das hatte mich bisher davon abgehalten, es auf dem HTPC zu testen. Habe ich aber nun doch einfach mal gemacht....
Mein Label1 gibt mir OK zurück und der Text kommt. Den kann ich auch so oft ändern wie ich lustig bin - keine weiteren Fehler.
Auch Programm beenden (UNINIT) gibt kein Gemaule.
Was ist nun wieder verkehrt ?
Hier mal der kurze Quelltext zu Ansicht:
Delphi-Quellcode:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
SGVFDDLL = '
SG_VFD.dll';
// used Function from SG_VFD.dll
function VFD_Init(vfdType, dummy : integer) : bool;
stdcall;
external SGVFDDLL
name '
iMONVFD_Init';
procedure VFD_Uninit();
stdcall;
external SGVFDDLL
name '
iMONVFD_Uninit';
function VFD_IsInited() : bool;
stdcall;
external SGVFDDLL
name '
iMONVFD_IsInited';
function VFD_SetText(TXT1, TXT2 : PChar) : bool;
stdcall;
external SGVFDDLL
name '
iMONVFD_SetText';
function VFD_SetEQ(EQdata :
array of integer) : bool;
stdcall;
external SGVFDDLL
name '
iMONVFD_SetEQ';
{
TDUMP -ee SG_VFD.DLL
EXPORT ord:0001='iMONVFD_CheckDign'
EXPORT ord:0002='iMONVFD_Init'
EXPORT ord:0003='iMONVFD_IsInited'
EXPORT ord:0004='iMONVFD_SetAlarmOFF'
EXPORT ord:0005='iMONVFD_SetAlarmON'
EXPORT ord:0006='iMONVFD_SetAlarmON_Abs'
EXPORT ord:0007='iMONVFD_SetEQ'
EXPORT ord:0008='iMONVFD_SetText'
EXPORT ord:0009='iMONVFD_Uninit'
///////////////////////////////////////////////
// Open VFD driver and initialize parameters.
// Call this method, when application starts.
// Return value informs driver is open or not
bfdType = 4 !
IMONVFD_API bool iMONVFD_Init(int vfdType, int resevered=0);
///////////////////////////////////////////////
// Close VFD driver.
// Call this method, when application destroyed.
IMONVFD_API void iMONVFD_Uninit(void);
///////////////////////////////////////////////
// Check if VFD driver is opened.
IMONVFD_API bool iMONVFD_IsInited(void);
///////////////////////////////////////////////
// Send text data to VFD. VFD supports only English character set.
IMONVFD_API bool iMONVFD_SetText(char* szFirstLine, char* szSecondLine);
///////////////////////////////////////////////
// Send EQ data to VFD.
// Total 16band, each band ranges from 0 to 100
// make EQ data with integer array.
EQValue : array[0..15] of integer !
IMONVFD_API bool iMONVFD_SetEQ(int* arEQValue);
}
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
VFD_Uninit;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
if VFD_Init(4, 0)
then
label1.Caption := '
Init OK'
else
label1.Caption := '
Init failed';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if VFD_SetText(PChar(Edit1.Text), PChar(Edit2.Text))
then
label2.Caption := '
Text OK'
else
label2.Caption := '
Text failed';
end;
end.