Calling .dlls from within max?

Archives Forums/Win32 Discussion/Calling .dlls from within max?

AntonyWells(Posted 2004) [#1]
Is it possible without resorting to doing C++ externs on a wrapper C++ file?


Robert(Posted 2004) [#2]
Yes. The Pub.Win32 module contains LoadLibraryA and GetProcAddress functions which you can use to load DLLs and get pointers to the functions contained in them.

I managed to get it working using this code, but it is very messy - there must be a much easier way to convert Byte Ptrs to the appropriate type of function pointer.

main

Function main()
	Local MessageBox(hWnd,text$z,caption$z,id)
	
	modHandle=LoadLibraryA("User32")
	If modHandle
		Local q:Int Ptr=Int Ptr(GetProcAddress(modHandle,"MessageBoxA"))
		'Really, really ugly and error prone - not a good idea!
		Local p:Int Ptr=Int Ptr(Varptr MessageBox)
	
		p[0]=Int(q)
		
		MessageBox(0,"HELLO WORLD","HI!",0)
	EndIf
	
	
End Function


Please don't use this to break multiplatform support though ;)


flying willy(Posted 2004) [#3]
Hi Antony, OT but what direction will your Vivid take, just curious as a lot of your DLL stuff could be ported to a module.


dmoc(Posted 2004) [#4]
Ugh!


AntonyWells(Posted 2004) [#5]
Thanks Robert, think i'll do a little module to simplify .dlls and post in the tweaks section - for anyone interested -.

Skunk, right now vivid's 2d engine can run in bmax fine, i'm considering releasing that with cg/pixel shader support, but vivid max3D(Thanks viper.;p) is coming too.(they'll be a demo this time though)
-


Robert(Posted 2004) [#6]
Will Vivid Max3D support MacOS & Linux?


AntonyWells(Posted 2004) [#7]
Yep, won't rely on .dlls this time.