Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.12.12;
Скачать: CL | DM;

Вниз

Использование DLL написанной на С++   Найти похожие ветки 

 
Ricko ©   (2004-11-25 16:47) [0]

Срочно понадобилось управлять микшером звуковой карты 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) [1]

соглашения о вызовах тобой явно нарушены.

не бурусь утверждать, но либо stdcall (наиболее вероятно) либо cdecl (менее вероятно)



Страницы: 1 вся ветка

Текущий архив: 2004.12.12;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.037 c
6-1096626563
Дмитрий Ботвин
2004-10-01 14:29
2004.12.12
Объём оперативки на удаленном компе


1-1101793138
DelphiN!
2004-11-30 08:38
2004.12.12
Помогите решить проблемму с функцией


14-1100796664
matt
2004-11-18 19:51
2004.12.12
InterBase 6


8-1094823919
debuger
2004-09-10 17:45
2004.12.12
Контраст и Яркость.


1-1101844581
Der Juvas
2004-11-30 22:56
2004.12.12
Очистка строки