쉽게 이야기해서.. API란 Windows 에서 기본적으로 지원하는 내장 함수를 일컫습니다. 이건 C 기반으로 이루어져 있습니다. MFC는 Microsoft Foundation Class 의 약자로 C++ 기반의 class를 정의해 놓은 것입니다. 즉, API를 사용하여 C++ 로 Windows 기반 프로그램을 개발할 수 있도록 class들을 미리 정의하여 놓은 것입니다. 참고르 mfc 의 모든 라이브러리는 api로 구현되었습니다
또 다른 내용입니다.
API는 써보고 느끼셨듯이 윈도우 프로그래밍을 위한 함수 집합입니다.
정확한 명칭은 Windows API이고, 사실 API라는 것은 단순히 '응용 프로그래머를 위한 인터페이스'로
아주 광범위한 것입니다. Windows API를 그냥 API라고 하는 것은 사실 틀린 말이지만, 대부분 MS Window를 쓰는 환경에서 API는 그저 Window API이기 때문에 소위 '태클'이 걸리지 않는 것입니다.
MFC는 API가 너무 복잡하고(MFC가 만들어질 당시의 생각에서), API로 하려면 사소한 작업을 일일이, 그것도 엄청나게 많은 코드를 직접해야 한다는 점에서, 윈도우 개발을 쉽게 할 수 있도록 하기 위해(그리고 C++의 클래스/객체/OOP의 장점도 적극 수용하면서) 만들어진 것입니다.
따라서 MFC는 API의 Wapper 클래스 이면서, API 아래에 붙어있는 것입니다.
좀더 쉽게, MFC는 API로 만든 것이고, MFC의 존재가 가장 특징적으로 드러나는 것은 스튜디오에서 '위자드'입니다. 뻥을 섞어서 위자드를 만들려고 MFC는 시작되었다고도 할 수 있습니다.^^;;
요즘은 MFC가 버전업이 되면서, 기존의 MFC VS API전쟁(지식N에 올라오는 백만년전 답변들) 과 같은 것은 할 필요가 없고, 각각의 장/단점이 뚜렷해지면서 API와 MFC가 혼용되어 사용되고 있습니다.
MFC의 함수는 원칙적으로 API와 완전히 동일합니다. 다른 점은 단 하나, 대부분의 API에서 첫번째 인자로 오게되는 HINSTANCE 또는 HWND가 없다는 것 뿐입니다.
MFC가 어렵다면, 그것은 코드가 아닌 구조에 있을 겁니다.
아래는 틈틈히 봐야할 자료입니다.
제가 영어는 완전 못하는데, 영어는 꼭 필요한 것이기 때문에, 항상 영어로 된 자료를 보려고 노력하고 있습니다. ^0^
Too many people come on to IRC and ask "What is better, MFC or API?" and too many people are willing to say "MFC sucks" or "API sucks" either because of traumatic events involving one or the other in early childhood, or because everyone else is saying it.
The standard arguments are:
- API is too hard - MFC is too confusing - API is too much code - MFC is bloated(비대한) - API doesn't have wizards - MFC is badly designed - API isn't Object Oriented - MFC kicked my dog - API stole my girlfriend And so on...
My Answer My opinion, although by no means the only one, is that you should use the right framework for the right job.
Introduction I was interested to have a tool such as Spy++ in Microsoft Visual Studio, but I'd like that the tool can modify window controls. For instance, some times, we need to enable some inactive controls in a program during run-time. MS Spy++ does not have any facilities to do this, and so I made it by myself.
This program is useful to obtain a window handle, caption, class name, style, and size. Moreover, it facilitates changing caption name, style, and extended style of victim window control in run-time load.
The application is a Win32 project without using MFC. It hooks the target window by WindowFromPoint() user32 API. There is an algorithm to seek on child and parent window to capture child windows inside a program by using GetWindowRect() and GetWindow() in a tricky way. It applies GetWindowLong() to obtain window properties and SetWindowLong() to modify them.
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Threading; public partial class Check_Net : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { btnDown.Visible = false; btnGo.Visible = false; Version clrVersion = Request.Browser.ClrVersion; Version requiredVersion = new Version(1, 1, 4322, 0);
if (clrVersion.Major == 0) { // 클라이언트 PC에 닷넷 프레임워크가 검출되지 않음. Label1.Text = "You haven't installed .NET framework 2.0 yet!!"; // 닷넷 프레임워크 설치 패키지를 다운로드 하는 페이지로 Transfer 혹은 Redirect 한다. btnDown.Visible = true; }
else {
// 클라이언트 PC에서 닷넷 프레임워크가 검출됨. // clrVersion 변수가 버전을 나타내고 있음. // 필요하다면 요구되는 버전 이상이 설치되었는가 검사할 수도 있다. if (clrVersion <= requiredVersion) { // 1.1 버전보다 낮은 버전이 설치되어 있다. 알맞는 처리를 수행하면 된다. Label1.Text = "You have installed .Net framework 1.1. You need to upgrade"; btnDown.Visible = true; } else { Label1.Text = "You already have installed .Net framework 2.0."; btnGo.Visible = true; } } }
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {