[ create a new paste ] login | about

Link: http://codepad.org/fDEMyIto    [ raw code | output | fork ]

C++, pasted on Sep 29:
#define UNICODE
#define _UNICODE

#include <tchar.h>
#include <windows.h>


class CConsole{
	public:
		//STD_ERROR_HANDLEなら大丈夫
		CConsole():m_hConsole(::GetStdHandle(STD_OUTPUT_HANDLE)){
		}

		virtual ~CConsole(){
			if(m_hConsole!=INVALID_HANDLE_VALUE)::CloseHandle(m_hConsole);
		}

		void Output(){
			TCHAR string[]=_T("Output\n");
			WriteConsole(m_hConsole,string,lstrlen(string),NULL,NULL);
		}

	private:
		HANDLE m_hConsole;
};

class foo{
	public:
	void aaa(){
		CConsole Console;
		Console.Output();
	}
};

int main(){
	HANDLE hStdOutput=NULL;
	DWORD dwWriteByte=0;
	TCHAR szBuffer[256];

	foo ff;
	ff.aaa();

	hStdOutput=GetStdHandle(STD_OUTPUT_HANDLE);

	lstrcpy(szBuffer,_T("Hello World!!!\n"));

	if(!WriteConsole(hStdOutput,szBuffer,lstrlen(szBuffer),&dwWriteByte,NULL)){
		MessageBox(NULL,_T("失敗"),NULL,MB_OK);
	}

	return 0;
}


Output:
1
2
3
4
Line 18: error: tchar.h: No such file or directory
Line 20: error: windows.h: No such file or directory
Line 24: error: 'HANDLE' does not name a type
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: