by ぱん » 2006年1月31日(火) 01:32
>DLLを生成する場合のコードと,その(ABで作られたほうの)DLLを呼び出すコードを見ないと何ともいえないと思います。
すいません、返事が遅くなりました。m(_ _;)m
そうですね。コードを載せますね。
[ここをクリックすると内容が表示されます] [ここをクリックすると非表示にします]コード: 全て選択
#include "pxtone_use.idx"
Declare Function pxtone_Ready Lib "pxtone.dll" (hWnd as HWND, channel_num as Long, sps as Long, bps as Long, buffer_sec as Single, bDirectSound as Long, pProc as Long) as Long
Declare Function pxtone_Tune_Load Lib "pxtone.dll" (hModule as Long, type_name as Long, file_name as BytePtr) as Long
Declare Function pxtone_Tune_Play Lib "pxtone.dll" (start_sample as Long, fade_msec as Long) as Long
Declare Function pxtone_Tune_Stop Lib "pxtone.dll" () as Long
'-------------------------------------------------------------------
' メモ - このファイルには、DLLの構成要素を記述します。
' (例:関数定義、グローバル変数、定数定義など)
'
' エクスポートが必要な関数には、"Export" 修飾子を指定します。
' (例:Function Export FuncName() As Long)
'-------------------------------------------------------------------
Function Export DllMain(hinstDLL As HINSTANCE, fdwReason As DWord, lpvReserved As VoidPtr) As Long
'DLLエントリポイント
Select Case fdwReason
Case DLL_PROCESS_ATTACH
'DLLがプロセス空間にロードされた時に実行されます。
_System_StartupProgram()
DllMain=1
End Select
End Function
'ウインドウハンドル取得
Function Export GetWndVal(lpszArgs As BytePtr) As HWND
GetWndVal = FindWindow(NULL, lpszArgs)
End Function
'初期化
Function Export PxtoneInit(hWnd As HWND) As Long
'PxtoneInit = pxtone_Ready(hWnd, channel_num, sps, bps, buffer_sec, bDirectSound, NULL)
PxtoneInit = pxtone_Ready(hWnd, 2, 44100, 16, 0.1, TRUE, NULL)
End Function
'データ読み込み
Function Export PxtoneDataLoad(file_name as BytePtr) as Long
' PxtoneDataLoad = pxtone_Tune_Load(hModule, type_name, file_name)
PxtoneDataLoad = pxtone_Tune_Load(NULL, NULL, file_name)
End Function
'再生
Function Export PxtonePlay(start_sample as Long, fade_msec as Long) as Long
PxtonePlay = pxtone_Tune_Play(start_sample, fade_msec)
End Function
'停止
Function Export PxtoneStop() as Long
PxtoneStop = pxtone_Tune_Stop()
End Function
上記のコードでは、初期化の時点で必ず強制終了になってしまいます。
元々の呼び出しアプリ側は、数値はLong型と文字型の2種類のみです。
dmy = PxtoneInit(hWnd)
という感じで呼び出しています。
間違っている点がありましたらご指摘ください。m(_ _)m
>DLLを生成する場合のコードと,その(ABで作られたほうの)DLLを呼び出すコードを見ないと何ともいえないと思います。
すいません、返事が遅くなりました。m(_ _;)m
そうですね。コードを載せますね。
[hide][code]
#include "pxtone_use.idx"
Declare Function pxtone_Ready Lib "pxtone.dll" (hWnd as HWND, channel_num as Long, sps as Long, bps as Long, buffer_sec as Single, bDirectSound as Long, pProc as Long) as Long
Declare Function pxtone_Tune_Load Lib "pxtone.dll" (hModule as Long, type_name as Long, file_name as BytePtr) as Long
Declare Function pxtone_Tune_Play Lib "pxtone.dll" (start_sample as Long, fade_msec as Long) as Long
Declare Function pxtone_Tune_Stop Lib "pxtone.dll" () as Long
'-------------------------------------------------------------------
' メモ - このファイルには、DLLの構成要素を記述します。
' (例:関数定義、グローバル変数、定数定義など)
'
' エクスポートが必要な関数には、"Export" 修飾子を指定します。
' (例:Function Export FuncName() As Long)
'-------------------------------------------------------------------
Function Export DllMain(hinstDLL As HINSTANCE, fdwReason As DWord, lpvReserved As VoidPtr) As Long
'DLLエントリポイント
Select Case fdwReason
Case DLL_PROCESS_ATTACH
'DLLがプロセス空間にロードされた時に実行されます。
_System_StartupProgram()
DllMain=1
End Select
End Function
'ウインドウハンドル取得
Function Export GetWndVal(lpszArgs As BytePtr) As HWND
GetWndVal = FindWindow(NULL, lpszArgs)
End Function
'初期化
Function Export PxtoneInit(hWnd As HWND) As Long
'PxtoneInit = pxtone_Ready(hWnd, channel_num, sps, bps, buffer_sec, bDirectSound, NULL)
PxtoneInit = pxtone_Ready(hWnd, 2, 44100, 16, 0.1, TRUE, NULL)
End Function
'データ読み込み
Function Export PxtoneDataLoad(file_name as BytePtr) as Long
' PxtoneDataLoad = pxtone_Tune_Load(hModule, type_name, file_name)
PxtoneDataLoad = pxtone_Tune_Load(NULL, NULL, file_name)
End Function
'再生
Function Export PxtonePlay(start_sample as Long, fade_msec as Long) as Long
PxtonePlay = pxtone_Tune_Play(start_sample, fade_msec)
End Function
'停止
Function Export PxtoneStop() as Long
PxtoneStop = pxtone_Tune_Stop()
End Function
[/code][/hide]
上記のコードでは、初期化の時点で必ず強制終了になってしまいます。
元々の呼び出しアプリ側は、数値はLong型と文字型の2種類のみです。
dmy = PxtoneInit(hWnd)
という感じで呼び出しています。
間違っている点がありましたらご指摘ください。m(_ _)m