Hi everyone. I'm trying to start a console from a winforms app, and right on the last line, it says An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll. Additional information: The handle is invalid. Here's the code:
VB.NET
Imports Microsoft.DirectX
PublicClass ConsoleWindow
DeclareFunction AllocConsole Lib"kernel32" () AsBooleanDeclareFunction FreeConsole Lib"kernel32" () AsIntegerDim readline AsStringDim stats AsNew ArrayList
Dim t AsNew Threading.Thread(AddressOf OpenWindow)
Sub Get3DInfo()
stats.Add("Texture Memory: ")
stats.Add(mdx9a.device.AvailableTextureMemory)
stats.Add("Number of lights: ")
stats.Add(mdx9a.device.Lights.Count + 1)
stats.Add("Light details :")
Dim i AsIntegerFor i = 0To mdx9a.device.Lights.Count
stats.Add(vbNewLine & "Light #" & i + 1 & ":" & vbNewLine)
stats.Add(mdx9a.device.Lights(i).ToString)
NextEndSubSub AddLine(ByVal line AsString, OptionalByVal fgcolor As ConsoleColor = ConsoleColor.White)
Dim tempcol As ConsoleColor = Console.ForegroundColor
Console.ForegroundColor = fgcolor
Console.Write(line)
Console.ForegroundColor = tempcol
EndSubSub OpenWindow()
If AllocConsole() = TrueThen
Console.WindowLeft = 0
So how do I create a valid handle?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Kapil Deo MalhotraRank #2,120 · 672 reputationPosted Jun 9, 2010, 2:16 PM EDT
Follow the below link, you might get what you are looking for.
http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/b7a14400-6d72-4fbf-9927-0966f69ef4a2