The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: nibbleNbits on November 07, 2011, 05:59:38 PM

Title: windows string pointer
Post by: nibbleNbits on November 07, 2011, 05:59:38 PM
Windows app, visual studio 2010 .NET
does anyone know how to send a System:String^ to a MASM functiion, without first casting the String^ to char*?

thanks for any help
Title: Re: windows string pointer
Post by: ToutEnMasm on November 07, 2011, 06:12:33 PM

It is a c++ class fonction.
Better way is to know what is done,and do the same with your own code.
You can also adapt the class for masm but it"s more difficult.
Title: Re: windows string pointer
Post by: hutch-- on November 08, 2011, 12:47:29 AM
Ron,

Welcome on board, glad to see you got past the signup irritations.

I am not a C++ .NET man but I would be surprised if a system string was not unicode but it will depend on if you can pass its address. I gather you want to be able to use a C++/.NET sourced string and process it in a MASM module and to do that you need its address.

RE: UNICODE, the next version of MASM32 has much more unicode support and it will be available REAL SOON[tm], I am just finishing off the documentation.
Title: Re: windows string pointer
Post by: nibbleNbits on November 08, 2011, 01:41:27 AM
Thanks Hutch

Here is the VS 2010 method of converting char* to System:String^
char* fn=(char*)(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi("some string")).ToPointer();

MS has there own (bloated)String class and have made it a real pain to convert back and forth. It won't allow the pointer notation * instead they came up with their own pointer notation ^ for the system string. This is managed code, so when working with both managed and unmanaged it becomes a problem. Since .asm is unmanaged it won't accept the pointer notation ^.

for example calling a masm function from c++
return char* myasmfunction(double dstuff, int istuff, char* cstuff) works just fine
return String^ myasmfunction(same stuff) doesn't work
return char* myasmfunction(double dstuff, int stuff, String^ sthing) doesn't work, in each case the "^" is the problem

Ron