473,396 Members | 1,997 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,396 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 2197
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.