WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DllCall Information

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to do DllCalls to Dlls with Double as one of the Passed Parameters

Keywords:    double dllcall

Question:

I need to call a dll that is expecting a "double" as one of the passed parameters. How can I do this? Here is the calling syntax for two of my problem API calls. I can't figure out how to pass the value of a double.
	long WINAPI chart_SetValue(HWND, int, int, double)
	long WINAPI chart_SetStripe(HWND, int, double, double, DWORD)

Answer:

Doubles are kind of rare.

I'll do the easy one...

	long WINAPI chart_SetValue(HWND, int, int, double) 
Here's the Winbatch code:
hwnd=DllHwnd("some window title")
int1=5 
int2=4
double=3.1515967

;the tricky part. Break double in half
;without kicking in the WinBatch mechanisms
;that try to autoconvert everything for you.

bb=BinaryAlloc(8)
BinaryPokeFlt(bb,0,double)
doub1=BinaryPeek4(bb,0)
doub2=BinaryPeek4(bb,4)
BinaryFree(bb) 

val=DllCall("the.dll",long:"Chart_SetValue",long:int1,long:int2,long:doub1,long:doub2)
That should work. TEST IT. If you get a weird stack pointer error then it didn't work at all.

Basically the calling conventions on both the calling and the callee side describe how the stack is set up to pass parameters. If we set up the appropriate smoke and mirrors, the callee does not know it and everything works, even though it appears we are passing more parameters than asked for....


Article ID:   W12867
Filename:   DllCalls to Dll with Double as Passed Param.txt
File Created: 1999:04:15:16:50:10
Last Updated: 1999:04:15:16:50:10