* I found out that running this code in the regular IDE instead of Protean makes it work. I guess thats something Rob will have to look into. WriteConsole still isn't working but at least AllocConsole doesnt bomb anymore *
I've been trying to do some Console API work in B+ but the AllocConsole function never succeeds. Is it impossible to create a console window in B+?
; Userlib
.lib "kernel32.dll"
AllocConsole%()
GetStdHandle%(nStdHandle%)
SetConsoleTitle%(lpConsoleTitle$):"SetConsoleTitleA"
SetConsoleTextAttribute%(hConsoleOutput%, wAttributes%)
WriteConsole%(hConsoleOutput%, lpBuffer$, nCharToWrite%, lpCharsWritten%, lpReserved):"WriteConsoleA"
Local hConsoleOut%, hConsoleIn%
Const STD_OUTPUT_HANDLE = -11
Const STD_INPUT_HANDLE = -10
Const INVALID_HANDLE_VALUE = -1
Ret% = AllocConsole()
If Ret% = 0 Then Notify "Console Allocation Failed"
; // Output
hConsoleOut% = GetStdHandle(STD_OUTPUT_HANDLE)
If hConsoleOut% = INVALID_HANDLE_VALUE Then Notify "Unable to get STDOUT"
; // Input
hConsoleIn% = GetStdHandle(STD_INPUT_HANDLE)
If hConsoleIn% = INVALID_HANDLE_VALUE Then Notify "Unable to get STDIN"
SetConsoleTitle "My Console App"
Output$ = "Hello World"
WriteConsole hConsoleOut%, Output$, Len(Output$), 0, 0
If anyone can figure it out or has an explanation as to why it fails, please let me know.
|