C++ - 컴퓨터의 실제 IP 얻기 (code)

#include <ws2tcpip.h> bool ServerInfoMgr::GetLocalIP( string& strIP ) { char host_name[256]; if (gethostname(host_name, 256) == SOCKET_ERROR) return false; struct addrinfo hints, *res = NULL; char *szRemoteAddress=NULL, *szRemotePort=NULL; int rc; memset( &hints, 0, sizeof(hints) ); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol...
더 읽기

C++ - 함수 핸들러(Funtion Dispatcher) (Code)

온라인 서버 제작자 모임의 핵랑님이 만든 것 비공개 카페라서 링크를 눌러도 멤버가 아니라면 접속할 수 없습니다. #pragma warning(disable:4819) #include <boost/bind.hpp> #include <boost/function.hpp> #include <boost/lambda/lambda.hpp> #pragma warning(default:4819) #include <string> #include <vector> #include <utility> #include <iostream> namespace Dispatcher { template<typename IdentifierT, typename...
더 읽기

C++ - Win32 시스템 정보 얻기(Code)

출처 win32_systemInfo.h #pragma once #include <cstdint> #include <vector> #include <string> #include <memory> #include <rapid/utils/singleton.h> namespace rapid { namespace platform { struct ProcessorInformation { ProcessorInformation() : numaNodeCount(0) , processorCoreCount(0) , logicalProcessorCount(0) , processorL1CacheCount(0) , processorL2CacheCount(0) , processorL3CacheCount(0) , processorPackageCount(0) { }...
더 읽기

C# - tip 모음

System.BitConverter byte에서 short로 변환하기 http://msdn.microsoft.com/ko-kr/library/system.bitconverter.toint16.aspx BitConverter.ToInt16 스트링을 바인트로 변환 //the below code converts byte[] type string type string txt = System.Text.Encoding.GetEncoding("utf-8").GetString(bytes); //using Default Encoding string txt = System.Text.Encoding.Default.GetString(msg2.getData()); 다른 클래스에 있는 const로 정의한 상수를 이용 방법 // 상수는 다음과 같이...
더 읽기

C# - 시스템 프로그래밍

다른 프로세스 실행 System.Diagnostics.Process.Start("실행파일경로\실행파일명.exe",파라메터) System.Diagnostics.Process.Start("cmd.exe 명령어"); 프로세스 종료 System.Diagnostics.Close(); // 프로세스의 리소스를 해재(종료) 시킨다. System.Diagnostics.CloseMainWindow(); // UI가 있는 프로세스에 메시지를 보내 종료 시킨다. System.Diagnostics.Kill(); // 즉시 프로세스를 종료시킨다. 프로세스 실행 후 종료까지 대기 System.Diagnostics.Process p = System.Diagnostics.Process.Start("C:\\test.txt"); p.WaitForExit(); //혹은 시간으로...
더 읽기

C# - SharpZipLib을 사용한 복수 개의 파일 압축 및 해제

SharpZipLib : http://icsharpcode.net/OpenSource/SharpZipLib/Default.aspx // 압축 void Compression() { try { string zipPath = "test.zip"; System.IO.FileStream writer = new System.IO.FileStream( zipPath, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Write); ICSharpCode.SharpZipLib.Zip.ZipOutputStream zos = new ICSharpCode.SharpZipLib.Zip.ZipOutputStream(writer); foreach (string file in DiffFiles) { int Substringindex = textBox2.Text.Length; string f...
더 읽기

C# - Timer

DispatcherTimer 일반 타이머는 메인 스레드가 아닌 다른 스레드를 만들어서 처리 되지만 이것은 실행은 메인 스레드에서 처리 되어 메인 스레드와 동기화가 보장 된다. MSDN의 설명 각 Dispatcher 루프의 맨 위에서 DispatcherTimer가 다시 평가됩니다. 시간 간격이 발생할 때 정확하게 타이머가 실행될지 보장할...
더 읽기

C# - SmtpClient로 메일 보내기

닷넷의 SmtpClient 클래스를 사용하여 메일을 보내는 방법이다. MSDN의 예제는 빠진 부분이 많아서 그걸 사용하면 제대로 되지 않았다. 삽질하다가 구글링으로 알아냈다. 아래 예제는 구글의 Gmail을 사용하는 것으로 했다. Gmail의 주소는 smtp.gmail.com 이다. 포트번호는 587을 사용한다. 구글에서는 465도 사용 할수 있다고 하지만...
더 읽기