Calling .dlls from within max?

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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 ;)