程式語言 - Visual C++ 6.0 - Microsoft Fundation Class (MFC) - Hello, world!



main.cpp

#include <afxwin.h>
  
class CMyApp : public CWinApp {
public:
    BOOL InitInstance() {
        AfxMessageBox("Hello, world!");
        return FALSE;
    }
};
  
CMyApp myApp;

main.mak

TARGET   = main
CPP      = cl.exe
CXXFLAGS = /nologo /MD /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FD /GZ /c
RC       = rc.exe
RCFLAGS  = /l 0x409 /fo "$(TARGET).res" /d "_AFXDLL"
LD       = link.exe
LDFLAGS  = /nologo /subsystem:windows /machine:I386 /out:$(TARGET).exe opengl32.lib glu32.lib gdi32.lib
OBJS     = $(TARGET).obj $(TARGET).res

all:
	if not exist $(TARGET).rc copy NUL $(TARGET).rc
	$(CPP) $(CXXFLAGS) $(TARGET).cpp
	$(RC) $(RCFLAGS) $(TARGET).rc
	$(LD) $(LDFLAGS) $(OBJS)
	$(TARGET)

編譯、執行

$ myx86 nmake -f main.mak

完成