我想使用載入 DLL()和我自己在 Visual Studio 中建構的 DLL。有人成功做到了嗎?
在哪裡可以找到演示如何在 DLL 端執行此操作的範例原始程式碼。
這是我想去的方向。 謝謝!
如果有一個示例 VS 解決方案/項目可供下載和編譯,那就太好了。
也許您可以從技術支持中得到一些東西;可能有一個名為 ExtFunctionTests 的文件,它是一個 C++ 程序,包含一整套用於將數據類型傳入和傳出 DLL 的示例。
或者這可能會朝著正確的方向發展(這是 2009 年使用當時流行的任何版本的 visual studio 構建的。 這是重要的部分。 “聲音”因為此 DLL 用於讓 JMP 播放聲音)
DLL中的JMP接口函數:
EXPORTFUNC int __cdecl init( int nCols, int channelMask, int samplesPerSecond, int nRows )
{
if ( theApp.mSoundThread == NULL )
{
theApp.mSoundThread = (SoundThread*)AfxBeginThread( RUNTIME_CLASS(SoundThread), 0, 0, CREATE_SUSPENDED, 0 );
theApp.mSoundThread->init( nCols, channelMask, samplesPerSecond, nRows );
theApp.mSoundThread->ResumeThread();
return 1;
}
return 0;
}
EXPORTFUNC double __cdecl feed( double * matrix, int elements )
{
return theApp.mSoundThread->feed( matrix, elements );
}
LPWSTR g_Declarations = L"\
DeclareFunction(\"init\", Convention( CDECL ), \n\
Arg( Int32, \"nCols\" ), Arg( Int32, \"channelMask\" ), Arg( Int32, \"samplesPerSecond\" ), Arg( Int32, \"nRows\" ), Returns( Int32 ) ) << \n\
DeclareFunction(\"feed\", Convention( CDECL ),\n\
Arg(Double, Array, \"array of nCols channels X nRows samples, -1..+1 \"), Arg(Int32), Returns(Double) );\n\
";
LPCWSTR __stdcall _JMP_Declarations()
{
return g_Declarations;
}.DEF 文件
; JMPSound.def : Declares the module parameters for the DLL.
LIBRARY "JMPSound"
EXPORTS
; Explicit exports can go here
_JMP_Declarations
由於上面的 g_Declarations,用於初始化 DLL 的 JSL 很簡單:
dll = loaddll("C:\Documents and Settings\L\Desktop\JMPSound.dll");
dll<<INIT></INIT>“初始化()”只是工作。 和“feed()”類似,傳遞數組...
data = leftchan || rightchan || col1:*alternate || col2:*alternate || col3:*alternate || col4:*alternate;
dll << feed( data, 0 );
(DLL 的目的是通過 feed 函數接受音頻樣本並播放它們……而 JMP 正在計算下一組樣本。 線程內容特定於此 DLL,您不需要使用線程。)
請參閱 Mark 的 JMP 感知 DLL 鏈接。 我做了一個,很久以前。 需要明確的是,有兩種類型:JMP 感知 DLL,以及所有其他類型。 JMP 感知 DLL 有一些額外的信息,使其更易於使用,並且可能沒有不可用的入口點。 使用不能很好地映射到 JMP 數據類型的複雜結構和指針的入口點可能無法使用。
我會看看能不能找到它,我把它放在哪裡都滿是灰塵......
這是一個無意識使用“多媒體DLL中的PlaySound"信封中的音頻筆記
@jschroedl
如果您執行“幫助 > 腳本索引”並蒐索“DLL”,您應該會看到許多示例來幫助您入門:
