[原创]几种编程语言写MessageBox
编程园地太冷清。虽然功欲善其事,必先利其器。但是内功不足,器再好也无用。以下几个例子,仅供大家参考学习。请参考masm的注释来理解其他语言
1、Masm的MessageBox
.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.const
szCaption db '提示',0
szText db '第一个Win32程序!',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
start:
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start
; 使用 nmake 或下列命令进行编译和链接:
; ml /c /coff MyFirst.asm
; rc MyFirst.rc
; Link /subsystem:windows MyFirst.obj MyFirst.res
2、C语言的
#include "windows.h"
void main()
{
MessageBox(NULL, "第一个Win32程序", "提示", MB_OK);
}
@cls
@set file=MyFirst
@cl.exe /O1 /c /MD /opt:nowin98 %file%.c
@link.exe /subsystem:windowsuser32.lib /opt:nowin98 /entry:main /FILEALIGN:0x200 %file%.obj
@pause
3、pascal的
program MyFirst;
uses
Windows;
begin
MessageBox(0, '第一个win32程序', '提示', MB_OK);
end.
@cls
@set file=MyFirst
@dcc32 /CG %file%.pas
@pause
4、最后来一个Fasm的
format PE GUI 4.0
entry __start
include 'win32ax.inc'
section '.code' readable executable
__start:
invoke MessageBox, NULL, '第一个Win32程序', '提示', MB_OK
return
section '.idata' data readable writeable import
library user32, 'user32.dll'
include 'api\user32.inc'
@cls
@set file=L1
@fasm.exe %file%.asm %file%.exe
@pause
页:
[1]