tags:

views:

39

answers:

1

hi,
I'm trying to port a C++.NET (managed extensions) application to C++/CLI. However I'm not very strong with the syntax yet.

What I'm trying to do is to create a wrapper for a C Dll file.

To do this I'm using DllImport but I failed to found documentation on it's use. There are some problems due to changes of the syntax but I couldn't find out why yet.

The C++.NET line looks like this:

[DllImport("my.dll", CharSet = Ansi,  CallingConvention = Cdecl, EntryPoint = "#10")]
 static MY_STATUS CPPInit(MY_HANDLE *pLmxHandle);

The idea is to pass a reference of MY_HANDLE to the function which initializes it. One problem is that the keywords Ansi and Cdecl are unknown. I expect I need to put some class infront of them but it's a little hard without docs or samples.

The other thing I have is a function which returns a static string:

char *MyFunc();

Can I assume that it can be mapped to String^?

Thanks in advance.

A: 

hi, thanks for the comment.

I thought to myself that I need to build a mixedmode library in order to avoid p/invoke. This just takes some time though.

Actually I solved the compile error in another way. Although I havn't tested it yet because I'm facing some 32/64 bit issues which I can't solve because of other bugs in Whidbey beta2.

My solution was to write the protype in the following way:

interior_ptr<MY_HANDLE> pMyHandle;

From what I understood it should give the function a reference (hence an address) to the dll function. Once I get to try it out I will see if my idea works.
Otherwise I will go for the following option (which i've been offered):

[Out] IntPtr p_MyHandle

Anyway I think the problem is solved because one of those should work.

yishai