![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Использование DLL написанной на С++ [D7, Win95/98]
Ricko © (2004-11-25 16:47:00)Срочно понадобилось управлять микшером звуковой карты ECHO MIA. Управление стандартным микшером она (карта) обходит используя свою консоль управления. Нашел в инете пример на с++ . Так как я абсолютно не разбираюсь в с++ решил запихать основные функции в dll, а уж в своем приложении на Delphi их использовать. Но при передачи значения параметров функций в Delphi не соответствуют значениям параметрам в dll. Вместо них какой то мусор. Знатоки с++ укажите на ошибки.
bmix.cpp->
#include <vcl.h>
#include "CSplunge.h"
#include "CSplungeList.h"
#pragma hdrstop
//----------
USEUNIT("CSplunge.cpp");
USEUNIT("CSplungeList.cpp");
//----------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return 1;
}
//----------
CSplungeList *pSplungeList;
CSplunge *pSplunge;
__declspec(dllexport) int InitMyMixer(void)
{
pSplungeList = new CSplungeList;
if (0 == pSplungeList->GetNumSplunges())
{
delete pSplungeList;
return 0;
}
pSplunge = pSplungeList->GetNthSplunge(0);
pSplunge->OpenDriver();
pSplunge->OpenMixer();
return 42;
}
__declspec(dllexport) int CloseMyMixer(void)
{
delete pSplungeList;
return 0;
}
__declspec(dllexport) char *GetCardName(void)
{
if (pSplungeList)
{
ECHOGALS_CAPS *pCaps = pSplunge->GetCaps();
return pCaps->szName;
}
return "None";
}
__declspec(dllexport) int GetVolume(Word iBus0,Word iBus1)
{
int iGain;
ShowMessage("Input param> iBus0: "+IntToStr(iBus0)
+"iBus1: "+IntToStr(iBus1));
pSplunge->GetMonitorGain(iBus0,iBus1,iGain);
return iGain;
}
__declspec(dllexport) int GetMute(Word iBus0,Word iBus1)
{
int iGain;
ShowMessage("Input param> iBus0: "+IntToStr(iBus0)
+"iBus1: "+IntToStr(iBus1));
pSplunge->GetMonitorMute(iBus0,iBus1,iGain);
ShowMessage("Get mute: "+IntToStr(iGain));
return iGain;
}
__declspec(dllexport) int SetVolume(Word iBus0,Word iBus1, int iGain)
{
pSplunge->SetMonitorGain(iBus0,iBus1,iGain);
return 0;
}
__declspec(dllexport) int SetMute(Word iBus0,Word iBus1, int iMute)
{
BOOL b;
ShowMessage("Set mute: "+IntToStr(iMute));
if (iMute == 0) b=false; else b=true;
pSplunge->SetMonitorMute(iBus0,iBus1,b);
return 0;
}
main.pas
var
Form1: TForm1;
function InitMyMixer : integer; external 'bmix.dll' name '@InitMyMixer$qv';
function CloseMyMixer : integer; external 'bmix.dll' name '@CloseMyMixer$qv';
function GetCardName : PChar; external 'bmix.dll' name '@GetCardName$qv';
function GetVolume(bus0,bus1:word):integer; external 'bmix.dll' name '@GetVolume$qusus';
function GetMute(bus0,bus1:word):integer; external 'bmix.dll' name '@GetMute$qusus';
function SetVolume(bus0,bus1:word;Gain:integer):integer; external 'bmix.dll' name '@SetVolume$qususi';
function SetMute(bus0,bus1:word; Mute:integer):integer; external 'bmix.dll' name '@SetMute$qususi';
Digitman (2004-11-25 16:56:00) [1]соглашения о вызовах тобой явно нарушены.
не бурусь утверждать, но либо stdcall (наиболее вероятно) либо cdecl (менее вероятно)