鱼C论坛

 找回密码
 立即注册
查看: 1719|回复: 3

Win32汇编语言程序设计,捣鼓老久也没成功。

[复制链接]
发表于 2013-2-15 22:12:50 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 lyoal 于 2013-2-15 22:25 编辑
  1. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  2. ;基础数据定义
  3. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  4.    .386
  5.    .model flat,stdcall
  6.    option casemap:none
  7.    
  8. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  9. ;所需要的include头文件和导入库
  10. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  11. include  windows.inc
  12. include  user32.inc
  13. includelib user32.lib
  14. include  kernel32.inc
  15. includelib kernel32.lib
  16. include  gdi32.inc
  17. includelib gdi32.lib;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  18. ;数据变量
  19. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  20.    .data?
  21. hInstance dd  ?
  22. hWinMain dd  ?   .const
  23. szMinCaption db  '窗口标题',0
  24. szWinClass  db  '窗口类名',0
  25. szMBCaption  db  '错误提示',0
  26. szMBCont1  db  '获取模块句柄失败!',0
  27. szWndCont  db  '这是我写的第一个窗口,请参观一下,呵呵。。。',0
  28. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  29. ;窗口过程
  30. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  31.     local @stPs:PAINTSTRUCT
  32.     local @stRect:RECT
  33.     local @hDc:HDC
  34.    
  35.     mov eax,uMsg
  36.    
  37.     .if  eax == WM_PAINT
  38.       invoke BeginPaint,hWnd,addr @stPs
  39.       mov  @hDc,eax
  40.       
  41.       invoke GetClientRect,hWnd,addr @stRect
  42.       invoke DrawText,@hDc,addr szWndCont,-1,\
  43.         addr @stRect,\
  44.         DT_SINGLELINE or DT_CENTER or DT_VCENTER
  45.         
  46.       invoke EndPaint,hWnd,addr @stPs
  47. ;**********************************************************************
  48.     .elseif eax == WM_CLOSE   ;关闭窗口
  49.       invoke DestroyWindow,hWinMain
  50.       invoke PostQuitMessage,NULL
  51. ;**********************************************************************
  52.     .else
  53.       invoke DefWindowProc,hWnd,uMsg,wParam,lParam
  54.       ret
  55.     .endif
  56. _ProcWinMain endp
  57. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  58. ;主函数,注册窗口,创建窗口,显示窗口,更新窗口,消息循环等
  59. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  60. _WinMain proc
  61.    local @stWndClass:WNDCLASSEX
  62.    local @stMsg:MSG
  63.    
  64.    
  65.    ;获取模块句柄
  66.    invoke GetModuleHandle,NULL
  67.    .if eax
  68.     mov hInstance,eax
  69.    .else
  70.     invoke MessageBox,NULL,offset szMBCont1,offset szMBCaption,MB_OK
  71.    .endif
  72.    
  73.    invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
  74.    xor eax,eax
  75.    
  76. ;**************************************************************************
  77. ;注册窗口类
  78. ;**************************************************************************
  79.    invoke LoadIcon,hInstance,IDI_APPLICATION
  80.    mov  @stWndClass.hIcon,eax
  81.    
  82.    xor eax,eax
  83.    invoke LoadCursor,hInstance,IDC_ARROW
  84.    mov  @stWndClass.hCursor,eax
  85.    
  86.    push hInstance
  87.    pop  @stWndClass.hInstance
  88.    mov  @stWndClass.cbSize,sizeof WNDCLASSEX
  89.    mov  @stWndClass.style,CS_HREDRAW OR CS_VREDRAW
  90.    mov  @stWndClass.lpfnWndProc,offset _ProcWinMain
  91.    mov  @stWndClass.hbrBackground,COLOR_WINDOW + 1
  92.    mov  @stWndClass.lpszClassName,offset szWinClass
  93.    invoke RegisterClassEx,addr @stWndClass
  94.    
  95. ;**********************************************************************
  96. ;建立并显示窗口
  97. ;**********************************************************************
  98.    invoke CreateWindowEx,WS_EX_CLIENTEDGE,\
  99.      offset szWinClass,offset szMinCaption,\
  100.      WS_OVERLAPPEDWINDOW,\
  101.      100,100,300,400,\
  102.      NULL,NULL,hInstance,NULL
  103.    mov  hWinMain,eax
  104.    invoke ShowWindow,hWinMain,SW_SHOWNORMAL
  105.    invoke UpdateWindow,hWinMain
  106.    
  107. ;**********************************************************************
  108. ;消息循环
  109. ;**********************************************************************
  110.    .while TRUE
  111.      invoke GetMessage,addr @stMsg,NULL,0,0
  112.      .break .if eax == 0
  113.      invoke TranslateMessage,addr @stMsg
  114.      invoke DispatchMessage,addr @stMsg
  115.      .endw
  116.      ret_WinMain  endp
  117. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  118. ;入口
  119. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  120. start:
  121.   call _WinMain
  122.   invoke ExitProcess,NULL
  123.   
  124. END start
复制代码

小甲鱼最新课程 -> https://ilovefishc.com
发表于 2013-2-16 11:38:24 | 显示全部楼层

回帖奖励 +1 鱼币

程序结构对着那!怎么运行失败,??
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2013-2-17 12:47:48 | 显示全部楼层
诶    没看出为什么  我技术太差了  我还是多问问别人吧
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2013-3-3 08:36:27 | 显示全部楼层
这么慌张!把窗口过程的函数地址都丢了,_ProcWinMain proc
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-1 11:12

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表