Question

I'm using managed c++ to implement a method that returns a string. I declare the method in my header file using the following signature:

String^ GetWindowText()

However, when I'm using this method from C#, the signature is:

string GetWindowTextW();

How do I get rid of the extra "W" at the end of the method's name?

Was it helpful?

Solution

To get around the preprocessor hackery of the Windows header files, declare it like this:

#undef GetWindowText
String^ GetWindowText()

Note that, if you actually use the Win32 or MFC GetWindowText() routines in your code, you'll need to either redefine the macro or call them as GetWindowTextW().

OTHER TIPS

GetWindowText is a win32 api call that is aliased via a macro to GetWindowTextW in your C++ project.

Try adding #undef GetWindowText to you C++ project.

Not Managed c++ but C++/CLI for the .net platform. A set of Microsoft extensions to C++ for use with their .Net system.

Bjarne Stroustrup's FAQ http://www.research.att.com/~bs/bs_faq.html#CppCLI

C++/CLI is not C++, don't tag it as such. Txs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top