I have a pretty good background with ahk macro's and app manipulations. I have delved into DllCall's for some basic tasks and got things happening. AHK is great!
I have hit a wall with this though. I am querying the well known PortAudio audio I/O library. I can initialize it, and get basic values returned like integers and stuff. However I am trying to get a return value of const char ** type.
I think I get that it's a pointer to a pointer of string. But I cannot for the life of me get a string from it.
I should note that this script will not run successfully on your system unless you have portaudio_x64.dll, and a soundcard with an ASIO driver.
However, DllCall experts may be able to point me in the right direction after parsing the code. I should note that my AHK is installed for x64 Unicode. My ASIO soundcard has x64 drivers. I'm on Win7 Pro x64.
This is the documetation here for the function I am trying to access:
Code: Select all
PaError PaAsio_GetOutputChannelName ( PaDeviceIndex device,
int channelIndex,
const char ** channelName
)
Retrieve a pointer to a string containing the name of the specified input channel. The string is valid until Pa_Terminate is called.
The string will be no longer than 32 characters including the null terminator.
Any help would be hugely appreciated! Thanks....
Code: Select all
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
paNoError = 0
hModule := DllCall("LoadLibrary", "Str", "portaudio_x64.dll", "Ptr") ; load dll
err := DllCall("portaudio_x64\Pa_Initialize")
if( err != paNoError )
{
errtxt := DllCall("portaudio_x64\Pa_GetErrorText", "Int", err, "AStr") ;Astr for const char*
MsgBox, Pa_Initialize: %errtxt%
}
Result := DllCall("portaudio_x64\Pa_GetDeviceCount", "Int")
MsgBox, Pa_GetDeviceCount: %Result%
; all works ok up until here - below is the problem
device = 0
channel = 0
VarSetCapacity(err, 64 * (A_IsUnicode ? 2 : 1))
err := DllCall("portaudio_x64\PaAsio_GetOutputChannelName", "Int", device, "Int", channel, "Ptr")
addr := NumGet(err, "Ptr") ; just an attempt
str := StrGet(addr, 64, "AStr") ; just an attempt
MsgBox, PaAsio_GetOutputChannelName:`n err: %err%`n addr: %addr%`n str: %str%
; err returns 4294957300
; addr returns 14636943605366836
; str returns nothing
; just tidying up from here, all ok
err := DllCall("portaudio_x64\Pa_Terminate")
if( err != paNoError )
{
errtxt := DllCall("portaudio_x64\Pa_GetErrorText", "Int", err, "AStr") ;Astr for const char*
MsgBox, Pa_Terminate: %errtxt%
}
DllCall("FreeLibrary", "Ptr", hModule) ; unload dll
return