S
Shawn B.
I need to pass a StringBuilder as a parameter that expects LPWSTR
(SetConsoleTitle).
How do I do this in MC++?
Thanks,
Shawn
(SetConsoleTitle).
How do I do this in MC++?
Thanks,
Shawn
(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.
Thanks for this post, but I'm still left trying to figure out how to pass
the string into the GetConsoleTitle. It won't accept a wchar_t or a String.
Thanks for this post, but I'm still left trying to figure out how to pass
the string into the GetConsoleTitle. It won't accept a wchar_t or a
String.
Upps... sorry I misread your first post...
I recommend:
<code>
#using <mscorlib.dll>
using namespace System;
using namespace System::Text;
using namespace System::Runtime::InteropServices;
[DllImportAttribute("kernel32.dll")]
extern UInt32 GetConsoleTitle(StringBuilder *str, UInt32 nSize);
int _tmain()
{
StringBuilder *sb = new StringBuilder(1000);
GetConsoleTitle(sb, sb->get_Capacity());
Console::WriteLine(sb->ToString());
return 0;
}
</code>
But you can also use:
<code>
#include <windows.h>
#using <mscorlib.dll>
using namespace System;
int _tmain()
{
wchar_t szBuffer[1000];
GetConsoleTitleW(szBuffer, 1000);
String *str = new String(szBuffer);
Console::WriteLine(str);
return 0;
}
</code>