08-30-2008, 10:11 AM
Macro
AttachConsole is unavailable on win 2000.
if(!AttachConsole(ATTACH_PARENT_PROCESS)) ErrMsg 1 _s.dllerror ;;note: this fails if the exe is not running from cmd.exe (DOS prompt)
;using C console functions
_cputs "[]Qm exe here.[]" ;;simple string
str s.time("%X")
_cprintf "Now is %s[]" s ;;formatted like out
;using Windows console functions
int hStdout=GetStdHandle(STD_OUTPUT_HANDLE)
SetConsoleTextAttribute hStdout FOREGROUND_GREEN
s.format("Press Enter to continue.[]")
WriteFile hStdout s s.len &_i 0
SetConsoleTextAttribute hStdout FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE ;;white
;if exe launches other threads, it must wait until they'll end
;because if exe ends immediately, it terminates these threads
ARRAY(int) threads
threads[]=mac("Function64") ;;launch second thread
threads[]=mac("Function67") ;;launch third thread
WaitForMultipleObjects threads.len &threads[0] 1 INFINITE
;all threads can use _cprintf etc too
ret 400 ;;exit codeAttachConsole is unavailable on win 2000.
