all groups > visual c > july 2006 >
You're in the

visual c

group:

C DLL + variable length parameters


Re: C DLL + variable length parameters William DePalo [MVP VC++]
7/28/2006 11:10:06 AM
visual c:
[quoted text, click to view]

Yes. In fact wsprintf(), which takes a variable number of arguments, is
exported by USER32.DLL. What problem are you having?

Regards,
Will

C DLL + variable length parameters Bit Byte
7/28/2006 1:06:04 PM
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 delimited string to be parsed in the function)?

i.e. I want something like this:

#include <varargs.h>

CCONV foo( char* fmt, va_list args ) ;

where CCONV is the calling convention (import/export)
Re: C DLL + variable length parameters William DePalo [MVP VC++]
7/28/2006 2:31:03 PM
[quoted text, click to view]

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

Re: C DLL + variable length parameters Bit Byte
7/28/2006 5:54:50 PM


[quoted text, click to view]
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 ?


Re: C DLL + variable length parameters Bruno van Dooren [MVP VC++]
7/29/2006 1:43:32 PM
[quoted text, click to view]

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.

--

Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"
[quoted text, click to view]

AddThis Social Bookmark Button