Windows编程(1)-第一个程序
来源:互联网 发布:coc天使升级数据 编辑:程序博客网 时间:2024/05/15 23:44
Code:
/*------------------------------------------------------------------HelloMsg.c -- Displays "Hello, Windows 98!" in a message box (c) Charles Petzold, 1998--------------------------------------------------------------------*/#include <windows.h>int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){MessageBox (NULL, TEXT ("Hello, Windows 98!"), TEXT ("HelloMsg"), 0);return 0 ;}
1. The Head Files
WINDOWS.H is a master include file that include other Windows header files, some of which also include other header files. The most important and most basic of these files are:
- WINDEF.H Basic type definitions
- WINNT.H Type definitions for Unicode support
- WINBASE.H Kernel functions
- WINUSER.H User interface functions
- WINGDI.H Graphics device interface funcitons
The entry point to a Windows program is WinMain, which always appears like this:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
This entry point is documented in /Platform SDK/User Interface Services/Windows/Window Reference/Window Functions. It is declared in WINBASE.H.
The WinMain function is declared as returning an int. The WINAPI identifier is defined in WINDEF.H with the statement:
#define WINAPI __stdcall
This statement specifiles a calling convention that involves how machine code is generated to place function call arguments on the stack. Most Windows function calls are declared as WINAPI. (该语句指定了一个呼叫约定,包括如何生产机械码以在堆栈中防止函数呼叫的参数。许多Windows函数呼叫声明为WINAPI)
The first parameter to WinMain is something called an "instance handle". In windows programming, a handle is simply a number that an application uses to identify something. In this case, the handle uniquely identifies the program. It is required as an argument(参数) to some other Windows function calls.
In early versions of Windows, when you ran the same program concurrently(同时)more than once, you created multiple instances of that program. All instances of the same application shared code and read-only memory(usually resources such as menu and dialog box templates). A program could determine if other instances of itself were running by checking the hPrevInstance parameter. It could then skip certain chores and move same data from the previous instance into its own data area.(同一应用程序的所有instances共享程序和只读内存(通常是例如菜单和对话框模板的资源)。程序通过检查hPrevInstance参数就能够确定自身的其他instance是否正在运行。然后它可以略过一些复杂的工作并从前面的instance将某些数据移到自己的数据区域)
In the 32-bit versions of Windows, this concept has been abandoned. The second parameter to WinMain is always NULL(defined as 0).
The third parameter to WinMain is the command line used to run the program. Some Windows applications use this to load a file into memory when the program is started.
The fourth parameter to WinMain indicates how the program should be initially displayed--either normally or maximized to fill the window, or minimized to be displayed in the task list bar.
- Windows编程(1)-第一个程序
- windows编程第一个程序
- 【Window编程】Step.1 我的第一个Windows程序
- windows编程--第一个WinMain程序
- Windows编程C++之第一个Windows程序
- 第一个Windows程序.
- 第一个Windows程序
- 第一个windows程序
- 第一个Windows程序
- 第一个WINDOWS程序
- 第一个windows程序
- 第一个Windows程序
- 第一个Windows程序
- 第一个Windows程序
- 第一个windows程序
- 第一个windows程序
- 学习C++ Windows 编程(你的第一个Windows程序)
- Windows游戏编程大师技巧(2nd)第一个程序编译错误解决办法
- shell cut命令具体应用
- 信号槽
- 使用Qt创建一个OpenCV工程
- Java原来如此-几种常见的排序--冒泡排序(Bubble Sort)
- MirandaSoft! Arduino Mega 2560: WIZnet以太网插板项目--element14
- Windows编程(1)-第一个程序
- java Excutor 与 blockingQueue 例子
- 图论 欧拉回路
- .net C# 实现点击下载PDF文件(通知浏览器打开下载对话框) 不是直接打开
- 关于win7下project2010打印不正常的问题处理
- Accept-Encoding: gzip, deflate
- loadrunner各种分析图啥含义
- ORA-00020: maximum number of processes (%s) exceeded问题解决过程
- Android柳叶刀之Button之UI交互