抱歉,我没有QQ.
我写了一个测试,你可以参考一下。
头文件
程序代码:
include windows.inc
include kernel32.inc
include user32.inc
include Comctl32.inc
include shell32.inc
includelib kernel32.lib
includelib user32.lib
includelib Comctl32.lib
includelib shell32.lib
BSTR typedef DWORD
DlgProc PROTO :HWND,:UINT,:WPARAM,:LPARAM
InitLcenKeys typedef PROTO C :BSTR,:BSTR,:BSTR,:BSTR
InitDecoration typedef PROTO C :BOOL
LoadSkinFromFile typedef PROTO C :BSTR
ApplySkin typedef PROTO C
RemoveSkin typedef PROTO C
DeInitDecoration typedef PROTO C
DecorateAs typedef PROTO C :LONG, :LONG
IncludeWnd typedef PROTO C :LONG,:LONG
ExcludeWnd typedef PROTO C :LONG,:LONG
SetCustomSkinWnd typedef PROTO C :LONG,:BSTR,:BOOL
GetSkinCopyRight typedef PROTO C :BSTR,:BSTR,:BSTR,:BSTR,:BSTR
UpdateControl typedef PROTO C :LONG
UpdateWnd typedef PROTO C :LONG
AddAdditionalThread typedef PROTO C
DeleteAdditionalThread typedef PROTO C
pInitLicn typedef ptr InitLcenKeys
pInitDec typedef ptr InitDecoration
pLoadSkin typedef ptr LoadSkinFromFile
pAppSkin typedef ptr ApplySkin
pMoveSkin typedef ptr RemoveSkin
pDeInitDec typedef ptr DeInitDecoration
pIncludeWnd typedef ptr IncludeWnd
pExcludeWnd typedef ptr ExcludeWnd
pSetCustWnd typedef ptr SetCustomSkinWnd
pGetSkinCopyRight typedef ptr GetSkinCopyRight
pUpdateControl typedef ptr UpdateControl
pAddAdditionalThread typedef ptr AddAdditionalThread
pDeleteAdditionalThread typedef ptr DeleteAdditionalThread
CTEXT MACRO y:VARARG
LOCAL sym
CONST segment dword private 'DATA'
IFIDNI <y>,<>
sym db 0
ELSE
sym db y,0
ENDIF
CONST ends
EXITM <OFFSET sym>
ENDM
IDD_DIALOG1 equ 101
IDC_BTN1 equ 1001
IDC_SBR1 equ 1006
IDC_PGB1 equ 1002
;#########################################################################
.data?
hInstance dd ?
hDll dd ?
FunInitLicn pInitLicn ?
FunInitDec pInitDec ?
FunLoadSkin pLoadSkin ?
FunAppSkin pAppSkin ?
FunDecInitDec pDeInitDec ?
Buf db 1024 dup(?)
调用跟普通WIN32API没有区别,只是因为它内部使用Unicode的关系,一些函数没有直接Invoke 而采用了call手工入栈方式。
再有要注意的就是所有函数声明全部为C调用方式,手工入栈的话注意调用后清栈。
程序代码:
.386
.model flat, stdcall ;32 bit memory model
option casemap :none ;case sensitive
include CSkinDll.inc
.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke InitCommonControls
invoke LoadLibrary,CTEXT("SkinDll.dll") ;加载DLL
mov hDll,eax
invoke GetProcAddress,hDll,CTEXT("InitLicenKeys") ;获得API地址
mov FunInitLicn,eax
invoke GetProcAddress,hDll,CTEXT("InitDecoration")
mov FunInitDec,eax
invoke GetProcAddress,hDll,CTEXT("LoadSkinFromFile")
mov FunLoadSkin,eax
invoke GetProcAddress,hDll,CTEXT("ApplySkin")
mov FunAppSkin,eax
invoke GetProcAddress,hDll,CTEXT("DeInitDecoration")
mov FunDecInitDec,eax
invoke MultiByteToWideChar,CP_ACP,0,CTEXT("DEMOSKINCRAFTERLICENCE"),-1,addr Buf,128 ;都是Unicode字串
lea eax,Buf
push eax
invoke MultiByteToWideChar,CP_ACP,0,CTEXT("support@),-1,addr Buf + 128,128
lea eax,Buf
add eax,128
push eax
invoke MultiByteToWideChar,CP_ACP,0,CTEXT("),-1,addr Buf + 128 * 2,128
lea eax,Buf
add eax,128 * 2
push eax
invoke MultiByteToWideChar,CP_ACP,0,CTEXT("SKINCRAFTER"),-1,addr Buf + 128 * 3,128
lea eax,Buf
add eax,128 * 3
push eax
;invoke MultiByteToWideChar,CP_ACP,0,CTEXT("0"),-1,addr Buf + 128 * 4,128
;lea eax,Buf
;add eax,128 * 4
;push eax
Call FunInitLicn ;调用函数
add esp,16
mov eax,1
push eax
Call FunInitDec ;调用函数
pop ecx
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
invoke ExitProcess,0
;########################################################################
DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
;LOCAL Buf[1024]:byte
mov eax,uMsg
.if eax==WM_INITDIALOG
.elseif eax==WM_COMMAND
mov eax,wParam
.if eax == IDC_BTN1
invoke MultiByteToWideChar,CP_ACP,0,CTEXT("Stylish.skf"),-1,addr Buf + 128 * 5,128
lea eax,Buf
add eax,128 * 5
push eax
Call FunLoadSkin ;调用函数
pop ecx
invoke FunAppSkin
invoke SendDlgItemMessage,hWin,IDC_PGB1,PBM_SETPOS,50,0
.endif
.elseif eax==WM_CLOSE
.if hDll
invoke FunDecInitDec ;调用函数
invoke FreeLibrary,hDll
.endif
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
end start
写得匆忙,很多地方没有很好处理,你领会一下意思好了。详细使用参考官方帮助。
[
本帖最后由 东海一鱼 于 2009-10-29 19:35 编辑 ]