Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2006

Tip: Looking for answers? Try searching our database.

variable args question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bit byte - 30 Apr 2006 07:52 GMT
I have a C function that takes variable args, i.e. is of the form :

foo( const char*, const int, ... ) ;

I want to expose this function so that I can call it from VB(6).

My questions are:
1). Is it possible to export a function with variable args in a DLL?
2). How would such a functon be called from VB ? (Ok, this may not be
the correct group for a question on VB but, it is related to what I'm
doing ... )
Bruno van Dooren - 30 Apr 2006 08:29 GMT
>I have a C function that takes variable args, i.e. is of the form :
>
[quoted text clipped - 4 lines]
> My questions are:
> 1). Is it possible to export a function with variable args in a DLL?
I have never done so, but since the printf routines in the dynamic runtime
are also exported from a dll this should be possible.

> 2). How would such a functon be called from VB ? (Ok, this may not be the
> correct group for a question on VB but, it is related to what I'm doing
> ... )

I think this is what you are looking for:
http://msdn2.microsoft.com/en-US/library/sect4ck6(VS.80).aspx
A quick google indicated that this also works for vb6 (though it would be
safer to check in the vb6 documentation)

Note that I have never used VB, so I cannot tell you how you have to tell it
how to marshall your variables, but that should be standard stuff I guess.
microsoft.public.dotnet.languages.vb would be a good place to ask that
question probably.

Signature

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

Carl Daniel [VC++ MVP] - 30 Apr 2006 15:09 GMT
> I have a C function that takes variable args, i.e. is of the form :
>
[quoted text clipped - 4 lines]
> My questions are:
> 1). Is it possible to export a function with variable args in a DLL?

Sure - just export it.

> 2). How would such a functon be called from VB ? (Ok, this may not be
> the correct group for a question on VB but, it is related to what I'm
> doing ... )

I don't believe that it's possible to call a varargs function from VB6 - at
least not while preserving the variable argument list feature (which, AFIAK,
VB doesn't have).

If you always need to pass the same number and type of arguments, you could
simply declare the VB function to have a fixed argument list it, I believe,
it should "work", but that's definitely going down the path of hackery
rather than solid design..

-cd

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.