我想使用加載 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>“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”,您應該會看到一些示例來幫助您入門:
