关键是
1.包含<Windows.h>及其他的相关头文件
2.在LINK指令中最起码要加上KERNEL32.LIB USER32.LIB GDI32.LIB(不需要制定其路径,因为NMAKE, CL和LINK都来自VS,这3个LIB文件都是默认配置好的),这三个LIB文件包含了所需的其他DLL的信息。当然,不止这三个,但这三个是最基本的,如果还需要其他的,建议可以打开VS创建一个WIN32 project,然后通过Project>Properties>Linker>Input (or Command line)查看还需要哪些其他的LIB文件
补充说明:
摘自下面demo的Makefile
"For more libraries of WINAPI you can create a WIN32 application in VS and inspect the project's linker options.
Select Project>Properties>Linker>Input (or Command line) so you can see all LIB files needed by a WIN32 applicatin.
These 3 LIB files contain names and reference information of the dynamic-link libraries to be bound to the generated exe file."
摘自Programming Windows 5th Edition, by Charles Petzold
"As normal, during the compile stage, the compiler generates an .OBJ (object) file from the C source code file.
During the link stage, the linker combines the .OBJ file with .LIB (library) files to create the .EXE (executable) file.
You can see a list of these library files by selecting Settings from the Project tab and clicking the Link tab. In
particular, you'll notice KERNEL32.LIB, USER32.LIB, and GDI32.LIB. These are "import libraries" for the three
major Windows subsystems. They contain the dynamic-link library names and reference information that is bound
into the .EXE file. Windows uses this information to resolve calls from the program to functions in the
KERNEL32.DLL, USER32.DLL, and GDI32.DLL dynamic-link libraries"
这是一个HELLO WORLD的WIN32 DEMO,点击下载