I have found out that it must have something to do with the DllCall function as with AHK DllCall(A_Temp . "\BASS.dll\BASS_MusicLoad", UInt, mem, UInt, &file, UInt64, offset, UInt, length, UInt, flags, UInt, freq) returns a handle while it does not when run with AHK_L.
Using bass.dll and song.mo3 from k3ph's script (just comment out the
FileDelete commands and find them in your TEMP directory and copy them to the directory which the script is running in) and this
code
Code:
SetBatchLines,-1
Thread, NoTimers
BASS_Init(device,freq,flags,win,clsid){
global
BassDll:=DllCall("LoadLibrary", "str", "\BASS.dll")
Return DllCall("\BASS.dll\BASS_Init", Int, device, Int, freq, Int, flags, UInt, win, UInt, clsid)
}
BASS_ChannelPlay(handle,restart){
;Return DllCall("\BASS.dll\BASS_ChannelPlay", UInt, handle, Int, restart)
Return DllCall("\BASS.dll\BASS_ChannelPlay", UInt, handle, Int, restart, Cdecl Int)
}
BASS_MusicLoad(mem,file,offset,length,flags,freq){
Return DllCall("\BASS.dll\BASS_MusicLoad", UInt, mem, UInt, &file, UInt64, offset, UInt, length, UInt, flags, UInt, freq)
}
BASS_ChannelGetLength(handle,mode){
Return DllCall("\BASS.dll\BASS_ChannelGetLength", UInt, handle, UInt, mode, UInt64)
}
BASS_ChannelBytes2Seconds(handle,pos){
Return DllCall("\BASS.dll\BASS_ChannelBytes2Seconds", UInt, handle, UInt64, pos, Double)
}
BASS_ErrorGetCode(){
Return DllCall("\BASS.dll\BASS_ErrorGetCode", Int)
}
BASS_Free(){
global
Return DllCall("\BASS.dll\BASS_Free", UInt, true),
DllCall("FreeLibrary", UInt, BassDll)
}
onexit,exit
bass=BASS.dll
fullbass=bass
fullfile=song.mo3
; -------------- Init ------------------------------
BASS_Init(-1,44100,0,0,0)
; -------------- Load ------------------------------
hStream:=BASS_MusicLoad( False, fullfile, 0, 0, 0x40000+0x20000+0x1000, 44100)
MsgBox,,hstream,%hstream%
a:=BASS_ErrorGetCode()
MsgBox ,,ErrorCode, %a%,
; -------------- GetLength ------------------------------
hStream_time:=Floor(BASS_ChannelBytes2Seconds(hStream,BASS_ChannelGetLength(hStream,0)))
hStream_sleep:=hStream_time*1000
; -------------- Play ------------------------------
a:=BASS_ChannelPlay( hStream, 0)
MsgBox,,ChannelPlay,%a%
a:=BASS_ErrorGetCode()
MsgBox ,,ErrorCode, %a%,
sleep %hStream_sleep%
exit:
BASS_Free()
ExitApp
I get MessageBoxes as follows:
AHK: -1610612735 (a valid handle) / 0 (no error) / 1 (ChannelPlay successful) / 0 (no error)
AHK_L ANSI: -1610612735 / 0 / 1 / 0 --> however, this only works when the "Cdecl Int" in the DllCall to BASS_ChannelPlay is removed (see the commented line above), otherwise I get an empty string insted of 1 and it doesn't play anything
AHK_L Unicode: 0 (no handle) / 2 ( BASS_ERROR_FILEOPEN) / 0 (ChannelPlay failed) / 5 (BASS_ERROR_HANDLE)
What has to be changed to make the script run with AHK_L Unicode and why does it run with AHK_L ANSI only without "Cdecl Int"?