Jump to content

confused about how to use dllcalls


Recommended Posts

hmm thanks, but after trying that I still get an autoit.exe crash

$dumy=guicreate("")
_BassInit("bass.dll", "tags.dll", "bass_fx.dll", $dumy)
$test=_BassStreamCreateFile("c:\record\record1.mp3")
_BassPlay($test)
Sleep(20000)
_BassStop($test)
_BassEnd()
It's funny, working with me.

Your dlls are in the scriptdir, used fonctions from my files have been copied in the script or the include is done ?

Link to comment
Share on other sites

So I tried the following but autoit.exe crashes when I execute it, any ideas?

#include <GUIConstants.au3>
#include <Array.au3>

Global $dllbass = DllOpen(@ScriptDir & "\bass.dll")

$file = DllStructCreate("c:\record\part1two.mp3")

$dumy = GuiCreate("dummy")
DllCall($dllbass, "short", "BASS_Init", "int", -1, "long", 44100, "long", 0, "long", $dumy, "long", "NULL"); initialisation de la dll
$test = DllCall($dllbass, "dword", "BASS_StreamCreateFile", "int", False, "ptr", DllStructGetPtr($file), "dword", 0, "dword", 0, "dword", 0)
;$bla = _ArrayDisplay($test)
;MsgBox(0, "", $test & " " & $bla & " " & @error) 
DllCall($dllbass, "short", "BASS_ChannelPlay", "dword", $test, "long", 0)
Sleep(20000)
DllCall($dllbass, "short", "BASS_ChannelStop", "dword", $test)
DllClose($dllbass)
Edited by tom13
Link to comment
Share on other sites

I agree with SmOke_N, this is good example of not doing enough RTFM'ing (both AutoIt and BASS lib).

Instead of making an effort to develop yourself a consistent code writing style that actually conforms with the rules imposed by the language, you, or whoever you copy-pasted these ideas from, are throwing random crap at the wall in hopes that some of it will stick (in the first code snippet you posted here, you manage to use 3 variations of passing a null value within a single DllCall - "int", "", "int", 0, "int", "NULL" - I believe that has to be some kind of record :)), and making false assumptions to justify such behaviour ("it works, maybe because that's how the .dll reads it").

Just because you got away with something once, doesn't mean you'll have such luck each time. Just because DllCall is nice enough to take nonsensical values without choking and silently ignore them, and because you can freely mix up types such as "int", "long", "dword" (and even "ptr" in 32-bit code) which all basically amount to the same Int32 size (4 bytes) and therefore make no significant difference when passing params to DllCall, doesn't mean the DllCall will guess the required size of parameters and fix it for you (in your last code snippet, which crashes on BASS_StreamCreateFile, you are passing "dword" types, while I open BASS helpfile and clearly see that some of those need to be QWORD (which is 8 bytes) = "uint64" in AutoIt).

Not to mention DllStructCreate("c:\record\part1two.mp3") which doesn't work under any circustances.

Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

I agree with SmOke_N, this is good example of not doing enough RTFM'ing (both AutoIt and BASS lib).

Instead of making an effort to develop yourself a consistent code writing style that actually conforms with the rules imposed by the language, you, or whoever you copy-pasted these ideas from, are throwing random crap at the wall in hopes that some of it will stick (in the first code snippet you posted here, you manage to use 3 variations of passing a null value within a single DllCall - "int", "", "int", 0, "int", "NULL" - I believe that has to be some kind of record :)), and making false assumptions to justify such behaviour ("it works, maybe because that's how the .dll reads it").

Just because you got away with something once, doesn't mean you'll have such luck each time. Just because DllCall is nice enough to take nonsensical values without choking and silently ignore them, and because you can freely mix up types such as "int", "long", "dword" (and even "ptr" in 32-bit code) which all basically amount to the same Int32 size (4 bytes) and therefore make no significant difference when passing params to DllCall, doesn't mean the DllCall will guess the required size of parameters and fix it for you (in your last code snippet, which crashes on BASS_StreamCreateFile, you are passing "dword" types, while I open BASS helpfile and clearly see that some of those need to be QWORD (which is 8 bytes) = "uint64" in AutoIt).

Not to mention DllStructCreate("c:\record\part1two.mp3") which doesn't work under any circustances.

So, you're telling me that it is not correct but not how to solve it or where to look. I was already aware that it is not correct or It'd have worked obviousely.

Anyhow, these functions have been passed to me indeed and apparently they're pretty flawed. But, I can't know howmuch bytes or bits or whatever a qword is (I obviousely have seen it in the bass help file but since there's no qword in autoit I've no idea how to handle it). And that is exactly the reason why I'm posting in this support forum..

So the question is how I am supposed to call that DLL.

Link to comment
Share on other sites

I agree with SmOke_N, this is good example of not doing enough RTFM'ing (both AutoIt and BASS lib).

Instead of making an effort to develop yourself a consistent code writing style that actually conforms with the rules imposed by the language, you, or whoever you copy-pasted these ideas from, are throwing random crap at the wall in hopes that some of it will stick (in the first code snippet you posted here, you manage to use 3 variations of passing a null value within a single DllCall - "int", "", "int", 0, "int", "NULL" - I believe that has to be some kind of record :)), and making false assumptions to justify such behaviour ("it works, maybe because that's how the .dll reads it").

Just because you got away with something once, doesn't mean you'll have such luck each time. Just because DllCall is nice enough to take nonsensical values without choking and silently ignore them, and because you can freely mix up types such as "int", "long", "dword" (and even "ptr" in 32-bit code) which all basically amount to the same Int32 size (4 bytes) and therefore make no significant difference when passing params to DllCall, doesn't mean the DllCall will guess the required size of parameters and fix it for you (in your last code snippet, which crashes on BASS_StreamCreateFile, you are passing "dword" types, while I open BASS helpfile and clearly see that some of those need to be QWORD (which is 8 bytes) = "uint64" in AutoIt).

Not to mention DllStructCreate("c:\record\part1two.mp3") which doesn't work under any circustances.

I tried to figure out when to use what kind of type for dllcall (int64 etc...) and this is my result, though I couldn't find bool and some more things.. anyway it still crashes on the exact same thing, could you assist maybe? ==>

#include <GuiConstants.au3>

$dll = @ScriptDir & "\bass.dll"
$file = "c:\record\part1two.mp3"

$dummy = GuiCreate("dummy")

$init = DllCall($dll, "int64", "BASS_Init", "int", -1, "dword", 44100, "dword", 0, "hwnd", $dummy, "long", "NULL")
$bass_error = DllCall($dll, "int", "BASS_ErrorGetCode")
ConsoleWrite("bass error init: " & $bass_error[0] & @CRLF)

$stream = DllCall($dll, "int64", "BASS_StreamCreateFile", "int64", FALSE, "ptr", $file, "uint64", 0, "uint64", 0, "dword", 0)
$bass_error = DllCall($dll, "int", "BASS_ErrorGetCode")
ConsoleWrite("bass error stream: " & $bass_error[0] & @CRLF)

Note that it crashes before the second error can be console written

Edited by tom13
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...