473,386 Members | 1,799 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,386 software developers and data experts.

Calling a COM Object with a LPWSTR ** param from C#


I wish to call a COM Object which has a parameter of type
LPWSTR ** on a method call from C#

The COM Method :-

STDMETHODIMP CClassType::GetDataInfo(LPWSTR ** ppData)
{
......

return S_OK;
}

How do I create the parameter required within C# in order
to call this COM Method.
I've read quite a few postings on marshalling and the
such, but is there anyone that can explain this in simple
terms or code samples would be good.

I think my main problem is C# knowledge, as I have only
just started using it TIA for even the smallest hint on
how to resolve this problem.
Nov 15 '05 #1
1 2597
I assume the following:
- this is a COM object created in C++ (hence macros like LPWSTR etc)
- you are using VS.Net when compiling c# (if you're not, you can skip to
the last couple of paragraphs)

In VS.Net if it's a COM object, then all you need to do is this:

1. Ensure the COM object is registered (in the registry, with RegSvr32)
2. In your project, you go to the "Solution Explorer", and right click on
"References".
3. select "Add Reference".
4. then you'll have a few tabs, with the current being ".Net", with others,
"COM", and "Projects".
5. Your object should be in the list that is in the COM tab, if it's not,
click on the "Browse" button and locate the DLL/OCX instead.
6. Once you've found it, click "Select" so that the item appears in the list
of "Selected Objects"
7. OK.

Now you'll see that a "MyCOMClass" reference has been added to the
references, you can include this in any class by using the "using" keyword.

What just happened?

Well you got VS.Net to create an interop between the COM object and your
code. This means that your code, running on the .Net Intermediate Language,
is not able to communicate with "unmanaged" C++ code (your C++ COM object
falls into this group). So VS.Net created another DLL, that is a mediator
between the COM object and the IL, so that your .Net project can use it.

Now if you're not using VS.Net, you have to do this manually, but it's
easier that it seems given the .Net framework tools.
I'd recommend reading the MSDN stuff on this:
http://msdn.microsoft.com/library/de...ntTutorial.asp
(beware of line wraps)

Hope that helps and I didn't completely miss the boat.
Dan.
Nov 15 '05 #2

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

Similar topics

6
by: dw | last post by:
Hello all, I'm having a dickens of a time calling a stored procedure on a connection. Every time I do, it generates an error "Arguments are of the wrong type, are out of acceptable range, or are in...
2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
3
by: RC | last post by:
Hi, I have a dll written by vb6. AFunction(ByRef o as Variant) I want to use it in csharp by System.Reflection. Assembly asm = Assembly.LoadFrom("Lib.dll"); Type t =...
2
by: Chris van den Heuvel | last post by:
I am trying to enumerate the users of a system from within my app (VB.NET) Not finding any .Net Framework classes to do this I turned to the Win32 API and NetQueryDisplayInformation. I can't get it...
1
by: Mike D Sutton | last post by:
I'm in the process of porting a bunch of code to C# which for the most part is going well, but just can't seem to get this one to work properly.. Here's the code I'm currently using: *** ...
6
by: ahmad.humyn | last post by:
I want to call a hidden form. My code goes something like in which the main calls form1. form1 has a button which creates & calls form2 and hides itself. Now I have a button in form2 which if...
18
by: Franky | last post by:
I don't know how to ask this so that someone will not misread it but here goes. At run time I want to be able to evaluate functions from the Math library, but at design time I do not know what...
2
by: ph33red | last post by:
Hi, I'm having a problem getting my code to pull the appropriate information when I call for it via URL. (example: http://..../.php?id=2). For some reason I can't get it to pull the information for...
3
by: rep_movsd | last post by:
Hi I have a C++ com object that exposes IStream and IPropertyBag, this is derived from IUnknown, there is no typelib or IDispatch etc I need to write a simple VB.NET app in VB 2003 that can...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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
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
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.