>>Is it possible to pass variable length parameters to a C function exported
>>in a DLL (i.e. using varargs.h without resorting to say passing a
[quoted text clipped - 13 lines]
> Regards,
> Will
Hi Will,
Thanks for replying, actually, my prototype was wrong. I wanted
something more like this:
CCONV foo(char* fmt, ...) ;
To be exported by my DLL - is this possible ?
(from what you say though - it should be possible - since wsprintf is
exported by user32.dll. I have seen a lot of questions posted about this
and the answer seems to be a resounding no - or having to resort to
"tricks".
Ah, but I did leave out one piece of (vital?) information though - I
want to be able to call this Dll function from VB - still possible ?
William DePalo [MVP VC++] - 28 Jul 2006 19:31 GMT
> Ah, but I did leave out one piece of (vital?) information though - I want
> to be able to call this Dll function from VB - still possible ?
VB is another kettle of fish entirely.
You will get a better reply in the VB groups than from me because I am happy
to remain blissfully ignorant of VB. :-)
That said, I _think_ (and I could be wrong) that you would need to use
something like ATL's CComSafeArray class to pass a variable number of
widgets back and forth. How you'd consume such a thing in VB if it is indeed
possible ... well, it beats the heck out of me. :-)
Regards,
Will
Bruno van Dooren [MVP VC++] - 29 Jul 2006 12:43 GMT
> Thanks for replying, actually, my prototype was wrong. I wanted something
> more like this:
[quoted text clipped - 10 lines]
> Ah, but I did leave out one piece of (vital?) information though - I want
> to be able to call this Dll function from VB - still possible ?
This question came up some time ago, and the answer was negative.
Yes, you can export varargs functions (calling convention has to be __cdecl)
Yes you can use it in VB if you import it as a function with a specific
prototype (i.e. you fix the argument list).
No, you cannot -AFAIK- import it directly as a varargs function.
But maybe someone on the VB forums can give you an alternative solution /
workaround.

Signature
Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"