/[Sims3RigEditor]/trunk/gr2lib_cpp/guicon.cpp
ViewVC logotype

Contents of /trunk/gr2lib_cpp/guicon.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 55 - (show annotations) (download)
Thu Aug 12 08:37:47 2010 UTC (9 years, 6 months ago) by william
File size: 2577 byte(s)
Fix all, current, c++ compiler warnings and linker errors

1 #define _WIN32_WINNT 0x0501
2 #include "VSDebugOutput.h"
3 #include <windows.h>
4 #include <wincon.h>
5 #include <stdio.h>
6 #include <fcntl.h>
7 #include <io.h>
8 #include <iostream>
9 #include <fstream>
10 #include <assert.h>
11
12 #ifndef _USE_OLD_IOSTREAMS
13 using namespace std;
14 #endif
15
16 int AttachConsole_()
17 {
18 int _AttachConsole = AttachConsole(ATTACH_PARENT_PROCESS);
19 if (!_AttachConsole) return _AttachConsole;
20
21 int hConHandle;
22 long lStdHandle;
23 FILE *fp;
24 // redirect unbuffered STDOUT to the console
25 lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
26 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
27 fp = _fdopen( hConHandle, "w" );
28 *stdout = *fp;
29 setvbuf( stdout, NULL, _IONBF, 0 );
30 // redirect unbuffered STDIN to the console
31 lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
32 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
33 fp = _fdopen( hConHandle, "r" );
34 *stdin = *fp;
35 setvbuf( stdin, NULL, _IONBF, 0 );
36 // redirect unbuffered STDERR to the console
37 lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
38 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
39 fp = _fdopen( hConHandle, "w" );
40 *stderr = *fp;
41 setvbuf( stderr, NULL, _IONBF, 0 );
42 // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog
43 // point to console as well
44 ios::sync_with_stdio();
45 // make output start on next line
46 printf("\n");
47 return _AttachConsole;
48 }
49 int AttachConsole_(int dwProcessId)
50 {
51 int _AttachConsole = AttachConsole(dwProcessId);
52 if (!_AttachConsole) return _AttachConsole;
53
54 int hConHandle;
55 long lStdHandle;
56 FILE *fp;
57 // redirect unbuffered STDOUT to the console
58 lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
59 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
60 fp = _fdopen( hConHandle, "w" );
61 *stdout = *fp;
62 setvbuf( stdout, NULL, _IONBF, 0 );
63 // redirect unbuffered STDIN to the console
64 lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
65 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
66 fp = _fdopen( hConHandle, "r" );
67 *stdin = *fp;
68 setvbuf( stdin, NULL, _IONBF, 0 );
69 // redirect unbuffered STDERR to the console
70 lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
71 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
72 fp = _fdopen( hConHandle, "w" );
73 *stderr = *fp;
74 setvbuf( stderr, NULL, _IONBF, 0 );
75 // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog
76 // point to console as well
77 ios::sync_with_stdio();
78 // make output start on next line
79 printf("\n");
80 return _AttachConsole;
81 }
82 int FreeConsole_()
83 {
84 return FreeConsole();
85 }
86 //#endif
87 //End of File

  ViewVC Help
Powered by ViewVC 1.1.22