当前位置: 代码迷 >> 汇编语言 >> 一下汇编创建窗口为什么不成功,该怎么处理
  详细解决方案

一下汇编创建窗口为什么不成功,该怎么处理

热度:8679   发布时间:2013-02-26 00:00:00.0
一下汇编创建窗口为什么不成功
Assembly code
start:main proc;create main window    local hWnd:dword    local pWndClass:WNDCLASSEX,pMsg:MSG        invoke RtlZeroMemory,addr pWndClass,sizeof WNDCLASSEX    invoke GetModuleHandle,m_null    mov hInst,eax    mov pWndClass.hInstance,eax    invoke LoadCursor,0,IDC_ARROW    mov    pWndClass.hCursor,eax    mov pWndClass.cbSize,sizeof WNDCLASSEX    mov    pWndClass.style,CS_HREDRAW or CS_VREDRAW    mov    pWndClass.lpfnWndProc,offset WndProc    mov pWndClass.lpszClassName,offset msz_WndClass    mov    pWndClass.hbrBackground,COLOR_WINDOW + 1    invoke RegisterClassEx,addr pWndClass    invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset msz_WndClass,offset msz_WndTitle,\        WS_OVERLAPPEDWINDOW,100,100,600,400,m_null,m_null,hInst,m_null    cmp eax,0 ;每次执行CreateWindowEx的eax都是0    jz @exitproc    mov hWnd,eax    invoke ShowWindow,hWnd,SW_SHOWNORMAL    invoke UpdateWindow,hWnd@msgloop:    invoke GetMessage,addr pMsg,m_null,m_null,m_null    cmp eax,0    jz @exitproc    invoke TranslateMessage,addr pMsg    invoke DispatchMessage,addr pMsg@exitproc:    invoke ExitProcess,m_nullmain endpend start


------解决方案--------------------------------------------------------
没有头文件吧.
------解决方案--------------------------------------------------------
@msgloop:
invoke GetMessage,addr pMsg,m_null,m_null,m_null
cmp eax,0
jz @exitproc
invoke TranslateMessage,addr pMsg
invoke DispatchMessage,addr pMsg
@exitproc:
没有头文件
你这个没有在进行消息循环,把完整的文件发上来看一下
------解决方案--------------------------------------------------------
试一下吧 

[code=Assembl]start:
main proc;create main window
  local hWnd:dword
  local pWndClass:WNDCLASSEX,pMsg:MSG
 
  invoke RtlZeroMemory,addr pWndClass,sizeof WNDCLASSEX
  invoke GetModuleHandle,m_null
  mov hInst,eax
  mov pWndClass.hInstance,eax
  invoke LoadCursor,0,IDC_ARROW
  mov  pWndClass.hCursor,eax
  mov pWndClass.cbSize,sizeof WNDCLASSEX
  mov  pWndClass.style,CS_HREDRAW or CS_VREDRAW
  mov  pWndClass.lpfnWndProc,offset WndProc
  mov pWndClass.lpszClassName,offset msz_WndClass
  mov  pWndClass.hbrBackground,COLOR_WINDOW + 1
  invoke RegisterClassEx,addr pWndClass
  invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset msz_WndClass,offset msz_WndTitle,\
    WS_OVERLAPPEDWINDOW,100,100,600,400,m_null,m_null,hInst,m_null
  cmp eax,0
  jz @exitproc  ;楼主不妨在此句后invoke MessageBox,如果能弹出来说明不是0
  mov hWnd,eax
  invoke ShowWindow,hWnd,SW_SHOWNORMAL
  invoke UpdateWindow,hWnd
@msgloop:
  invoke GetMessage,addr pMsg,m_null,m_null,m_null
  cmp eax,0
  jz @exitproc
  invoke TranslateMessage,addr pMsg
  invoke DispatchMessage,addr pMsg
  jmp @msgloop  ;关键是这里,消息循环 应该是漏写了吧
@exitproc:
  invoke ExitProcess,m_null
main endp
end start[/code]
------解决方案--------------------------------------------------------
好像没有包含头文件哦
  相关解决方案