473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

HOWTO: use ArgIterator

Hello, All!

I haven't found any example of using ArgIterator and RuntimeArgumentHandle in MSDN. Are they analogous to elipsis (...) in C++? Can I call DLL exported function with elipsis using ArgIterator?

Regards,
Vladimir.

Winamp 5.0 (playing): Stratovarius - 4th Reich
Nov 22 '05 #1
3 2196
Vladimir,
I haven't found any example of using ArgIterator and RuntimeArgumentHandle in MSDN. Are they analogous to elipsis (...) in C++?
Here's an example

static void Varargs(__arglist)
{
ArgIterator args = new ArgIterator( __arglist );

int argCount = args.GetRemainingCount();
for ( int i = 0; i < argCount; i++ )
Console.WriteLine( TypedReference.ToObject( args.GetNextArg() ) );
}

static void Main()
{
Varargs( __arglist( 123, 456.78, "abc" ) );
}

Can I call DLL exported function with elipsis using ArgIterator?


You only need ArgIterator if you want to implement a varargs method.
For calling one you only need __arglist. __arglist, BTW, is
undocumented so there's no guarantee that it'll work in future
versions or other C# compilers. For pure managed work I'd strongly
recommend using params instead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 22 '05 #2
Mattias Sjögren wrote:
[...]
static void Varargs(__arglist)
[...]


<shudder>
Nov 22 '05 #3
Hello, Mattias!
You wrote on Fri, 05 Mar 2004 20:35:40 +0100:

>> I haven't found any example of using ArgIterator and
>> RuntimeArgumentHandle in MSDN. Are they analogous to elipsis
>> (...) in C++?


MS> Here's an example
MS> static void Varargs(__arglist)
MS> Varargs( __arglist( 123, 456.78, "abc" ) );

And what about RuntimeArgumentHandle?

Another question. If I have some exported function in DLL defined like this

_declspec(dllexport) void DummyFn(char *sz1, char sz2, ...)
{
va_list marker;
vs_start(marker, sz2);
<do_some_stuff>;
va_end(marker);
}

how can I call it from C#? I've tried __arglist and params. It doesn't work. It seems PInvoke doesn't support such calls. And IJW too.

Regards,
Vladimir.

Winamp 5.0 (playing): Stratovarius - Twilight Time
Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Josef Sachs | last post by:
Is Andrew Kuchling's regex-to-re HOWTO available anywhere? I've found the following (dead) links on various Web pages: http://py-howto.sourceforge.net/regex-to-re/regex-to-re.html...
3
by: Vladimir | last post by:
Hello, All! I haven't found any example of using ArgIterator and RuntimeArgumentHandle in MSDN. Are they analogous to elipsis (...) in C++? Can I call DLL exported function with elipsis using...
3
by: Vladimir | last post by:
Hello, All! I haven't found any example of using ArgIterator and RuntimeArgumentHandle in MSDN. Are they analogous to elipsis (...) in C++? Can I call DLL exported function with elipsis using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.