unit RadioDllWrapper;
interface
uses Windows, StrUtils, IniFiles;
type
TFNInitRadio =
procedure(strPath: PChar);
stdcall;
TFNCloseRadio =
procedure;
stdcall;
TFNSetRadioFrequenz =
procedure(Value: Integer; Tuner: Boolean);
stdcall;
TFNSetRadioIntervall =
procedure(Value: Integer);
stdcall;
TFNScanRadio =
procedure(direction: Boolean; Tuner: Boolean);
stdcall;
TFNSeekRadio =
procedure(direction: Boolean; Tuner: Boolean);
stdcall;
TFNSetRadioVolume =
procedure(Value: Integer);
stdcall;
TFNSetRadioBass =
procedure(Value: Integer);
stdcall;
TFNSetRadioTreble =
procedure(Value: Integer);
stdcall;
TFNSetRadioLoudnessOn =
procedure(Value: Boolean);
stdcall;
TFNSetRadioLoudnessStep =
procedure(Value: Boolean);
stdcall;
TFNSetRadioVolumeStep =
procedure(Value: Boolean);
stdcall;
TFNSetRadioFaderStep =
procedure(Value: Boolean);
stdcall;
TFNSetRadioBalanceStep =
procedure(Value: Boolean);
stdcall;
TFNSetRadioBassStep =
procedure(Value: Boolean);
stdcall;
TFNSetRadioTrebleStep =
procedure(Value: Boolean);
stdcall;
TFNSetRadioMute =
procedure(Value: Boolean);
stdcall;
TFNSetRadioRemote =
procedure(Value: Boolean);
stdcall;
TFNSetRadioLoudness =
procedure(Value: Integer);
stdcall;
TFNSetRadioBalance =
procedure(Value: Integer);
stdcall;
TFNSetRadioFader =
procedure(Value: Integer);
stdcall;
TFNSetRadioAntenne =
procedure(Tuner: Boolean; Antenne: Boolean);
stdcall;
TFNSetRadioAFOn =
procedure(Value: Boolean);
stdcall;
TFNSaveRadioValue =
procedure;
stdcall;
TFNRadioCallBack =
procedure(Value: Pointer);
stdcall;
function LoadRadioDll: Boolean;
function CloseRadioDll: Boolean;
//Dll-Callback
procedure RCallBack(
Index: Integer; Data: PChar; IntData: Integer);
const
RADIO_CLOSE = 0;
RADIO_OPEN = 1;
RADIO_FRQ1 = 2;
RADIO_FRQ2 = 3;
RADIO_PI1 = 4;
RADIO_PI2 = 5;
RADIO_FS1 = 6;
RADIO_FS2 = 7;
RADIO_RDSNAME1 = 8;
RADIO_RDSNAME2 = 9;
RADIO_RDSTEXT1 = 10;
RADIO_RDSTEXT2 = 11;
RADIO_PTY1 = 12;
RADIO_PTY2 = 13;
RADIO_MONO1 = 14;
RADIO_MONO2 = 15;
RADIO_TP1 = 16;
RADIO_TP2 = 17;
RADIO_INTERVALL = 200;
RADIO_REMOTE = 201;
RADIO_ERROR = 255;
RADIO_MESSAGE = 100;
var
InitRadio: TFNInitRadio=
nil;
CloseRadio: TFNCloseRadio =
nil;
SetRadioFrequenz: TFNSetRadioFrequenz =
nil;
SetRadioIntervall: TFNSetRadioIntervall =
nil;
ScanRadio: TFNScanRadio =
nil;
SeekRadio: TFNSeekRadio =
nil;
SetRadioVolume: TFNSetRadioVolume =
nil;
SetRadioBass: TFNSetRadioBass =
nil;
SetRadioTreble: TFNSetRadioTreble =
nil;
SetRadioLoudnessOn: TFNSetRadioLoudnessOn =
nil;
SetRadioLoudnessStep: TFNSetRadioLoudnessStep =
nil;
SetRadioVolumeStep: TFNSetRadioVolumeStep =
nil;
SetRadioFaderStep: TFNSetRadioFaderStep =
nil;
SetRadioBalanceStep: TFNSetRadioBalanceStep =
nil;
SetRadioBassStep: TFNSetRadioBassStep =
nil;
SetRadioTrebleStep: TFNSetRadioTrebleStep =
nil;
SetRadioMute: TFNSetRadioMute =
nil;
SetRadioRemote: TFNSetRadioRemote =
nil;
SetRadioLoudness: TFNSetRadioLoudness =
nil;
SetRadioBalance: TFNSetRadioBalance =
nil;
SetRadioFader: TFNSetRadioFader =
nil;
SetRadioAntenne: TFNSetRadioAntenne =
nil;
SetRadioAFOn: TFNSetRadioAFOn =
nil;
SaveRadioValue: TFNSaveRadioValue =
nil;
RadioCallBack: TFNRadioCallBack =
nil;
RadioLib: HMODULE;
implementation
uses
Radio, RadioUnit;
function LoadRadioDll: Boolean;
var
ini: TMemIniFile;
RadioDll:
String;
begin
result := False;
try
Ini:=TMemIniFile.Create('
Radio.ini');
RadioDll := Ini.ReadString('
Global','
RadioDll','
');
finally
ini.Free;
end;
if RadioDll <> '
'
then
RadioLib := LoadLibrary(PChar(RadioDll));
if RadioLib <> 0
then
begin
@InitRadio := GetProcAddress(RadioLib, '
InitRadio');
@CloseRadio := GetProcAddress(RadioLib, '
CloseRadio');
@SetRadioFrequenz := GetProcAddress(RadioLib, '
SetRadioFrequenz');
@SetRadioIntervall := GetProcAddress(RadioLib, '
SetRadioIntervall');
@ScanRadio := GetProcAddress(RadioLib, '
ScanRadio');
@SeekRadio := GetProcAddress(RadioLib, '
SeekRadio');
@SetRadioVolume := GetProcAddress(RadioLib, '
SetRadioVolume');
@SetRadioBass := GetProcAddress(RadioLib, '
SetRadioBass');
@SetRadioTreble := GetProcAddress(RadioLib, '
SetRadioTreble');
@SetRadioLoudnessOn := GetProcAddress(RadioLib, '
SetRadioLoudnessOn');
@SetRadioLoudnessStep := GetProcAddress(RadioLib, '
SetRadioLoudnessStep');
@SetRadioVolumeStep := GetProcAddress(RadioLib, '
SetRadioVolumeStep');
@SetRadioFaderStep := GetProcAddress(RadioLib, '
SetRadioFaderStep');
@SetRadioBalanceStep := GetProcAddress(RadioLib, '
SetRadioBalanceStep');
@SetRadioBassStep := GetProcAddress(RadioLib, '
SetRadioBassStep');
@SetRadioTrebleStep := GetProcAddress(RadioLib, '
SetRadioTrebleStep');
@SetRadioMute := GetProcAddress(RadioLib, '
SetRadioMute');
@SetRadioRemote := GetProcAddress(RadioLib, '
SetRadioRemote');
@SetRadioLoudness := GetProcAddress(RadioLib, '
SetRadioLoudness');
@SetRadioBalance := GetProcAddress(RadioLib, '
SetRadioBalance');
@SetRadioFader := GetProcAddress(RadioLib, '
SetRadioFader');
@SetRadioAntenne := GetProcAddress(RadioLib, '
SetRadioAntenne');
@SetRadioAFOn := GetProcAddress(RadioLib, '
SetRadioAFOn');
@SaveRadioValue := GetProcAddress(RadioLib, '
SaveRadioValue');
@RadioCallBack := GetProcAddress(RadioLib, '
RadioCallBack');
result := True;
end;
end;
function CloseRadioDll: Boolean;
begin
if RadioLib <> 0
then
begin
FreeLibrary(RadioLib);
result := True;
end else
result := False;
end;
//Diese Funktion soll das Hauptprogramm aufrufen bei einer Dll-Nachricht
procedure RCallBack(
Index: Integer; Data: PChar; IntData: Integer);
begin
case Index of
RADIO_CLOSE :
begin RadioOn := False;
end;
RADIO_OPEN :
begin
SetRadioFrequenz(LastRadioFrq, False);
SetRadioMute(False);
if RadioAF
then SetRadioAFOn(True);
RadioOn := True;
end;
RADIO_FRQ1 :
begin
frmMain.Flash.SetVariable('
RADIOFREQ',
String(Data));
RadioFrequenz1 :=
String(Data);
Frequenz := IntData;
end;
RADIO_FRQ2 :
begin frmMain.Flash.SetVariable('
AFFREQ',
String(Data));
end;
RADIO_PI1 :
begin
frmMain.Flash.SetVariable('
PICODE',
String(Data));
PICode :=
String(Data);
frmMain.Flash.SetVariable('
RADIOLOGO', AppPath + '
\Radio\' + PICode + '
.jpg');
end;
RADIO_PI2 :
begin frmMain.Flash.SetVariable('
AFPICODE',
String(Data));
end;
RADIO_FS1 :
begin frmMain.Flash.SetVariable('
RDSSIGNAL',
String(Data));
end;
RADIO_FS2 :
begin frmMain.Flash.SetVariable('
AFFS',
String(Data));
end;
RADIO_RDSNAME1 :
begin
frmMain.Flash.SetVariable('
RDSNAME',
String(Data));
Radioname :=
String(Data);
end;
RADIO_RDSNAME2 :
begin end;
RADIO_RDSTEXT1 :
begin
frmMain.Flash.SetVariable('
RDSTEXT',
String(Data));
end;
RADIO_RDSTEXT2 :
begin end;
RADIO_PTY1 :
begin frmMain.Flash.SetVariable('
RADIOGENRE',
String(Data));
end;
RADIO_PTY2 :
begin end;
RADIO_MONO1 :
begin frmMain.Flash.SetVariable('
RADIOSTEREO',
String(Data));
end;
RADIO_MONO2 :
begin end;
RADIO_TP1 :
begin frmMain.Flash.SetVariable('
TP',
String(Data));
end;
RADIO_TP2 :
begin end;
RADIO_INTERVALL :
begin OutputDebugString(Data);
end;
RADIO_REMOTE :
begin frmMain.Remote(IntData);
end;
RADIO_ERROR :
begin OutputDebugString(Data);
end;
RADIO_MESSAGE :
begin OutputDebugString(Data);
end;
end;
end;
end.