>I need to pass a StringBuilder as a parameter that expects LPWSTR
(SetConsoleTitle).
How do I do this in MC++?
Sorry, I got it wrong. I need to pass a StringBuilder to GetConsoleTitle,
and a String __gc* to GetConsoleTitle.
For the GetConsoleTitle API, I'm doing
void Console::set_Caption(String *caption)
{
if (caption->Length < CAPTION_LENGTH)
{
SetConsoleTitle((LPCWSTR)&caption);
}
}
But I'm getting strange unicode character in the Title before it throws an
exception.
For the GetConsoleTitle, I'm doing
String *Console::get_Caption()
{
StringBuilder *caption = new StringBuilder(CAPTION_LENGTH);
return caption->ToString(
0,
(DWORD)GetConsoleTitle((LPWSTR)&caption, CAPTION_LENGTH)
);
}
and nothing happens.
I'm converting code from C#.
So, in effect, I want to know what the proper way to pass the StringBuilder
and the String is to the API calls. I've looked up the platform SDK,
googled for hours, and even got the "Essential Guide to Managed Extensions
for C++" Book and nothing has helped me one iota. I'm terribly rusty with
C++ so that probly isn't helping.
Thanks for you help.
Thanks,
Shawn