473,387 Members | 1,483 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.

DLL warpper help!! Nick Paldino

bob
How to wrap the following function using PInvole-

VARIANT _stdcall retVariantArray(void) {
COleSafeArray saRet;
DWORD numElements[] = {10, 10}; // 10x10

// Create the safe-array...
saRet.Create(VT_R8, 2, numElements);

// Initialize it with values...
long index[2];
for(index[0]=0; index[0]<10; index[0]++) {
for(index[1]=0; index[1]<10; index[1]++) {
double val = index[0] + index[1]*10;
saRet.PutElement(index, &val);
}
}

// Return the safe-array encapsulated in a VARIANT...
return saRet.Detach();
}

PS:: Nick Paldino I learnt you are an expert on interop.
Nov 15 '05 #1
1 1327
Bob,

I'm curious where you heard I am an expert on Interop. I'd have to
thank that person. =)

In order to wrap this function, I think you want to do the following:

[DllImport("dllname.dll")]
[return:MarshalAs(UnmanagedType.Struct)]
public static extern object retVariantArray();

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com
"bob" <am******@myrealbox.com> wrote in message
news:5b**************************@posting.google.c om...
How to wrap the following function using PInvole-

VARIANT _stdcall retVariantArray(void) {
COleSafeArray saRet;
DWORD numElements[] = {10, 10}; // 10x10

// Create the safe-array...
saRet.Create(VT_R8, 2, numElements);

// Initialize it with values...
long index[2];
for(index[0]=0; index[0]<10; index[0]++) {
for(index[1]=0; index[1]<10; index[1]++) {
double val = index[0] + index[1]*10;
saRet.PutElement(index, &val);
}
}

// Return the safe-array encapsulated in a VARIANT...
return saRet.Detach();
}

PS:: Nick Paldino I learnt you are an expert on interop.

Nov 15 '05 #2

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

Similar topics

2
by: nobody | last post by:
1) Does anyone know if the CRC32 algorithm in binascii has a name? There seem to be a TON of different CRC32 methods; different polynomials, different byte orders, different seeds, some flip the...
1
by: Julia | last post by:
Hi I have a domain model and I am looking for the correct design patterns to use, The following is my domain model Server-> the is the thread boundaries,the server create a thread the...
11
by: dcinfinite | last post by:
Hi.. i've posted heaps previously about my IIS not running..i've resorted in formatting my computer..and now the IIS is working..but i have another issue now..is so frustrating.. now..when i...
5
by: john | last post by:
Here is the short story of what i'm trying to do. I have a 4 sided case labeling printer setting out on one of our production lines. Now then i have a vb.net application that sends data to this...
1
by: Nick | last post by:
Well, the project I am working on has now come to a screeching halt! I have been developing a program that heavily utilizes ADO.NET record sets. To generate reports, I convert the recordset to XML,...
10
by: Alejandro Castañaza | last post by:
Hi. I'm writing a program, and I need to send confidential data through the network, so I decided to use encryption, using the System.Security.Cryptography namespace. I'm using the sockets...
14
by: Nick Z. | last post by:
I have a file that I want to read a UTF-16 unicode string from. What is the easiest way to accomplish that? Thanks in advance, Nick Z.
4
by: Nick Weg | last post by:
Hello We have a web application developed in .NET using VB.NET. We get the error below every now and then and can't figure out how to correct it. The viewstate this error refers to is pretty...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
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.