Calling .dlls from within max?
Archives Forums/Win32 Discussion/Calling .dlls from within max?| 
 | ||
| Is it possible without resorting to doing C++ externs on a wrapper C++ file? | 
| 
 | ||
| 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 ;) | 
| 
 | ||
| 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. | 
| 
 | ||
| Ugh! | 
| 
 | ||
| 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) - | 
| 
 | ||
| Will Vivid Max3D support MacOS & Linux? | 
| 
 | ||
| Yep, won't rely on .dlls this time. |