xijiangyue0824 发表于 2014-4-21 17:50:15

新手求解 错误代码A2206 A2114

.386
.model flat,stdcall
option casemap:none

includewindows.inc
includegdi32.inc
includelib gdi32.lib
includeuser32.inc
includelib user32.lib
includekernel32.inc
includelib kernel32.lib
includeshell32.inc
includelib shell32.lib
IDM_MAIN equ 0x4000
IDA_MAIN equ 0x4200
IDM_CLOSE equ 0x4201
.data?
hInstance dd ?
hWinMain dd ?
hMenudd ?
szBuffer dd 512 dup(?)
.const
szClassName db 'MyClass',0
szCaptionMain db '接受程序',0
szReceive db 'receive说 接受到WM_SETTEXT消息',0dh,0ah
db 'receive说param的内容是%08x',0dh,0ah
db 'receive说 指向的字符串是"%s"',0dh,0ah,0
szButton db 'button',0
szButtonText db '点击此处打开qq',0
szOpendb 'open',0
szURLdb '"D:\Program Files\Tencent\qq\Bin\QQ.exe"'
szCaption db '菜单选择',0
szFormat db '你选择了菜单命令:%08x',0
.code
;窗口过程
_ProcWinMain proc uses ebx edi esi,hWnd,uMsg,wParam,lParam
mov eax,uMsg
.if eax==WM_CLOSE
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
.elseif eax==WM_SETTEXT
invoke wsprintf,addr szBuffer,addr szReceive,lParam,lParam
invoke MessageBox,hWnd,offset szBuffer,addr szCaptionMain,MB_OK
.elseif eax==WM_COMMAND
mov eax,wParam
.if ax==IDOK
invoke ShellExecute,NULL,offset szOpen,offset szURL,NULL,NULL,SW_SHOWNORMAL
.endif
.elseif eax==WM_CREATE
invoke CreateWindowEx,NULL,offset szButton,offset szButtonText,WS_CHILD or WS_VISIBLE,10,10,200,50,hWnd,1,hInstance,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
_ProcWinMain endp

_WinMain proc

local @stWndClass:WNDCLASSEX
local @stMsg:MSG
local @hAccelerator

invoke GetModuleHandle,NULL
mov hInstance,eax
invoke LoadMenu,hInstance,IDM_MAIN
mov hMenu,eax
invoke LoadAccelerators,hInstance,IDA_MAIN
mov @hAccelerator,eax
invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
;注册窗口类
invoke LoadCursor,0,IDC_ARROW
mov @stWndClass.hCursor,eax
push hInstance
pop @stWndClass.hInstance
mov @stWndClass.cbSize,sizeof WNDCLASSEX
mov @stWndClass.style,CS_HREDRAW or CS_VREDRAW
mov @stWndClass.lpfnWndProc,offset _ProcWinMain
mov @stWndClass.hbrBackground,COLOR_WINDOW+1
mov @stWndClass.lpszClassName,offset szClassName
invoke RegisterClassEx,addr @stWndClass
;建立并显示窗口
invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szCaptionMain,\
WS_OVERLAPPEDWINDOW,\
100,100,600,400,\
NULL,hMenu,hInstance,NULL
mov hWinMain,eax
invoke ShowWindow,hWinMain,SW_SHOWNORMAL
invoke UpdateWindow,hWinMain
;消息循环
.while TRUE
invokeGetMessage,addr @stMsg,NULL,0,0
.break .if eax==0
invoke TranslateMessage,addr @stMsg
invoke DispatchMessage,addr @stMsg
.endw
ret
_WinMain endp
start:   
      call _WinMain   
      invoke ExitProcess,NULL   
end start


前面是asm主程序
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"

#define IDM_MAIN 0x4000
#define IDA_MAIN 0x4200
//
// Menu resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDM_MAIN MENU
{
    POPUP "文件"
    {
      MENUITEM "关闭(x)...", IDM_CLOSE
    }
}

//
// Accelerator resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDA_MAIN ACCELERATORS
{
    VK_F1,         IDM_CLOSE, VIRTKEY
}
这个是资源文件
为什么nmake的时候显示 error A2206: missing operator in expression
和 error A2114: INVOKE argument type mismatch : argument : 2
错误对应的是invoke LoadMenu,hInstance,IDM_MAIN函数
新手求解

志华 发表于 2014-4-24 21:09:50

IDM_MAIN equ 0x4000
IDA_MAIN equ 0x4200
IDM_CLOSE equ 0x4201

汇编下应该是 IDM_MAIN EQU 4000H 而不是0x4000
资源文件里好像没定义IDM_CLOSE

阔怀 发表于 2015-8-8 10:46:33

:big
页: [1]
查看完整版本: 新手求解 错误代码A2206 A2114