请教通过资源名加载资源
如何才能通过资源名加载资源呢?通过资源ID的我会,但是通过资源名的却不能正常工作。在此请教大家,望赐教!
如下源码编译后在OD中运行DialogBoxParam函数返回值为-1,程序直接结束.
汇编源码:
.386
.model flat, stdcall
option casemap : none
includewindows.inc
includeuser32.inc
includelibuser32.lib
includekernel32.inc
includelibkernel32.lib
includegdi32.inc
includelibgdi32.lib
.data
hInstancedd?
hBmp1dd?
hBmp2dd?
.const
szDialogNamedb'IDD_DIALOG1', 0
.code
_ProcDlgprocuses ebx esi edi hWnd, uMsg, wParam, lParam
.ifuMsg == WM_CLOSE
invokeEndDialog, hWnd, 0
invokeDeleteObject, hBmp1
invokeDeleteObject, hBmp2
.elseifuMsg == WM_INITDIALOG
invokeLoadIcon, hInstance, 101
invokeSendMessage, hWnd, WM_SETICON, ICON_BIG, eax
.else
moveax, FALSE
ret
.endif
moveax, TRUE
ret
_ProcDlgendp
start:
invokeGetModuleHandle, NULL
movhInstance, eax
invokeDialogBoxParam, hInstance, addr szDialogName, NULL, addr _ProcDlg, 0
invokeExitProcess, 0
endstart
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"
//
// Dialog resources
//
LANGUAGE 0, SUBLANG_NEUTRAL
IDD_DIALOG1 DIALOG 0, 0, 186, 95
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "Ms Shell Dlg"
{
DEFPUSHBUTTON "OK", IDOK, 129, 7, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 129, 24, 50, 14
}
//
// Icon resources
//
LANGUAGE 0, SUBLANG_NEUTRAL