In the meantime, I made a working C++ demo program in Borland C++Builder.
[quote]I also think that the variable names can be omitted in the header, i.e. “SetGen(int,float,float,…)” instead of “SetGen(int func,float freq,float ampl)”.[/quote]Indeed, works fine with this header file too:
fgulink.h
[code]#ifdef __cplusplus
extern “C” {
#endif
#define FUNCTION __declspec(dllimport)
FUNCTION __stdcall SetGen(int, float, float, float);
FUNCTION __stdcall SetSweep(float, float, float, float, float, int);
FUNCTION __stdcall SetLibWave(float, float, float, int, char*);
FUNCTION __stdcall StartGen();
FUNCTION __stdcall StopGen();
FUNCTION __stdcall OpenGen();
FUNCTION __stdcall CloseGen();
FUNCTION bool __stdcall GenReady();
FUNCTION int __stdcall GenStatus();
FUNCTION __stdcall ShowGen(bool);
FUNCTION __stdcall AttOn(bool);
FUNCTION __stdcall LogSweep(bool);
#ifdef __cplusplus
}
#endif[/code]
Here the code of the whole program:[size=85][code]
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include “fgulink.h”
#include “Unit1.h”
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource “*.dfm”
TForm1 Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
OpenGen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
CloseGen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
SetGen(1, 1000, 5, 0);
StartGen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
{
SetGen(2, 1500, 5, 0);
StartGen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
SetGen(3, 1000, 5, 0);
StartGen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button11Click(TObject *Sender)
{
char s[20] = “ramp_dn.lib”;
SetLibWave(1000, 5, 2.5, 1, s);
StartGen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button9Click(TObject *Sender)
{
LogSweep(true);
SetSweep(10, 2000000, 5, 0, 50, 1);
StartGen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
LogSweep(false);
SetSweep(1000, 10000, 5, 0, 10, 2);
StartGen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
StopGen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CheckBox1Click(TObject *Sender)
{
AttOn(CheckBox1->Checked);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CheckBox2Click(TObject *Sender)
{
ShowGen(!CheckBox2->Checked);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if(GenReady())
{
Label2->Caption = “Generator Ready!”;
}
else
{
Label2->Caption = “Generator Not Ready”;
}
Label3->Caption = "Status: "+IntToStr(GenStatus());
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
CloseGen();
}
//---------------------------------------------------------------------------[/code][/size]