How do you use an externeal DLL in MAX ??
B3D you just created a .lib file with the function declares in it
Local DllHandle = LoadLibraryA("wsc32.dll")
Local SioReset:Int(port:Int, buf1:Int, buf2:Int)"Win32" = GetProcAddress(DllHandle,"SioReset")
seems to work so far but not sure why ?
some functions require a pointer to a string or memory block ,, how is this done ??
hi maverick,
i am not sure i fully comprehend the scope of your questions, but if it is working it is because you are doing the right things.
you must have a "import pub.win32" somewhere before the code in your posting. is this true?
some functions require a pointer to a string or memory block ,, how is this done ??
use ptr and varptr or for a string, you can usually get away with $z (cstring) or string.ToCString()
getting back to why it is working (the first question).
you are explicitly loading the dll (loadlibrary) and asking (getprocaddress) for the address in memory (pointer) of a particular function which i am assuming you are interested in calling.
can you call "SioReset" ? if so, then you have answered your first question by yourself already.
perturbatio has answered your second question
Hi thanks for the reply.
I basically just looked around other posts and cobbled together the above code to see if it would work which it does :) I can call SioReset from the DLL and this works ,but comming from B3D and only now playing with the trial version I don`t really understand why it works yet (I`m used to the DECLS files in B3D)
I have noticed people using the following sort of thing
extern "win32"
function int:messageboxA
blah
blah
end function
function int:whatever
blah
blah
end function
end extern
but this format I have only used with windows API calls , i`m assuming that once you declare the function like
funtion messagebox($Z)
end function
you could then just write
messagebox("hello")
and the function would be called, this seems easier than the way I did it.
To be honest the inline documentation for max is the SH1TS
I couldn`t find loadlibraryA in any of it but it seems to work ,, how do people find out about these if the documentation is so poor ?