1. 최초 커밋

This commit is contained in:
이형구 2021-05-02 15:31:55 +09:00
commit eddba8f209
44 changed files with 4131 additions and 0 deletions

245
.gitignore vendored Normal file
View File

@ -0,0 +1,245 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Xx]64/
[Xx]86/
[Bb]uild/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Un-comment the next line if you do not want to checkin
# your web deploy settings because they may include unencrypted
# passwords
#*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# LightSwitch generated files
GeneratedArtifacts/
ModelManifest.xml
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/
/RealgamBehaviour
/RealgamBehaviour Test
/RealgamSDKWrapper

View File

@ -0,0 +1,47 @@
#include "stdafx.h"
#include "HookProcedure.h"
extern HHOOK g_hHook;
//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
char szPath[MAX_PATH] = {0,};
char *p = NULL;
//------------------------------
//
//------------------------------
TCHAR szCaptureWindowName[] = "MFC_PIDINFO_Training";
HWND hWindowToFind = NULL;
HWND hCurrTopWindowHandle = NULL;
TCHAR szMessage[ 128 ] = { 0, };
if( ( wParam == VK_F12 ) && !( lParam & FLAG_KEYDOWN ) )
{
hWindowToFind = FindWindow( NULL, szCaptureWindowName );
if( hWindowToFind != NULL )
{
// 해당 프로세스에게 메시지를 날린다
SendMessage( hWindowToFind, WM_USER + 10000, (WPARAM)0, (LPARAM)0 );
#if defined( _DEBUG_MODE_ )
MessageBox( NULL, "Send Message","", MB_OK );
#endif
}
else
{
#if defined( _DEBUG_MODE_ )
MessageBox( NULL, "No Found!","", MB_OK );
#endif //
}
}
return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}

View File

@ -0,0 +1,8 @@
#pragma once
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK TempKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK KeyboardProcSendCurrProcessId(int nCode, WPARAM wParam, LPARAM lParam);

View File

@ -0,0 +1,50 @@
// KeyHookForCapture.cpp : DLL 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include "HookProcedure.h"
#include "Utility.h"
// 전역 객체
HINSTANCE g_hInstance = NULL; //
HHOOK g_hHook = NULL; //
// 메인 함수
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved )
{
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
g_hInstance = hinstDLL;
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
//----------------------------------
// 훅 시작
//----------------------------------
DELARE_EXPORT_FUNCTION void HookStart()
{
g_hHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInstance, 0);
}
//----------------------------------
// 훅 끝
//----------------------------------
DELARE_EXPORT_FUNCTION void HookEnd()
{
if( g_hHook )
{
UnhookWindowsHookEx(g_hHook);
g_hHook = NULL;
}
}

View File

@ -0,0 +1,245 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="KeyHookForCapture"
ProjectGUID="{CBAE52E4-75F6-4E3A-AC60-028649CF136A}"
RootNamespace="KeyHookForCapture"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;KEYHOOKFORCAPTURE_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName)_D.dll"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/KeyHookForCapture.pdb"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/KeyHookForCapture.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;KEYHOOKFORCAPTURE_EXPORTS"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/KeyHookForCapture.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\HookProcedure.cpp"
>
</File>
<File
RelativePath=".\KeyHookForCapture.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Utility.cpp"
>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\HookProcedure.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\Utility.h"
>
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,40 @@
========================================================================
동적 연결 라이브러리 : KeyHookForCapture 프로젝트 개요
========================================================================
응용 프로그램 마법사에서 이 KeyHookForCapture DLL을 만들었습니다.
이 파일에는 KeyHookForCapture 응용 프로그램을 구성하는 각각의 파일에
들어 있는 요약 설명이 포함되어 있습니다.
KeyHookForCapture.vcproj
응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다.
해당 파일을 생성한 Visual C++의 버전 정보를 비롯하여
응용 프로그램 마법사에서 선택한 플랫폼, 구성 및
프로젝트 기능에 대한 정보가 들어 있습니다.
KeyHookForCapture.cpp
기본 DLL 소스 파일입니다.
이 DLL은 만들어질 때 기호를 내보내지 않으므로,
빌드될 때 .lib 파일이 생성되지 않습니다.
이 프로젝트가 다른 프로젝트에 종속되게 하려면
해당 DLL에서 기호를 내보내도록 하는 코드를 추가하여
내보내기 라이브러리가 생성되게 하거나,
[프로젝트 속성 페이지] 대화 상자에 있는 [링커] 폴더의 [일반] 속성 페이지에서
[가져오기 라이브러리 무시] 속성을 [예]로 설정합니다.
/////////////////////////////////////////////////////////////////////////////
기타 표준 파일:
StdAfx.h 및 StdAfx.cpp는
KeyHookForCapture.pch라는 이름의 PCH(미리 컴파일된 헤더) 파일과
StdAfx.obj라는 이름의 미리 컴파일된 형식 파일을 빌드하는 데 사용됩니다.
/////////////////////////////////////////////////////////////////////////////
기타 참고:
응용 프로그램 마법사에서 사용하는 "TODO:" 주석은 사용자가 추가하거나 사용자 지정해야 하는
소스 코드 부분을 나타냅니다.
/////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,32 @@
#include "stdafx.h"
#include "Utility.h"
//------------------------------------------
// 인자로 전달된 이름의 프로세스를 찾는다
//------------------------------------------
DWORD FindProcessID( LPCTSTR szProcessName )
{
DWORD dwPID = 0xFFFFFFFF;
HANDLE hSnapShot = INVALID_HANDLE_VALUE;
PROCESSENTRY32 pe;
// Get the snapshot of the system
pe.dwSize = sizeof( PROCESSENTRY32 );
hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPALL, NULL );
// find process
Process32First(hSnapShot, &pe);
do
{
if(!_stricmp(szProcessName, pe.szExeFile))
{
dwPID = pe.th32ProcessID;
break;
}
}
while( Process32Next(hSnapShot, &pe ) );
CloseHandle(hSnapShot);
return dwPID;
}

View File

@ -0,0 +1,7 @@
#pragma once
//------------------------------------------
// 인자로 전달된 이름의 프로세스를 찾는다
//------------------------------------------
DWORD FindProcessID( LPCTSTR szProcessName );

View File

@ -0,0 +1,8 @@
// stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
// KeyHookForCapture.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
#include "stdafx.h"
// TODO: 필요한 추가 헤더는
// 이 파일이 아닌 STDAFX.H에서 참조합니다.

View File

@ -0,0 +1,24 @@
// stdafx.h : 자주 사용하지만 자주 변경되지는 않는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
//
#pragma once
#define WIN32_LEAN_AND_MEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
// Windows 헤더 파일입니다.
#include <windows.h>
// TODO: 프로그램에 필요한 추가 헤더는 여기에서 참조합니다.
#include "tlhelp32.h"
//==========================================
// 상수
//==========================================
#define DELARE_EXPORT_FUNCTION extern "C" __declspec(dllexport)
// 키가 눌렸는지 판단하는 부분의 비트 마스크
#define FLAG_KEYDOWN 0x80000000
//#define _DEBUG_MODE_

38
MFC_PIDINFO_Training.sln Normal file
View File

@ -0,0 +1,38 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MFC_PIDINFO_Training", "MFC_PIDINFO_Training\MFC_PIDINFO_Training.vcproj", "{B2530686-89DF-4608-BBD4-9773B0A90528}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestServer", "TestServer\TestServer.vcproj", "{F41C2C14-83A7-4C8C-8198-559B58F945D1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestClient", "TestClient\TestClient.vcproj", "{D58FB8F1-9532-4706-ABC1-D48956E34B9B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeyHookForCapture", "KeyHookForCapture\KeyHookForCapture.vcproj", "{CBAE52E4-75F6-4E3A-AC60-028649CF136A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B2530686-89DF-4608-BBD4-9773B0A90528}.Debug|Win32.ActiveCfg = Debug|Win32
{B2530686-89DF-4608-BBD4-9773B0A90528}.Debug|Win32.Build.0 = Debug|Win32
{B2530686-89DF-4608-BBD4-9773B0A90528}.Release|Win32.ActiveCfg = Release|Win32
{B2530686-89DF-4608-BBD4-9773B0A90528}.Release|Win32.Build.0 = Release|Win32
{F41C2C14-83A7-4C8C-8198-559B58F945D1}.Debug|Win32.ActiveCfg = Debug|Win32
{F41C2C14-83A7-4C8C-8198-559B58F945D1}.Debug|Win32.Build.0 = Debug|Win32
{F41C2C14-83A7-4C8C-8198-559B58F945D1}.Release|Win32.ActiveCfg = Release|Win32
{F41C2C14-83A7-4C8C-8198-559B58F945D1}.Release|Win32.Build.0 = Release|Win32
{D58FB8F1-9532-4706-ABC1-D48956E34B9B}.Debug|Win32.ActiveCfg = Debug|Win32
{D58FB8F1-9532-4706-ABC1-D48956E34B9B}.Debug|Win32.Build.0 = Debug|Win32
{D58FB8F1-9532-4706-ABC1-D48956E34B9B}.Release|Win32.ActiveCfg = Release|Win32
{D58FB8F1-9532-4706-ABC1-D48956E34B9B}.Release|Win32.Build.0 = Release|Win32
{CBAE52E4-75F6-4E3A-AC60-028649CF136A}.Debug|Win32.ActiveCfg = Debug|Win32
{CBAE52E4-75F6-4E3A-AC60-028649CF136A}.Debug|Win32.Build.0 = Debug|Win32
{CBAE52E4-75F6-4E3A-AC60-028649CF136A}.Release|Win32.ActiveCfg = Release|Win32
{CBAE52E4-75F6-4E3A-AC60-028649CF136A}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,231 @@
#include "stdafx.h"
#include "DefineData.h"
void PID2IMG(DWORD processId)
{
}
bool ClipBoard2IMG(CString filename, HWND DsthWnd, CString *err_msg)
{
static int nCount = 0;
HBITMAP hBit;
int capture_delay = 10;
if(!IsClipboardFormatAvailable(CF_BITMAP))
{
*err_msg = _T("클립보드 존재 오류");
return FALSE;
}
if(!OpenClipboard(DsthWnd))
{
*err_msg = _T("클립보드 오픈 오류");
return FALSE;
}
hBit=(HBITMAP)GetClipboardData(CF_BITMAP);
BITMAP bitmap; // 비트맵(DDB) 구조체
GetObject(hBit, sizeof(BITMAP), &bitmap); // 비트맵(DDB)의 정보를 얻음
BITMAPINFOHEADER bmih; // 비트맵(DIB) 정보 헤더 구조체
ZeroMemory(&bmih, sizeof(BITMAPINFOHEADER));
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = bitmap.bmWidth;
bmih.biHeight = bitmap.bmHeight;
bmih.biPlanes = 1;
bmih.biBitCount = 24; // 24비트 트루컬러
bmih.biCompression = BI_RGB;
HDC hDC = GetDC(GetDesktopWindow());
// 비트맵 싸이즈 정보를 얻음
//GetDIBits(hDC, hBit, 0, bitmap.bmHeight, NULL, (LPBITMAPINFO)&bmih, DIB_RGB_COLORS);
GetDIBits(hDC, hBit, 0, bitmap.bmHeight, NULL, (LPBITMAPINFO)&bmih, DIB_RGB_COLORS);
// 비트맵 데이터를 저장하기 위한 버퍼 마련
LPBYTE lpBits = new BYTE[bmih.biSizeImage];
// 비트맵 데이터를 가져옴
GetDIBits(hDC, hBit, 0, bitmap.bmHeight, lpBits, (LPBITMAPINFO)&bmih, DIB_RGB_COLORS);
ReleaseDC(GetDesktopWindow(), hDC);
// 파일 생성
HANDLE hFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
delete [] lpBits;
return FALSE;
}
BITMAPFILEHEADER bmfh; // 비트맵 파일 헤더 구조체
bmfh.bfType = 'MB'; // 비트맵 파일 인식자
bmfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
bmfh.bfSize = bmfh.bfOffBits + bmih.biSizeImage;
bmfh.bfReserved1 = bmfh.bfReserved2 = 0;
DWORD dwWritten;
WriteFile(hFile, &bmfh, sizeof(BITMAPFILEHEADER), &dwWritten, NULL); // 비트맵파일헤더 저장
WriteFile(hFile, &bmih, sizeof(BITMAPINFOHEADER), &dwWritten, NULL); // 비트맵정보헤더 저장
WriteFile(hFile, lpBits, bmih.biSizeImage, &dwWritten, NULL); // 비트맵데이터 저장
CloseHandle(hFile);
delete [] lpBits;
EmptyClipboard();
CloseClipboard();
return TRUE;
}
void CaptureScreen(LPDIRECT3DDEVICE9 pDevice, D3DDISPLAYMODE mode, char* szFileName)
{
HRESULT hr;
// 캡처한 화면을 옮겨 담을 Surface를 생성한다.
IDirect3DSurface9* surf;
if(FAILED(hr = pDevice->CreateOffscreenPlainSurface(mode.Width, mode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surf, NULL)))
{
return;
}
// GetFrontBufferData()함수를 통해 프레임 버퍼의 내용을 Surface로 가져온다.
if(FAILED(hr = pDevice->GetFrontBufferData(0, surf)))
{
surf->Release();
return;
}
// Surface에 담긴 내용을 BMP포맷으로 변환한다.
hr = D3DXSaveSurfaceToFile(_T("GetFrontBufferData.png"), D3DXIFF_PNG, surf, NULL, NULL);
surf->Release();
return;
}
void CaptureScreen2(LPDIRECT3DDEVICE9 pDevice, D3DDISPLAYMODE mode, char* szFileName)
{
HRESULT hr;
/*if(FAILED(hr=pDevice->CreateOffscreenPlainSurface( mode.Width, mode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM ,&BackSurfaceBuffer, NULL )))
return;*/
IDirect3DSurface9* surf;
if(FAILED(hr = pDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &surf ))){
surf->Release();
return;
}
hr=D3DXSaveSurfaceToFile(_T("GetBackBuffer.png"), D3DXIFF_PNG, surf, NULL, NULL );
surf->Release();
return;
}
void CaptureScreen(LPDIRECT3DDEVICE9 pDevice, D3DDISPLAYMODE mode, HWND hWnd, char* szFileName)
{
if (!pDevice || !szFileName)
return;
DWORD tickStart = GetTickCount();
// There is 2 Methods
// 1. Capture Front Buffer
// 2. Capture Back Buffer (Faster)
bool isBackBuffer = true;
RECT rectWindow = {0};
RECT rectDesktop = {0};
//HWND hwnd = GetWindowHandle(m_dwPid);
GetClientRect(hWnd, &rectWindow);
GetClientRect(GetDesktopWindow(), &rectDesktop);
IDirect3DSurface9* pSurface = NULL;
HRESULT hResult = S_OK;
if (isBackBuffer)
{
hResult = pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pSurface);
}
else
{
/*
For windowed mode, the size of the destination surface
should be the size of the desktop. For full-screen mode,
the size of the destination surface should be the screen size.
*/
bool isFullScreen = true;
int nWidth = isFullScreen ? rectWindow.right - rectWindow.left
: rectDesktop.right - rectDesktop.left;
int nHeight = isFullScreen ? rectWindow.bottom - rectWindow.top
: rectDesktop.bottom - rectDesktop.top;
hResult = pDevice->CreateOffscreenPlainSurface(nWidth, nHeight, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pSurface, NULL);
hResult = pDevice->GetFrontBufferData(0, pSurface);
}
if (pSurface)
{
hResult = D3DXSaveSurfaceToFile(_T("hwnd_GetBackBuffer.png"), D3DXIFF_PNG, pSurface, NULL, &rectWindow);
pSurface->Release();
}
//
// tickDiff = GetTickCount() - tickStart;
}
void CaptureScreen2(LPDIRECT3DDEVICE9 pDevice, D3DDISPLAYMODE mode, HWND hWnd, char* szFileName)
{
if (!pDevice || !szFileName)
return;
DWORD tickStart = GetTickCount();
// There is 2 Methods
// 1. Capture Front Buffer
// 2. Capture Back Buffer (Faster)
bool isBackBuffer = false;
RECT rectWindow = {0};
RECT rectDesktop = {0};
//HWND hwnd = GetWindowHandle(m_dwPid);
GetClientRect(GetDesktopWindow(), &rectWindow);
GetClientRect(GetDesktopWindow(), &rectDesktop);
IDirect3DSurface9* pSurface = NULL;
HRESULT hResult = S_OK;
if (isBackBuffer)
{
hResult = pDevice->GetFrontBufferData(0, pSurface);
}
else
{
/*
For windowed mode, the size of the destination surface
should be the size of the desktop. For full-screen mode,
the size of the destination surface should be the screen size.
*/
bool isFullScreen = false;
int nWidth = isFullScreen ? rectWindow.right - rectWindow.left
: rectDesktop.right - rectDesktop.left;
int nHeight = isFullScreen ? rectWindow.bottom - rectWindow.top
: rectDesktop.bottom - rectDesktop.top;
hResult = pDevice->CreateOffscreenPlainSurface(nWidth, nHeight, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pSurface, NULL);
hResult = pDevice->GetFrontBufferData(0, pSurface);
}
if (pSurface)
{
hResult = D3DXSaveSurfaceToFile(_T("hwnd_GetFrontBufferData.png"), D3DXIFF_PNG, pSurface, NULL, &rectWindow);
pSurface->Release();
}
//
// tickDiff = GetTickCount() - tickStart;
}

View File

@ -0,0 +1,22 @@
#pragma once
#include <d3dx9.h>
#pragma comment(lib,"d3d9.lib")
#pragma comment(lib,"d3dx9.lib")
#define IP_PORT_RELOAD 1
#define SCREEN_RELOAD 2
typedef struct _NETINFO
{
CString IP;
int PORT;
}NETINFO;
void PID2IMG(DWORD processId);
bool ClipBoard2IMG(CString filename, HWND DsthWnd, CString *err_msg);
void CaptureScreen(LPDIRECT3DDEVICE9 pDevice, D3DDISPLAYMODE mode, char* szFileName);
void CaptureScreen2(LPDIRECT3DDEVICE9 pDevice, D3DDISPLAYMODE mode, char* szFileName);
void CaptureScreen(LPDIRECT3DDEVICE9 pDevice, D3DDISPLAYMODE mode, HWND hWnd, char* szFileName);
void CaptureScreen2(LPDIRECT3DDEVICE9 pDevice, D3DDISPLAYMODE mode, HWND hWnd, char* szFileName);

View File

@ -0,0 +1,85 @@
// MFC_PIDINFO_Training.cpp : 응용 프로그램에 대한 클래스 동작을 정의합니다.
//
#include "stdafx.h"
#include "MFC_PIDINFO_Training.h"
#include "MFC_PIDINFO_TrainingDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CMFC_PIDINFO_TrainingApp
BEGIN_MESSAGE_MAP(CMFC_PIDINFO_TrainingApp, CWinAppEx)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CMFC_PIDINFO_TrainingApp 생성
CMFC_PIDINFO_TrainingApp::CMFC_PIDINFO_TrainingApp()
{
// TODO: 여기에 생성 코드를 추가합니다.
// InitInstance에 모든 중요한 초기화 작업을 배치합니다.
}
// 유일한 CMFC_PIDINFO_TrainingApp 개체입니다.
CMFC_PIDINFO_TrainingApp theApp;
// CMFC_PIDINFO_TrainingApp 초기화
BOOL CMFC_PIDINFO_TrainingApp::InitInstance()
{
// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다.
// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
// 이 항목을 설정하십시오.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinAppEx::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 표준 초기화
// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
// 아래에서 필요 없는 특정 초기화
// 루틴을 제거해야 합니다.
// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
// 적절한 내용으로 수정해야 합니다.
SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
CMFC_PIDINFO_TrainingDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 여기에 [확인]을 클릭하여 대화 상자가 없어질 때 처리할
// 코드를 배치합니다.
}
else if (nResponse == IDCANCEL)
{
// TODO: 여기에 [취소]를 클릭하여 대화 상자가 없어질 때 처리할
// 코드를 배치합니다.
}
// 대화 상자가 닫혔으므로 응용 프로그램의 메시지 펌프를 시작하지 않고 응용 프로그램을 끝낼 수 있도록 FALSE를
// 반환합니다.
return FALSE;
}

View File

@ -0,0 +1,32 @@
// MFC_PIDINFO_Training.h : PROJECT_NAME 응용 프로그램에 대한 주 헤더 파일입니다.
//
#pragma once
#ifndef __AFXWIN_H__
#error "PCH에 대해 이 파일을 포함하기 전에 'stdafx.h'를 포함합니다."
#endif
#include "resource.h" // 주 기호입니다.
// CMFC_PIDINFO_TrainingApp:
// 이 클래스의 구현에 대해서는 MFC_PIDINFO_Training.cpp을 참조하십시오.
//
class CMFC_PIDINFO_TrainingApp : public CWinAppEx
{
public:
CMFC_PIDINFO_TrainingApp();
// 재정의입니다.
public:
virtual BOOL InitInstance();
// 구현입니다.
DECLARE_MESSAGE_MAP()
};
extern CMFC_PIDINFO_TrainingApp theApp;

View File

@ -0,0 +1,211 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// 한국어 resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
#ifdef _WIN32
LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
#pragma code_page(949)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)\r\n"
"LANGUAGE 18, 1\r\n"
"#pragma code_page(949)\r\n"
"#include ""res\\MFC_PIDINFO_Training.rc2"" // Microsoft Visual C++ 이외의 다른 도구에서 편집한 리소스입니다.\r\n"
"#include ""l.KOR\\afxres.rc"" // 표준 구성 요소입니다.\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\MFC_PIDINFO_Training.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "MFC_PIDINFO_Training 정보"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,14,14,21,20
LTEXT "MFC_PIDINFO_Training, 버전 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
LTEXT "Copyright (C) 2011",IDC_STATIC,42,26,114,8
DEFPUSHBUTTON "확인",IDOK,113,41,50,14,WS_GROUP
END
IDD_MFC_PIDINFO_TRAINING_DIALOG DIALOGEX 0, 0, 319, 260
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "MFC_PIDINFO_Training"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "확인",IDOK,113,239,35,14
PUSHBUTTON "취소",IDCANCEL,277,239,35,14
LISTBOX IDC_LIST_INFO,7,7,183,232,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP,WS_EX_ACCEPTFILES
EDITTEXT IDC_EDIT_FILEPATH,29,239,82,14,ES_AUTOHSCROLL
LTEXT "경로 : ",IDC_STATIC,7,245,22,8
PUSHBUTTON "갱신",IDC_BUTTON_RELOAD,148,239,35,14
LISTBOX IDC_LIST_VECTOR,190,7,122,232,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP,WS_EX_ACCEPTFILES
PUSHBUTTON "벡터확인",IDC_BUTTON_VECTOR,183,239,35,14
PUSHBUTTON "스크린샷",IDC_BUTTON_PRTSC,218,239,35,14
CONTROL "자동",IDC_CHECK_AUTOPIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,253,243,24,10
END
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "041203b5"
BEGIN
VALUE "CompanyName", "TODO: <회사 이름>"
VALUE "FileDescription", "TODO: <파일 설명>"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "MFC_PIDINFO_Training.exe"
VALUE "LegalCopyright", "TODO: (c) <회사 이름>. All rights reserved."
VALUE "OriginalFilename", "MFC_PIDINFO_Training.exe"
VALUE "ProductName", "TODO: <제품 이름>"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x412, 949
END
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 163
TOPMARGIN, 7
BOTTOMMARGIN, 55
END
IDD_MFC_PIDINFO_TRAINING_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 312
TOPMARGIN, 7
BOTTOMMARGIN, 253
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_ABOUTBOX "MFC_PIDINFO_Training 정보(&A)..."
IDP_SOCKETS_INIT_FAILED "Windows 소켓을 초기화하지 못했습니다."
END
#endif // 한국어 resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
LANGUAGE 18, 1
#pragma code_page(949)
#include "res\MFC_PIDINFO_Training.rc2" // Microsoft Visual C++ 이외의 다른 도구에서 편집한 리소스입니다.
#include "l.KOR\afxres.rc" // 표준 구성 요소입니다.
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,282 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="MFC_PIDINFO_Training"
ProjectGUID="{B2530686-89DF-4608-BBD4-9773B0A90528}"
RootNamespace="MFC_PIDINFO_Training"
Keyword="MFCProj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
ValidateParameters="true"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1042"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName)_D.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
ValidateParameters="true"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG"
MinimalRebuild="false"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1042"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\DefineData.cpp"
>
</File>
<File
RelativePath=".\MFC_PIDINFO_Training.cpp"
>
</File>
<File
RelativePath=".\MFC_PIDINFO_TrainingDlg.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\DefineData.h"
>
</File>
<File
RelativePath=".\MFC_PIDINFO_Training.h"
>
</File>
<File
RelativePath=".\MFC_PIDINFO_TrainingDlg.h"
>
</File>
<File
RelativePath=".\Resource.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\targetver.h"
>
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\res\MFC_PIDINFO_Training.ico"
>
</File>
<File
RelativePath=".\MFC_PIDINFO_Training.rc"
>
</File>
<File
RelativePath=".\res\MFC_PIDINFO_Training.rc2"
>
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
<Global
Name="RESOURCE_FILE"
Value="MFC_PIDINFO_Training.rc"
/>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,675 @@
// MFC_PIDINFO_TrainingDlg.cpp : 구현 파일
//
#include "stdafx.h"
#include "MFC_PIDINFO_Training.h"
#include "MFC_PIDINFO_TrainingDlg.h"
#include "DefineData.h"
#include <iphlpapi.h>
#include <vector>
char* g_mibTCPState[] =
{
"???",
"MIB_TCP_STATE_CLOSED",
"MIB_TCP_STATE_LISTEN",
"MIB_TCP_STATE_SYN_SENT",
"MIB_TCP_STATE_SYN_RCVD",
"MIB_TCP_STATE_ESTAB",
"MIB_TCP_STATE_FIN_WAIT1",
"MIB_TCP_STATE_FIN_WAIT2",
"MIB_TCP_STATE_CLOSE_WAIT",
"MIB_TCP_STATE_CLOSING",
"MIB_TCP_STATE_LAST_ACK",
"MIB_TCP_STATE_TIME_WAIT",
"MIB_TCP_STATE_DELETE_TCB"
};
DWORD (WINAPI *pGetExtendedTcpTable)(
PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved
);
std::vector <NETINFO> m_vNetinfo;
LPDIRECT3D9 g_pD3D = NULL;
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
//#pragma comment(lib, "iphlpapi.lib")
//#pragma comment( lib, "Ws2_32.lib")
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 응용 프로그램 정보에 사용되는 CAboutDlg 대화 상자입니다.
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
// 구현입니다.
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CMFC_PIDINFO_TrainingDlg 대화 상자
CMFC_PIDINFO_TrainingDlg::CMFC_PIDINFO_TrainingDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMFC_PIDINFO_TrainingDlg::IDD, pParent)
, m_szFilePath(_T(""))
, m_dwPid(0)
, m_strIP(_T(""))
, m_bLoadState(FALSE)
, m_nPORT(0)
, m_bScreenAutoCap(FALSE)
, m_D3state(FALSE)
, m_bSnapKeyState(FALSE)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMFC_PIDINFO_TrainingDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST_INFO, m_lbListBox);
DDX_Text(pDX, IDC_EDIT_FILEPATH, m_szFilePath);
DDX_Control(pDX, IDC_LIST_VECTOR, m_lbVector);
DDX_Check(pDX, IDC_CHECK_AUTOPIC, m_bScreenAutoCap);
}
BEGIN_MESSAGE_MAP(CMFC_PIDINFO_TrainingDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, &CMFC_PIDINFO_TrainingDlg::OnBnClickedOk)
ON_WM_DROPFILES()
ON_BN_CLICKED(IDC_BUTTON_RELOAD, &CMFC_PIDINFO_TrainingDlg::OnBnClickedButtonReload)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON_VECTOR, &CMFC_PIDINFO_TrainingDlg::OnBnClickedButtonVector)
ON_BN_CLICKED(IDC_BUTTON_PRTSC, &CMFC_PIDINFO_TrainingDlg::OnBnClickedButtonPrtsc)
ON_BN_CLICKED(IDC_CHECK_AUTOPIC, &CMFC_PIDINFO_TrainingDlg::OnBnClickedCheckAutopic)
ON_WM_DESTROY()
ON_WM_CLIPBOARDUPDATE()
END_MESSAGE_MAP()
// CMFC_PIDINFO_TrainingDlg 메시지 처리기
BOOL CMFC_PIDINFO_TrainingDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 시스템 메뉴에 "정보..." 메뉴 항목을 추가합니다.
// IDM_ABOUTBOX는 시스템 명령 범위에 있어야 합니다.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 이 대화 상자의 아이콘을 설정합니다. 응용 프로그램의 주 창이 대화 상자가 아닐 경우에는
// 프레임워크가 이 작업을 자동으로 수행합니다.
SetIcon(m_hIcon, TRUE); // 큰 아이콘을 설정합니다.
SetIcon(m_hIcon, FALSE); // 작은 아이콘을 설정합니다.
// TODO: 여기에 추가 초기화 작업을 추가합니다.
hDll = LoadLibraryA( DEF_DLL_NAME );
if( hDll == NULL )
{
m_lbListBox.AddString(_T("FAIL! To Load DLL"));
return 0;
}
//MessageBox( "SUCESS! To Load DLL" );
HookStart = ( PFN_HOOKSTART )GetProcAddress(hDll, DEF_HOOKSTART);
HookStop = ( PFN_HOOKSTOP )GetProcAddress(hDll, DEF_HOOKSTOP);
HookStart();
m_lbListBox.AddString(_T("1. 실행파일 드롭"));
m_lbListBox.AddString(_T("2. 확인"));
m_lbListBox.AddString(_T("3. 벡터확인"));
m_lbListBox.AddString(_T("4. 스크린샷 단축키 F12"));
m_lbListBox.AddString(_T("5. 클립보드 캡쳐는 '흐믓.bmp'에 지속적으로 덮어쓰기 됨"));
m_lbListBox.AddString(_T("== 자동 스크린샷 주기 1초 =="));
return TRUE; // 포커스를 컨트롤에 설정하지 않으면 TRUE를 반환합니다.
}
void CMFC_PIDINFO_TrainingDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 대화 상자에 최소화 단추를 추가할 경우 아이콘을 그리려면
// 아래 코드가 필요합니다. 문서/뷰 모델을 사용하는 MFC 응용 프로그램의 경우에는
// 프레임워크에서 이 작업을 자동으로 수행합니다.
void CMFC_PIDINFO_TrainingDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 그리기를 위한 디바이스 컨텍스트
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 클라이언트 사각형에서 아이콘을 가운데에 맞춥니다.
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 아이콘을 그립니다.
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서
// 이 함수를 호출합니다.
HCURSOR CMFC_PIDINFO_TrainingDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CMFC_PIDINFO_TrainingDlg::OnBnClickedOk()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
if(m_szFilePath.IsEmpty())
{
m_lbListBox.AddString(_T("파일을 넣어주세용"));
return;
}
SHELLEXECUTEINFO ShExecInfo;
memset(&ShExecInfo, NULL, sizeof(SHELLEXECUTEINFO));
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.lpFile = m_szFilePath;
ShExecInfo.nShow = SW_SHOW;
BOOL ret = ShellExecuteEx(&ShExecInfo);
if(!ret)
{
m_lbListBox.AddString(_T("열기실패"));
return;
}
m_dwPid = GetProcessId(ShExecInfo.hProcess);
CloseHandle(ShExecInfo.hProcess);
CString add_msg;
add_msg.Format(_T("PID : %ld"), m_dwPid);
m_lbListBox.AddString(add_msg);
}
void CMFC_PIDINFO_TrainingDlg::OnDropFiles(HDROP hDropInfo)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
char FileFath[MAX_PATH];
DragQueryFileA(hDropInfo, 0, FileFath, MAX_PATH);
m_szFilePath = FileFath;
m_lbListBox.AddString(m_szFilePath);
UpdateData(FALSE);
CDialog::OnDropFiles(hDropInfo);
}
BOOL CMFC_PIDINFO_TrainingDlg::initFunctions(void)
{
pGetExtendedTcpTable =
(DWORD (WINAPI *)(PVOID,PDWORD,BOOL,ULONG,TCP_TABLE_CLASS,ULONG))
GetProcAddress(LoadLibraryA("iphlpapi.dll"), "GetExtendedTcpTable");
if(pGetExtendedTcpTable == NULL) return FALSE;
return TRUE;
}
void CMFC_PIDINFO_TrainingDlg::OnBnClickedButtonReload()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_bLoadState = !m_bLoadState;
if(m_bLoadState)
{
m_lbListBox.AddString(_T("갱신시작"));
SetTimer(IP_PORT_RELOAD, 1000, 0);
}
else
{
m_lbListBox.AddString(_T("갱신종료"));
KillTimer(IP_PORT_RELOAD);
}
}
CString CMFC_PIDINFO_TrainingDlg::GetPid2Info(DWORD SrcPid)
{
CString err_msg;
if(!initFunctions()){
err_msg = _T("Needed to have XP SP2, Vista SP1 or Server 2003 SP1 and above");
return err_msg;
}
PVOID pTCPTable = NULL;
DWORD size = 0;
DWORD result = 0;
result = pGetExtendedTcpTable(NULL, &size, true, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0);
while(result == ERROR_INSUFFICIENT_BUFFER){
if(pTCPTable != NULL){
free(pTCPTable);
}
pTCPTable = malloc(size);
result = pGetExtendedTcpTable(pTCPTable, &size, true, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0);
if(result != NO_ERROR){
err_msg.Format(_T("Failed to get TCP Table %s"), GetLastError());
free(pTCPTable);
m_lbListBox.AddString(err_msg);
return err_msg;
}
}
if(result != NO_ERROR){
err_msg.Format(_T("Failed to get size estimation %s"), GetLastError());
m_lbListBox.AddString(err_msg);
return err_msg;
}
for(DWORD i = 0; i < ((PMIB_TCPTABLE_OWNER_MODULE)pTCPTable)->dwNumEntries; i++)
{
MIB_TCPROW_OWNER_MODULE module = ((PMIB_TCPTABLE_OWNER_MODULE)pTCPTable)->table[i];
if(SrcPid == module.dwOwningPid)
{
if(module.dwState != MIB_TCP_STATE_LISTEN)
{
CString t1;
int t2;
BOOL trance;
trance = TRUE;
t1.Format(_T("%d.%d.%d.%d"),
(htonl(module.dwRemoteAddr) >> 24) & 0xFF,
(htonl(module.dwRemoteAddr) >> 16) & 0xFF,
(htonl(module.dwRemoteAddr) >> 8) & 0xFF,
(htonl(module.dwRemoteAddr)) & 0xFF);
t2 = (unsigned int)htons((short)module.dwRemotePort);
for(int i=0; i < (int)m_vNetinfo.size(); i++)
{
if(m_vNetinfo[i].IP == t1 && m_vNetinfo[i].PORT == t2 )
{
trance = FALSE;
}
}
if(trance || m_vNetinfo.size() == 0)
{
NETINFO tinfo;
tinfo.IP = t1;
tinfo.PORT = t2;
m_vNetinfo.push_back(tinfo);
}
CString add_msg;
m_strIP = t1;
m_nPORT = t2;
add_msg.Format(_T("IP : %s / PORT : %d"), m_strIP.GetBuffer(), m_nPORT);
m_lbListBox.AddString(add_msg);
}
}
}
if(pTCPTable != NULL)
{
free(pTCPTable);
}
err_msg.Empty();
return err_msg;
}
void CMFC_PIDINFO_TrainingDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
switch(nIDEvent)
{
case IP_PORT_RELOAD:
{
CString t;
t = GetPid2Info(m_dwPid);
if(!t.IsEmpty())
{
m_lbListBox.AddString(t);
}
break;
}
case SCREEN_RELOAD:
{
HWND hwnd = GetWindowHandle(m_dwPid);
HWND2IMG(hwnd);
break;
}
}
CDialog::OnTimer(nIDEvent);
}
void CMFC_PIDINFO_TrainingDlg::OnBnClickedButtonVector()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_lbVector.ResetContent();
CString ttt;
for(int i=0; i < (int)m_vNetinfo.size(); i++)
{
ttt.Format(_T("IP : %s / PORT : %d"), m_vNetinfo[i].IP.GetBuffer(), m_vNetinfo[i].PORT);
m_lbVector.AddString(ttt);
}
}
HWND CMFC_PIDINFO_TrainingDlg::GetWindowHandle(DWORD processid)
{
HWND tmpHwnd = ::FindWindow(NULL, NULL);
DWORD idProc = 0;
while(tmpHwnd!= NULL)
{
if( ::GetParent(tmpHwnd) == NULL ) // 최상위 핸들인지 체크, 버튼 등도 핸들을 가질 수 있으므로 무시하기 위해
{
GetWindowThreadProcessId( tmpHwnd, &idProc );
if( processid == idProc)
{
return tmpHwnd;
}
}
tmpHwnd = ::GetWindow(tmpHwnd, GW_HWNDNEXT); // 다음 핸들 찾기
}
return tmpHwnd;
}
void CMFC_PIDINFO_TrainingDlg::OnBnClickedButtonPrtsc()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
HWND m_hwnd_f = GetWindowHandle(m_dwPid);
CString add_msg;
add_msg.Format(_T("HWND : %x"), m_hwnd_f);
m_lbListBox.AddString(add_msg);
if(m_hwnd_f == NULL)
{
m_lbListBox.AddString(_T("핸들을 찾지 못하였습니다."));
m_lbListBox.AddString(_T("(창이 완전히 켜진후에 다시 시도 해보세요)"));
return;
}
//캡처누르기
INPUT inp[4];
ZeroMemory(inp, sizeof(inp));
//press the VK_MENU key
inp[0].type = INPUT_KEYBOARD;
inp[0].ki.wVk = VK_MENU;
//press the VK_SNAPSHOT key
inp[1].type = INPUT_KEYBOARD;
inp[1].ki.wVk = VK_SNAPSHOT;
//release the VK_SNAPSHOT key
inp[2] = inp[1];
inp[2].ki.dwFlags |= KEYEVENTF_KEYUP;
//release the VK_MENU key
inp[3] = inp[0];
inp[3].ki.dwFlags |= KEYEVENTF_KEYUP;
//simulate keyboard events and check success of function
SendInput(4, inp, sizeof(INPUT));
AddClipboardFormatListener(GetSafeHwnd());
m_bSnapKeyState = TRUE;
//캡처누르기 끝
static D3DDISPLAYMODE d3ddm;
if(!m_D3state)
{
g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
d3dpp.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hwnd_f,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
//D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE,
&d3dpp, &g_pd3dDevice );
m_D3state = TRUE;
}
CString sizz;
sizz.Format(_T("현재해상도 == W : %d, H : %d"), GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
m_lbListBox.AddString(sizz);
HWND2IMG(m_hwnd_f);
//CaptureScreen(g_pd3dDevice, d3ddm, "함수안에서 작성됨");
//CaptureScreen2(g_pd3dDevice, d3ddm, "함수안에서 작성됨");
//CaptureScreen(g_pd3dDevice, d3ddm, m_hwnd_f, "함수안에서 작성됨");
//CaptureScreen2(g_pd3dDevice, d3ddm, m_hwnd_f, "함수안에서 작성됨");
}
BOOL CMFC_PIDINFO_TrainingDlg::HWND2IMG(HWND DsthWnd)
{
CDC memDC;
CDC *pDC = CDC::FromHandle(::GetDC(DsthWnd));
//CreateOffscreenPlainSurface();
//IDirect3DSurface9
CBitmap MyBitmap, *pOld;
memDC.CreateCompatibleDC(pDC);
CRect rect;
::GetClientRect(DsthWnd, &rect);
CString ttt;
ttt.Format(_T("Width : %d, Height : %d"), rect.Width(), rect.Height());
m_lbListBox.AddString(ttt);
MyBitmap.CreateCompatibleBitmap(pDC, rect.Width(),rect.Height()); // 화면에서 256*256만 가져옵니다.
pOld = memDC.SelectObject(&MyBitmap);
memDC.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
memDC.SelectObject(pOld);
ReleaseDC(&memDC);
CImage image; // Cimage파일을 써서 쉽게 bmp화 시킵니다.
image.Attach(MyBitmap);
CString filename;
CTime filenameset;
filenameset = CTime::GetCurrentTime();
filename = filenameset.Format("%y%m%d%H%M%S");
filename += _T(".png");
image.Save(filename);
return 0;
}
LRESULT CMFC_PIDINFO_TrainingDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
switch( message )
{
case WM_USER+1:
{
OnBnClickedButtonPrtsc();
break;
}
}
return CDialog::WindowProc(message, wParam, lParam);
}
void CMFC_PIDINFO_TrainingDlg::OnBnClickedCheckAutopic()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
UpdateData(TRUE);
if(m_bScreenAutoCap)
{
SetTimer(SCREEN_RELOAD, 1000, 0);
m_lbListBox.AddString(_T("자동스샷 시행"));
}
else
{
KillTimer(SCREEN_RELOAD);
m_lbListBox.AddString(_T("자동스샷 종료"));
}
}
BOOL CMFC_PIDINFO_TrainingDlg::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
return CDialog::Create(lpszTemplateName, pParentWnd);
}
void CMFC_PIDINFO_TrainingDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
if(m_D3state)
{
g_pD3D->Release();
g_pd3dDevice->Release();
}
}
void CMFC_PIDINFO_TrainingDlg::OnClipboardUpdate()
{
// 이 기능을 사용하려면 Windows Vista 이상이 있어야 합니다.
// _WIN32_WINNT 기호는 0x0600보다 크거나 같아야 합니다.
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
if(m_bSnapKeyState)
{
CString filename;
filename = _T("흐믓.bmp");
CString err_msg;
if(!ClipBoard2IMG(filename, NULL, &err_msg))
{
m_lbListBox.AddString(err_msg);
}
}
m_bSnapKeyState = FALSE;
RemoveClipboardFormatListener(GetSafeHwnd());
CDialog::OnClipboardUpdate();
}

View File

@ -0,0 +1,81 @@
// MFC_PIDINFO_TrainingDlg.h : 헤더 파일
//
#pragma once
#include "afxwin.h"
#ifdef _DEBUG
#define DEF_DLL_NAME "KeyHookForCapture_D.dll"
#else
#define DEF_DLL_NAME "KeyHookForCapture.dll"
#endif
#define DEF_HOOKSTART "HookStart"
#define DEF_HOOKSTOP "HookStop"
typedef void (*PFN_HOOKSTART)();
typedef void (*PFN_HOOKSTOP)();
// CMFC_PIDINFO_TrainingDlg 대화 상자
class CMFC_PIDINFO_TrainingDlg : public CDialog
{
// 생성입니다.
public:
CMFC_PIDINFO_TrainingDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
// 대화 상자 데이터입니다.
enum { IDD = IDD_MFC_PIDINFO_TRAINING_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
// 구현입니다.
protected:
HICON m_hIcon;
// 생성된 메시지 맵 함수
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
CListBox m_lbListBox;
CString m_szFilePath;
afx_msg void OnBnClickedOk();
afx_msg void OnDropFiles(HDROP hDropInfo);
DWORD m_dwPid;
BOOL initFunctions(void);
CString m_strIP;
afx_msg void OnBnClickedButtonReload();
CString GetPid2Info(DWORD SrcPid);
BOOL m_bLoadState;
afx_msg void OnTimer(UINT_PTR nIDEvent);
CListBox m_lbVector;
afx_msg void OnBnClickedButtonVector();
int m_nPORT;
HWND GetWindowHandle(DWORD processid);
afx_msg void OnBnClickedButtonPrtsc();
BOOL HWND2IMG(HWND DsthWnd);
BOOL m_bScreenAutoCap;
protected:
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
private:
HINSTANCE hDll; // 훅 프로시져 DLL 핸들
PFN_HOOKSTART HookStart; // 훅 설치 함수 포인터
PFN_HOOKSTOP HookStop; // 훅 제거 함수 포인터
public:
afx_msg void OnBnClickedCheckAutopic();
virtual BOOL Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);
protected:
// virtual void PostNcDestroy();
public:
HWND m_hwnd;
BOOL m_D3state;
afx_msg void OnDestroy();
afx_msg void OnClipboardUpdate();
BOOL m_bSnapKeyState;
};

View File

@ -0,0 +1,96 @@
================================================================================
MFC 라이브러리 : MFC_PIDINFO_Training 프로젝트 개요
===============================================================================
응용 프로그램 마법사에서 이 MFC_PIDINFO_Training 응용 프로그램을
만들었습니다. 이 응용 프로그램은 MFC(Microsoft Foundation Classes)의
기본적인 사용법을 보여 주며 응용 프로그램 작성을 위한 출발점을 제공합니다.
이 파일에는 MFC_PIDINFO_Training 응용 프로그램을 구성하는 각 파일에 대한
요약 설명이 포함되어 있습니다.
MFC_PIDINFO_Training.vcproj
응용 프로그램 마법사를 사용하여 생성된 VC++ 프로젝트의 주 프로젝트 파일입니다.
파일을 생성한 Visual C++ 버전에 대한 정보와
응용 프로그램 마법사를 사용하여 선택한 플랫폼, 구성 및 프로젝트
기능에 대한 정보가 들어 있습니다.
MFC_PIDINFO_Training.h
응용 프로그램의 기본 헤더 파일입니다. 여기에는 다른 프로젝트 관련
헤더(Resource.h 포함)가 들어 있고 CMFC_PIDINFO_TrainingApp 응용 프로그램
클래스를 선언합니다.
MFC_PIDINFO_Training.cpp
응용 프로그램 클래스 CMFC_PIDINFO_TrainingApp이(가) 들어 있는 기본 응용 프로그램
소스 파일입니다.
MFC_PIDINFO_Training.rc
프로그램에서 사용하는 모든 Microsoft Windows 리소스의 목록입니다.
여기에는 RES 하위 디렉터리에 저장된 아이콘, 비트맵 및 커서가
포함됩니다. 이 파일은 Microsoft Visual C++에서
직접 편집할 수 있습니다. 프로젝트 리소스는 1042에 있습니다.
res\MFC_PIDINFO_Training.ico
응용 프로그램의 아이콘으로 사용되는 아이콘 파일입니다. 이 아이콘은
주 리소스 파일인 MFC_PIDINFO_Training.rc에 의해 포함됩니다.
res\MFC_PIDINFO_Training.rc2
이 파일에는 Microsoft Visual C++ 이외의 다른 도구에서 편집한 리소스가
포함되어 있습니다. 리소스 편집기로 편집할 수 없는 모든 리소스는
이 파일에 넣어야 합니다.
/////////////////////////////////////////////////////////////////////////////
응용 프로그램 마법사에서 하나의 대화 상자 클래스가 만들어집니다.
MFC_PIDINFO_TrainingDlg.h, MFC_PIDINFO_TrainingDlg.cpp - 대화 상자
이 파일에는 CMFC_PIDINFO_TrainingDlg 클래스가 들어 있습니다. 이 클래스는
응용 프로그램의 주 대화 상자 동작을 정의합니다. 대화 상자의 템플릿은
Microsoft Visual C++에서 편집할 수 있는 MFC_PIDINFO_Training.rc에 있습니다.
/////////////////////////////////////////////////////////////////////////////
기타 기능:
ActiveX 컨트롤
응용 프로그램에서 ActiveX 컨트롤을 사용할 수 있도록 지원합니다.
Windows 소켓
응용 프로그램에서 TCP/IP 네트워크를 사용한 통신을 지원합니다.
/////////////////////////////////////////////////////////////////////////////
기타 표준 파일:
StdAfx.h, StdAfx.cpp
이 파일은 미리 컴파일된 헤더(PCH) 파일인 MFC_PIDINFO_Training.pch와
미리 컴파일된 형식 파일인 StdAfx.obj를 빌드하는 데 사용됩니다.
Resource.h
새 리소스 ID를 정의하는 표준 헤더 파일입니다.
Microsoft Visual C++에서 이 파일을 읽고 업데이트합니다.
MFC_PIDINFO_Training.manifest
응용 프로그램 매니페스트 파일은 Windows XP에서 특정 버전의 Side-by-Side
어셈블리에 대한 응용 프로그램 종속성을 설명하는 데 사용됩니다. 로더는 이 정보를
사용하여 어셈블리 캐시에서 적절한 어셈블리를 로드하거나 응용 프로그램에서 전용
어셈블리를 로드합니다. 응용 프로그램 매니페스트는 응용 프로그램 실행 파일과 같은
폴더에 설치된 외부 .manifest 파일로 재배포를 위해 포함되거나 리소스의 형태로
실행 파일에 포함될 수 있습니다.
/////////////////////////////////////////////////////////////////////////////
기타 참고:
응용 프로그램 마법사는 "TODO:"를 사용하여 추가하거나 사용자 지정해야 하는
소스 코드 부분을 나타냅니다.
응용 프로그램에서 공유 DLL의 MFC를 사용하는 경우
해당 MFC DLL을 다시 배포해야 합니다. 응용 프로그램의 언어가
운영 체제의 로캘과 다른 경우
지역화된 해당 리소스 MFC90XXX.DLL도 다시 배포해야 합니다.
이 두 가지 항목에 대한 자세한 내용은 MSDN 설명서에서
Visual C++ 응용 프로그램 다시 배포에 대한 단원을 참조하십시오.
/////////////////////////////////////////////////////////////////////////////

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -0,0 +1,13 @@
//
// MFC_PIDINFO_Training.RC2 - Microsoft Visual C++에서 직접 편집하지 않는 리소스
//
#ifdef APSTUDIO_INVOKED
#error 이 파일은 Microsoft Visual C++에서 편집할 수 없습니다.
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// 여기에 수동으로 편집한 리소스를 추가합니다.
/////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,30 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by MFC_PIDINFO_Training.rc
//
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDS_ABOUTBOX 101
#define IDD_MFC_PIDINFO_TRAINING_DIALOG 102
#define IDP_SOCKETS_INIT_FAILED 103
#define IDR_MAINFRAME 128
#define IDC_LIST_INFO 1000
#define IDC_EDIT_FILEPATH 1001
#define IDC_BUTTON_RELOAD 1003
#define IDC_LIST_VECTOR 1004
#define IDC_BUTTON_VECTOR 1005
#define IDC_BUTTON1 1006
#define IDC_BUTTON_PRTSC 1006
#define IDC_CHECK1 1008
#define IDC_CHECK_AUTOPIC 1008
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1009
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -0,0 +1,8 @@
// stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
// MFC_PIDINFO_Training.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
#include "stdafx.h"

View File

@ -0,0 +1,53 @@
// stdafx.h : 자주 사용하지만 자주 변경되지는 않는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
#pragma once
#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 일부 CString 생성자는 명시적으로 선언됩니다.
// MFC의 공통 부분과 무시 가능한 경고 메시지에 대한 숨기기를 해제합니다.
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC 핵심 및 표준 구성 요소입니다.
#include <afxext.h> // MFC 확장입니다.
#include <afxdisp.h> // MFC 자동화 클래스입니다.
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // Internet Explorer 4 공용 컨트롤에 대한 MFC 지원입니다.
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // Windows 공용 컨트롤에 대한 MFC 지원입니다.
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC의 리본 및 컨트롤 막대 지원
#include <afxsock.h> // MFC 소켓 확장
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif

View File

@ -0,0 +1,26 @@
#pragma once
// 다음 매크로는 필요한 최소 플랫폼을 정의합니다. 필요한 최소 플랫폼은
// 응용 프로그램을 실행하는 데 필요한 기능이 포함된 가장 빠른 버전의 Windows, Internet Explorer
// 등입니다. 이 매크로는 지정된 버전 이상의 플랫폼 버전에서 사용 가능한 모든 기능을 활성화해야
// 작동합니다.
// 아래 지정된 플랫폼에 우선하는 플랫폼을 대상으로 하는 경우 다음 정의를 수정하십시오.
// 다른 플랫폼에 사용되는 해당 값의 최신 정보는 MSDN을 참조하십시오.
#ifndef WINVER // 필요한 최소 플랫폼을 Windows Vista로 지정합니다.
#define WINVER 0x0600 // 다른 버전의 Windows에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#ifndef _WIN32_WINNT // 필요한 최소 플랫폼을 Windows Vista로 지정합니다.
#define _WIN32_WINNT 0x0600 // 다른 버전의 Windows에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#ifndef _WIN32_WINDOWS // 필요한 최소 플랫폼을 Windows 98로 지정합니다.
#define _WIN32_WINDOWS 0x0410 // Windows Me 이상에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#ifndef _WIN32_IE // 필요한 최소 플랫폼을 Internet Explorer 7.0으로 지정합니다.
#define _WIN32_IE 0x0700 // 다른 버전의 IE에 맞도록 적합한 값으로 변경해 주십시오.
#endif

View File

@ -0,0 +1,42 @@
// ConnectSocket.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "ConnectSocket.h"
// CConnectSocket
CConnectSocket::CConnectSocket()
{
ServerConnectState = NULL;
}
CConnectSocket::~CConnectSocket()
{
}
// CConnectSocket 멤버 함수
void CConnectSocket::OnClose(int nErrorCode)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
ShutDown();
Close();
ServerConnectState = FALSE;
CSocket::OnClose(nErrorCode);
AfxMessageBox(_T("ERROR: Disconnected from server!"));
//::PostQuitMessage(0);
}
void CConnectSocket::OnReceive(int nErrorCode)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
CSocket::OnReceive(nErrorCode);
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "afxwin.h"
// CConnectSocket 명령 대상입니다.
class CConnectSocket : public CSocket
{
public:
CConnectSocket();
virtual ~CConnectSocket();
virtual void OnClose(int nErrorCode);
virtual void OnReceive(int nErrorCode);
public:
BOOL ServerConnectState;
};

96
TestClient/ReadMe.txt Normal file
View File

@ -0,0 +1,96 @@
================================================================================
MFC 라이브러리 : TestClient 프로젝트 개요
===============================================================================
응용 프로그램 마법사에서 이 TestClient 응용 프로그램을
만들었습니다. 이 응용 프로그램은 MFC(Microsoft Foundation Classes)의
기본적인 사용법을 보여 주며 응용 프로그램 작성을 위한 출발점을 제공합니다.
이 파일에는 TestClient 응용 프로그램을 구성하는 각 파일에 대한
요약 설명이 포함되어 있습니다.
TestClient.vcproj
응용 프로그램 마법사를 사용하여 생성된 VC++ 프로젝트의 주 프로젝트 파일입니다.
파일을 생성한 Visual C++ 버전에 대한 정보와
응용 프로그램 마법사를 사용하여 선택한 플랫폼, 구성 및 프로젝트
기능에 대한 정보가 들어 있습니다.
TestClient.h
응용 프로그램의 기본 헤더 파일입니다. 여기에는 다른 프로젝트 관련
헤더(Resource.h 포함)가 들어 있고 CTestClientApp 응용 프로그램
클래스를 선언합니다.
TestClient.cpp
응용 프로그램 클래스 CTestClientApp이(가) 들어 있는 기본 응용 프로그램
소스 파일입니다.
TestClient.rc
프로그램에서 사용하는 모든 Microsoft Windows 리소스의 목록입니다.
여기에는 RES 하위 디렉터리에 저장된 아이콘, 비트맵 및 커서가
포함됩니다. 이 파일은 Microsoft Visual C++에서
직접 편집할 수 있습니다. 프로젝트 리소스는 1042에 있습니다.
res\TestClient.ico
응용 프로그램의 아이콘으로 사용되는 아이콘 파일입니다. 이 아이콘은
주 리소스 파일인 TestClient.rc에 의해 포함됩니다.
res\TestClient.rc2
이 파일에는 Microsoft Visual C++ 이외의 다른 도구에서 편집한 리소스가
포함되어 있습니다. 리소스 편집기로 편집할 수 없는 모든 리소스는
이 파일에 넣어야 합니다.
/////////////////////////////////////////////////////////////////////////////
응용 프로그램 마법사에서 하나의 대화 상자 클래스가 만들어집니다.
TestClientDlg.h, TestClientDlg.cpp - 대화 상자
이 파일에는 CTestClientDlg 클래스가 들어 있습니다. 이 클래스는
응용 프로그램의 주 대화 상자 동작을 정의합니다. 대화 상자의 템플릿은
Microsoft Visual C++에서 편집할 수 있는 TestClient.rc에 있습니다.
/////////////////////////////////////////////////////////////////////////////
기타 기능:
ActiveX 컨트롤
응용 프로그램에서 ActiveX 컨트롤을 사용할 수 있도록 지원합니다.
Windows 소켓
응용 프로그램에서 TCP/IP 네트워크를 사용한 통신을 지원합니다.
/////////////////////////////////////////////////////////////////////////////
기타 표준 파일:
StdAfx.h, StdAfx.cpp
이 파일은 미리 컴파일된 헤더(PCH) 파일인 TestClient.pch와
미리 컴파일된 형식 파일인 StdAfx.obj를 빌드하는 데 사용됩니다.
Resource.h
새 리소스 ID를 정의하는 표준 헤더 파일입니다.
Microsoft Visual C++에서 이 파일을 읽고 업데이트합니다.
TestClient.manifest
응용 프로그램 매니페스트 파일은 Windows XP에서 특정 버전의 Side-by-Side
어셈블리에 대한 응용 프로그램 종속성을 설명하는 데 사용됩니다. 로더는 이 정보를
사용하여 어셈블리 캐시에서 적절한 어셈블리를 로드하거나 응용 프로그램에서 전용
어셈블리를 로드합니다. 응용 프로그램 매니페스트는 응용 프로그램 실행 파일과 같은
폴더에 설치된 외부 .manifest 파일로 재배포를 위해 포함되거나 리소스의 형태로
실행 파일에 포함될 수 있습니다.
/////////////////////////////////////////////////////////////////////////////
기타 참고:
응용 프로그램 마법사는 "TODO:"를 사용하여 추가하거나 사용자 지정해야 하는
소스 코드 부분을 나타냅니다.
응용 프로그램에서 공유 DLL의 MFC를 사용하는 경우
해당 MFC DLL을 다시 배포해야 합니다. 응용 프로그램의 언어가
운영 체제의 로캘과 다른 경우
지역화된 해당 리소스 MFC90XXX.DLL도 다시 배포해야 합니다.
이 두 가지 항목에 대한 자세한 내용은 MSDN 설명서에서
Visual C++ 응용 프로그램 다시 배포에 대한 단원을 참조하십시오.
/////////////////////////////////////////////////////////////////////////////

85
TestClient/TestClient.cpp Normal file
View File

@ -0,0 +1,85 @@
// TestClient.cpp : 응용 프로그램에 대한 클래스 동작을 정의합니다.
//
#include "stdafx.h"
#include "TestClient.h"
#include "TestClientDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CTestClientApp
BEGIN_MESSAGE_MAP(CTestClientApp, CWinAppEx)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CTestClientApp 생성
CTestClientApp::CTestClientApp()
{
// TODO: 여기에 생성 코드를 추가합니다.
// InitInstance에 모든 중요한 초기화 작업을 배치합니다.
}
// 유일한 CTestClientApp 개체입니다.
CTestClientApp theApp;
// CTestClientApp 초기화
BOOL CTestClientApp::InitInstance()
{
// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다.
// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
// 이 항목을 설정하십시오.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinAppEx::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 표준 초기화
// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
// 아래에서 필요 없는 특정 초기화
// 루틴을 제거해야 합니다.
// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
// 적절한 내용으로 수정해야 합니다.
SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
CTestClientDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 여기에 [확인]을 클릭하여 대화 상자가 없어질 때 처리할
// 코드를 배치합니다.
}
else if (nResponse == IDCANCEL)
{
// TODO: 여기에 [취소]를 클릭하여 대화 상자가 없어질 때 처리할
// 코드를 배치합니다.
}
// 대화 상자가 닫혔으므로 응용 프로그램의 메시지 펌프를 시작하지 않고 응용 프로그램을 끝낼 수 있도록 FALSE를
// 반환합니다.
return FALSE;
}

32
TestClient/TestClient.h Normal file
View File

@ -0,0 +1,32 @@
// TestClient.h : PROJECT_NAME 응용 프로그램에 대한 주 헤더 파일입니다.
//
#pragma once
#ifndef __AFXWIN_H__
#error "PCH에 대해 이 파일을 포함하기 전에 'stdafx.h'를 포함합니다."
#endif
#include "resource.h" // 주 기호입니다.
// CTestClientApp:
// 이 클래스의 구현에 대해서는 TestClient.cpp을 참조하십시오.
//
class CTestClientApp : public CWinAppEx
{
public:
CTestClientApp();
// 재정의입니다.
public:
virtual BOOL InitInstance();
// 구현입니다.
DECLARE_MESSAGE_MAP()
};
extern CTestClientApp theApp;

204
TestClient/TestClient.rc Normal file
View File

@ -0,0 +1,204 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// 한국어 resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
#ifdef _WIN32
LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
#pragma code_page(949)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)\r\n"
"LANGUAGE 18, 1\r\n"
"#pragma code_page(949)\r\n"
"#include ""res\\TestClient.rc2"" // Microsoft Visual C++ 이외의 다른 도구에서 편집한 리소스입니다.\r\n"
"#include ""l.KOR\\afxres.rc"" // 표준 구성 요소입니다.\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\TestClient.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "TestClient 정보"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,14,14,21,20
LTEXT "TestClient, 버전 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
LTEXT "Copyright (C) 2011",IDC_STATIC,42,26,114,8
DEFPUSHBUTTON "확인",IDOK,113,41,50,14,WS_GROUP
END
IDD_TESTCLIENT_DIALOG DIALOGEX 0, 0, 118, 47
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "TestClient"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "확인",IDOK,7,26,50,14
PUSHBUTTON "취소",IDCANCEL,61,26,50,14
EDITTEXT IDC_EDIT_IP,7,7,104,14,ES_AUTOHSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "041203b5"
BEGIN
VALUE "CompanyName", "TODO: <회사 이름>"
VALUE "FileDescription", "TODO: <파일 설명>"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "TestClient.exe"
VALUE "LegalCopyright", "TODO: (c) <회사 이름>. All rights reserved."
VALUE "OriginalFilename", "TestClient.exe"
VALUE "ProductName", "TODO: <제품 이름>"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x412, 949
END
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 163
TOPMARGIN, 7
BOTTOMMARGIN, 55
END
IDD_TESTCLIENT_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 111
TOPMARGIN, 7
BOTTOMMARGIN, 40
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_ABOUTBOX "TestClient 정보(&A)..."
IDP_SOCKETS_INIT_FAILED "Windows 소켓을 초기화하지 못했습니다."
END
#endif // 한국어 resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
LANGUAGE 18, 1
#pragma code_page(949)
#include "res\TestClient.rc2" // Microsoft Visual C++ 이외의 다른 도구에서 편집한 리소스입니다.
#include "l.KOR\afxres.rc" // 표준 구성 요소입니다.
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,281 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="TestClient"
ProjectGUID="{D58FB8F1-9532-4706-ABC1-D48956E34B9B}"
RootNamespace="TestClient"
Keyword="MFCProj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
ValidateParameters="true"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1042"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName)_D.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
ValidateParameters="true"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG"
MinimalRebuild="false"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1042"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\ConnectSocket.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\TestClient.cpp"
>
</File>
<File
RelativePath=".\TestClientDlg.cpp"
>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\ConnectSocket.h"
>
</File>
<File
RelativePath=".\Resource.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\targetver.h"
>
</File>
<File
RelativePath=".\TestClient.h"
>
</File>
<File
RelativePath=".\TestClientDlg.h"
>
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\res\TestClient.ico"
>
</File>
<File
RelativePath=".\TestClient.rc"
>
</File>
<File
RelativePath=".\res\TestClient.rc2"
>
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
<Global
Name="RESOURCE_FILE"
Value="TestClient.rc"
/>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,206 @@
// TestClientDlg.cpp : 구현 파일
//
#include "stdafx.h"
#include "TestClient.h"
#include "TestClientDlg.h"
#include "ConnectSocket.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 응용 프로그램 정보에 사용되는 CAboutDlg 대화 상자입니다.
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
// 구현입니다.
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CTestClientDlg 대화 상자
CTestClientDlg::CTestClientDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestClientDlg::IDD, pParent)
, m_ip(_T(""))
, m_nSocketCnt(0)
//, m_csPtr(NULL)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CTestClientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_IP, m_ip);
}
BEGIN_MESSAGE_MAP(CTestClientDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, &CTestClientDlg::OnBnClickedOk)
ON_WM_DESTROY()
END_MESSAGE_MAP()
// CTestClientDlg 메시지 처리기
BOOL CTestClientDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 시스템 메뉴에 "정보..." 메뉴 항목을 추가합니다.
// IDM_ABOUTBOX는 시스템 명령 범위에 있어야 합니다.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 이 대화 상자의 아이콘을 설정합니다. 응용 프로그램의 주 창이 대화 상자가 아닐 경우에는
// 프레임워크가 이 작업을 자동으로 수행합니다.
SetIcon(m_hIcon, TRUE); // 큰 아이콘을 설정합니다.
SetIcon(m_hIcon, FALSE); // 작은 아이콘을 설정합니다.
// TODO: 여기에 추가 초기화 작업을 추가합니다.
return TRUE; // 포커스를 컨트롤에 설정하지 않으면 TRUE를 반환합니다.
}
void CTestClientDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 대화 상자에 최소화 단추를 추가할 경우 아이콘을 그리려면
// 아래 코드가 필요합니다. 문서/뷰 모델을 사용하는 MFC 응용 프로그램의 경우에는
// 프레임워크에서 이 작업을 자동으로 수행합니다.
void CTestClientDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 그리기를 위한 디바이스 컨텍스트
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 클라이언트 사각형에서 아이콘을 가운데에 맞춥니다.
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 아이콘을 그립니다.
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서
// 이 함수를 호출합니다.
HCURSOR CTestClientDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CTestClientDlg::OnBnClickedOk()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
UpdateData(TRUE);
if(m_ip.IsEmpty())
{
AfxMessageBox(_T("아이피 입력하쇼"));
return;
}
if(m_nSocketCnt >= 100)
{
AfxMessageBox(_T("더는 접속 못함"));
return;
}
m_csPtr[m_nSocketCnt] = new CConnectSocket();
m_csPtr[m_nSocketCnt]->Create();
if(m_csPtr[m_nSocketCnt]->Connect(m_ip, 19999) == FALSE)
{
AfxMessageBox(_T("ERROR: Failed to connect server"));
m_csPtr[m_nSocketCnt]->ServerConnectState = FALSE;
m_nSocketCnt++;
OnOK();
}
else
{
AfxMessageBox(_T("Success to connect server"));
m_csPtr[m_nSocketCnt]->ServerConnectState = TRUE;
}
m_nSocketCnt++;
//OnOK();
}
void CTestClientDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
}

View File

@ -0,0 +1,40 @@
// TestClientDlg.h : 헤더 파일
//
#pragma once
#include "connectsocket.h"
// CTestClientDlg 대화 상자
class CTestClientDlg : public CDialog
{
// 생성입니다.
public:
CTestClientDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
// 대화 상자 데이터입니다.
enum { IDD = IDD_TESTCLIENT_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
// 구현입니다.
protected:
HICON m_hIcon;
// 생성된 메시지 맵 함수
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedOk();
CConnectSocket m_CConnectSocket;
CString m_ip;
int m_nSocketCnt;
CConnectSocket *m_csPtr[100];
afx_msg void OnDestroy();
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -0,0 +1,13 @@
//
// TestClient.RC2 - Microsoft Visual C++에서 직접 편집하지 않는 리소스
//
#ifdef APSTUDIO_INVOKED
#error 이 파일은 Microsoft Visual C++에서 편집할 수 없습니다.
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// 여기에 수동으로 편집한 리소스를 추가합니다.
/////////////////////////////////////////////////////////////////////////////

23
TestClient/resource.h Normal file
View File

@ -0,0 +1,23 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by TestClient.rc
//
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDS_ABOUTBOX 101
#define IDD_TESTCLIENT_DIALOG 102
#define IDP_SOCKETS_INIT_FAILED 103
#define IDR_MAINFRAME 128
#define IDC_EDIT1 1000
#define IDC_EDIT_IP 1000
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

8
TestClient/stdafx.cpp Normal file
View File

@ -0,0 +1,8 @@
// stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
// TestClient.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
#include "stdafx.h"

61
TestClient/stdafx.h Normal file
View File

@ -0,0 +1,61 @@
// stdafx.h : 자주 사용하지만 자주 변경되지는 않는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
#pragma once
#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 일부 CString 생성자는 명시적으로 선언됩니다.
// MFC의 공통 부분과 무시 가능한 경고 메시지에 대한 숨기기를 해제합니다.
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC 핵심 및 표준 구성 요소입니다.
#include <afxext.h> // MFC 확장입니다.
#include <afxdisp.h> // MFC 자동화 클래스입니다.
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // Internet Explorer 4 공용 컨트롤에 대한 MFC 지원입니다.
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // Windows 공용 컨트롤에 대한 MFC 지원입니다.
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC의 리본 및 컨트롤 막대 지원
#include <afxsock.h> // MFC 소켓 확장
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif

26
TestClient/targetver.h Normal file
View File

@ -0,0 +1,26 @@
#pragma once
// 다음 매크로는 필요한 최소 플랫폼을 정의합니다. 필요한 최소 플랫폼은
// 응용 프로그램을 실행하는 데 필요한 기능이 포함된 가장 빠른 버전의 Windows, Internet Explorer
// 등입니다. 이 매크로는 지정된 버전 이상의 플랫폼 버전에서 사용 가능한 모든 기능을 활성화해야
// 작동합니다.
// 아래 지정된 플랫폼에 우선하는 플랫폼을 대상으로 하는 경우 다음 정의를 수정하십시오.
// 다른 플랫폼에 사용되는 해당 값의 최신 정보는 MSDN을 참조하십시오.
#ifndef WINVER // 필요한 최소 플랫폼을 Windows Vista로 지정합니다.
#define WINVER 0x0600 // 다른 버전의 Windows에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#ifndef _WIN32_WINNT // 필요한 최소 플랫폼을 Windows Vista로 지정합니다.
#define _WIN32_WINNT 0x0600 // 다른 버전의 Windows에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#ifndef _WIN32_WINDOWS // 필요한 최소 플랫폼을 Windows 98로 지정합니다.
#define _WIN32_WINDOWS 0x0410 // Windows Me 이상에 맞도록 적합한 값으로 변경해 주십시오.
#endif
#ifndef _WIN32_IE // 필요한 최소 플랫폼을 Internet Explorer 7.0으로 지정합니다.
#define _WIN32_IE 0x0700 // 다른 버전의 IE에 맞도록 적합한 값으로 변경해 주십시오.
#endif

217
TestServer/TestServer.cpp Normal file
View File

@ -0,0 +1,217 @@
#include <stdio.h>
#include <winsock2.h>
#define BUFSIZE 100
#pragma comment(lib, "ws2_32.lib")
int main(int argc, char** argv){
WSADATA wsaData;
SOCKET hServSock;
SOCKADDR_IN servAddr;
int arrIndex;
int clntLen;
SOCKET hClntSock;
SOCKADDR_IN clntAddr;
fd_set reads, tmps;
char message[BUFSIZE];
int strLen;
TIMEVAL timeout;
if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
fputs("WSADStartup() error", stderr);
hServSock = socket(PF_INET, SOCK_STREAM, 0);
if(hServSock == INVALID_SOCKET)
fputs("socket() error", stderr);
argv[1] = "19999";
memset(&servAddr, 0, sizeof(servAddr));
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
servAddr.sin_port = htons(atoi(argv[1]));
servAddr.sin_family = AF_INET;
if(bind(hServSock, (SOCKADDR*)&servAddr, sizeof(servAddr)) == SOCKET_ERROR)
fputs("bind() error", stderr);
if(listen(hServSock, 5) == SOCKET_ERROR)
fputs("listen() error", stderr);
FD_ZERO(&reads);
FD_SET(hServSock, &reads); //hServSock을 통해 들어오는 것인지 확인
while(1){
tmps = reads;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
//대기하고 있다가 변화가 있으면 리턴
if(select(0, &tmps, 0, 0, &timeout) == SOCKET_ERROR)
fputs("select() error", stderr);
//모든 소켓 핸들을 순회.
for(arrIndex = 0; arrIndex < (int)reads.fd_count; arrIndex++){
if(FD_ISSET(reads.fd_array[arrIndex], &tmps)){
//연결 요청인 경우
if(tmps.fd_array[arrIndex] == hServSock){
clntLen = sizeof(clntAddr);
hClntSock = accept(hServSock, (SOCKADDR*)&clntAddr, &clntLen);
//연결이된 클라이언트를 FD_SET에 추가.
FD_SET(hClntSock, &reads);
printf("클라이언트 연결 : 소켓 핸들 %d \n", hClntSock);
}else{ //전송된 데이터가 존재하는 경우. 종료 요청 혹은 데이터 수신.
strLen = recv(tmps.fd_array[arrIndex], message, BUFSIZE-1, 0);
if(strLen == 0){ //종료 요청의 경우.
FD_CLR(tmps.fd_array[arrIndex], &reads);
closesocket(tmps.fd_array[arrIndex]);
printf("클라이언트 종료 : 소켓 핸들 %d \n", tmps.fd_array[arrIndex]);
}else{ //데이터 수신의 경우.
send(tmps.fd_array[arrIndex], message, strLen, 0);
} //else
} //else
} //if
} //for
} //while
WSACleanup();
return 0;
} //main
//#include <stdio.h>
//#include <string.h>
//#include <WinSock2.h>
//
//#pragma comment(lib, "ws2_32.lib")
//
//#define BUFSIZE 100
//
//void ErrorHandling(char *message);
//
//int main(int argc, char **argv)
//{
// WSADATA wsaData;
// SOCKET hServSock;
// SOCKADDR_IN servAddr;
//
// int arrIndex;
// int clntLen;
// SOCKET hClntSock;
// SOCKADDR_IN clntAddr;
//
// fd_set reads, temps;
//
// char message[BUFSIZE];
// int strLen;
// TIMEVAL timeout;
//
// /*if(argc != 2)
// {
// exit(1);
// }*/
//
// if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
// ErrorHandling("e");
//
// hServSock = socket(PF_INET, SOCK_STREAM, 0);
//
// if(hServSock == INVALID_SOCKET)
// ErrorHandling("e");
//
// servAddr.sin_family = AF_INET;
// servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
// servAddr.sin_port = 19999;
//
// if(bind(hServSock, (SOCKADDR*)&servAddr, sizeof(servAddr))==SOCKET_ERROR)
// ErrorHandling("e");
//
// if(listen(hServSock, 5)==SOCKET_ERROR)
// ErrorHandling("e");
//
// FD_ZERO(&reads);
// FD_SET(hServSock, &reads);
//
// printf("-1\n");
//
// while(1)
// {
// temps = reads;
// timeout.tv_sec = 5;
// timeout.tv_usec = 0;
//
// if(select(0, &temps, 0, 0, &timeout) == SOCKET_ERROR)
// ErrorHandling("e");
//
// for(arrIndex=0; arrIndex < reads.fd_count; arrIndex++)
// {
// printf("1\n");
// if(FD_ISSET(reads.fd_array[arrIndex], &temps))
// {
// printf("2\n");
// if(reads.fd_array[arrIndex]==hServSock)
// {
// clntLen = sizeof(clntAddr);
// hClntSock = accept(hServSock, (SOCKADDR*)&clntAddr, &clntLen);
// FD_SET(hClntSock, &reads);
// printf("클라이언트 연결 : 소켓 핸들 %d \n", hClntSock);
// }
// else
// {
// strLen = recv(reads.fd_array[arrIndex], message, BUFSIZE-1, 0);
// if(strLen == 0)
// {
// closesocket(temps.fd_array[arrIndex]);
// //printf("클라이언트 종료 : 소켓 핸들 %d \n", reads.fd_array[arrIndex]);
// printf("클라이언트 종료 : 소켓 핸들\n");
// FD_CLR(reads.fd_array[arrIndex], &reads);
//
// }
// else
// {
// send(reads.fd_array[arrIndex], message, strLen, 0);
// }
// }
// }
// }
// }
// WSACleanup();
// return 0;
//}
//
//void ErrorHandling(char *message)
//{
// fputs(message, stderr);
// fputc('\n', stderr);
// exit(1);
//}

View File

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="TestServer"
ProjectGUID="{F41C2C14-83A7-4C8C-8198-559B58F945D1}"
RootNamespace="TestServer"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName)_D.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\TestServer.cpp"
>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>