³o¤@³¹¡A¤p¤ì°¸n½Íªº¬O¦p¦ó¦b Win32 ¨t²Î¤¤¡A¨Ï¥Î¸U°ê½X¼¶¼g²Õ¦X»y¨¥µ{¦¡¡C³o¨Ç¤º®e«Ü¦h¦Ó¥B½ÆÂø¡A©Ò¥H¥u¯à½Í¤@³¡¥÷¡A¥i¤À¬°©³¤U´XÓ¬q¸¨¡G
¦b²Õ¦X»y¨¥©Ò»s§@ªºµ{¦¡¤¤¡An¨Ï¥Î¸U°ê½X ( ¦³Ãö¸U°ê½Xªº¤¶²Ð¡A½Ð«ö³o¸Ì ) ½s½X¡A¥i¤À¬°´X¤è±¨Ó»¡¡G§@·~¨t²Î¡B²ÕĶ¾¹¡B¤å®Ñ³B²z¾¹¡B¥]§tÀÉ ( *.INC ) ¥|¤è±¨Ó»¡©ú¡G
¥Ñ«e¬qªº»¡©ú¡AŪªÌÀ³·í¥i¥H©úÁA¡A¥Ø«en¦b Win32 ²Õ¦X»y¨¥¤¤¨Ï¥Î¸U°ê½X¡AÁÙ¬O¤£¤Ó®e©ö¡C¥Dnì¦]¬O²ÕĶ¾¹¤£¤ä´©¡A¦ý¬O¤]¨Ã«DµLªk¥H²Õ¦X»y¨¥¼g¥X¸U°ê½X½s½Xªºµ{¦¡¡Cn¹F¦¨³oӥتº¡Aº¥ýÀ³¸Ó¤U¸ü MASM32 v11 ©Î¥H«áªºª©¥»¡A¨ä¦¸¤å®Ñ³B²z³nÅé©Ò¼¶¼gªºì©lµ{¦¡¥²¶·¥H ASCII/ANSI ®æ¦¡Àx¦s¦¨ *.ASM ÀÉ¡C¦b¼¶¼gì©lµ{¦¡®É¡AÁÙ¶·ª`·N´X¥ó¨Æ¡A¤~¯à¼g¥X¤ä´©¸U°ê½Xªºµ{¦¡¡C©ó¬O¦¹³¹½Ï¥Í¡C
¦b MASM32 ª©¥»ùØ ( ¦p MASM32 v7.0 )¡A¨Ã¨S¦³¤ä´©¸U°ê½X¡A¨º®É¦b *.INC Àɤº¡A³B²z¦r¤¸ªº API ³£¬O¥ý©w¸q ANSI ª©¥»¡A¦A§â¥h±¼³Ì«á±ªº¡uA¡v©Ò±oªº API ¦WºÙ©w¸q¬° ANSI ª©ªº API¡C¨Ò¦p¡A¦b USER32.INC ùØ¡A¦³Ãö MessageBox ªº©w¸q¹³¤U±³o¼Ë¡G
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD MessageBox equ <MessageBoxA>
¦]¦¹¡A¦b²Õ¦X»y¨¥ì©lµ{¦¡¤¤¡A¥u»Ý¼g¡uINVOKE MessageBox¡v´N¯à©I¥s MessageBox ¤F¡A¦Ó¥B¬O©I¥s MessageBoxA¡C¨ì¤F MASM32 v11 ®É¡AMessageBox ªº©w¸qÅܦ¨¤U±³o¼Ë¡G
MessageBoxA PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD IFNDEF __UNICODE__ MessageBox equ <MessageBoxA> ENDIF MessageBoxW PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD IFDEF __UNICODE__ MessageBox equ <MessageBoxW> ENDIF
³o¨â¬q±ø¥ó²ÕĶ¬O MASM ªº¯S¦â¤§¤@¡C¡uIFNDEF¡v¬O«ü¦pªG¥¼©w¸q«á±ªºÅܼơA¡u__UNICODE__¡v¡A¨º»ò MessageBox ´Nµ¥©ó MessageBoxA¡A¥ç§Y¦pªG©I¥s MessageBox¡A¨ä¹ê´N¬O©I¥s MessageBoxA¡F¡uIFDEF¡v«hªí¥Ü¦pªG©w¸q¤F¡u__UNICODE__¡v¡A¨º»ò©I¥s MessageBox ¨ä¹ê´N¬O©I¥s MessageBoxW¡C¦Ó¨ä¥L¦³²o¯A¨ì³B²z¤å¦rªº Win32 API¡A¤]³£¦³Ãþ¦üªº©w¸q¡C
´«¥y¸Ü»¡¡A¦b MASM32 v11 ùØ¡An¹ê¦æ©I¥s UNICODE ª©¥»ªº API¡Aº¥ýn¦bì©l½X¤@¶}©l¡A¦Ü¤Ö¬O¦b¥]§t INCLUDE Àɤ§«e¡A¥ý©w¸q¡u__UNICODE__¡vÅܼơC©w¸qªº¤èªk¦p¤U¡G
__UNICODE__ EQU 1
²Ä¤GÓ¨BÆJ´N¬On§â¦r¦ê§ï¦¨¥H¸U°ê½X½s½X¡C¹ï©ó^¤å¦r¥À»Pªü©Ô§B¼Æ¦r¦Ó¨¥«Ü²³æ¡A¦]¬°^¤å¦r¥À»Pªü©Ô§B¼Æ¦rªº¸U°ê½X¥u¬O ASCII ¦r¦êªº¨CӦ줸²ÕÅܦ¨¨âӦ줸²Õ¡A¦Ó°ª¦ì¤¸²Õ³]¬°¹s¡A´N§¹¦¨¤F¡C³o¥ó¨Æ¤]¤£»Ýn¥H¤H¤u¤è¦¡§¹¦¨¡A¦b MASM32 v11 ª©ùØ¡A¤w¸g§¹¦¨¤F¤@Ó¥¨¶°«ü¥O¡A¥i¥HÀ°§Ú̧¹¦¨³o¥ó¨Æ¡C¨º¬O¦b¡uc:\masm32\macros\macros.asm¡vùرªº¡uWSTR¡v¥¨¶°¡C¨Ï¥Î®É¥u»Ýn§â¡umacros.asm¡v§t¬A¶i¨Ó¡C¦pªG¦r¦ê¤º®e¡A¥þ³¡³£¬O^¤å¦r¥À©Îªü©Ô§B¦r¥À¡A§ï¥H¡uWSTR¡v©w¸q¡A¡uWSTR¡v·|¦Û°Êªº§â 80H ¥H¤Uªº ASCII ¦r¦êÅܦ¨¸U°ê½X¦r¦ê¡A¨Ã¥B©ñ¦b¡u.DATA¡v°Ï¬q¤¤¡A¨ä¥Îªk¬O¡J
WSTR ¦r¦ê¦WºÙ,"¦r¦ê¤º®e"
½Ð¬Ý¥H¤U½d¨Ò¡J
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 |
OPTION CASEMAP:NONE
.386
.MODEL FLAT,STDCALL
__UNICODE__ EQU 1
INCLUDE WINDOWS.INC
INCLUDE KERNEL32.INC
INCLUDE USER32.INC
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
INCLUDE C:\masm32\macros\macros.asm
;***************************************************************************************************
.DATA
WSTR szTitle,"Simplest Program"
WSTR szMessage,"Hellow, MASM32 UNICODE."
;***************************************************************************************************
.CODE
start: INVOKE MessageBox,NULL,ADDR szMessage,ADDR szTitle,MB_OK OR MB_ICONINFORMATION
INVOKE ExitProcess,NULL
;***************************************************************************************************
END start |
¦]¬°¡uWSTR¡v¥¨¶°·|¥Î¨ì WINDOWS.INC ùتº©w¸q¡A©Ò¥H macros.asm ³Ì¦n©ñ¦b©Ò¦³§t¬A¶i¨Óªº *.INC Àɪº«á±¡C¤W±¥|¦æ¥H¬õ¦â¦r©Ò¼Ð¥Üªº¡A´N¬O¨Ï¥Î¸U°ê½X®É¡A·s¼W¥[ªºµ{¦¡½X¡C
¦pªG¬O¤¤¤å¦r¦ên¨Ï¥Î¸U°ê½X¡A´NµLªk¥H WSTR ¥¨¶°©w¸q¡A¦]¬°¤¤¤å¦r½s½X¤è¦¡¥i¤£¹³^¤å¨º¼Ë³æ¯Â¡C¨ì¥Ø«e¬°¤î¡A¤¤¤å¦r¦ê¥u¯à¥H¼ÆȪº¤èªk©w¸q¡C½Ð¬Ý©³¤Uµ{¦¡ªº²Ä 12 ¦æ©w¸q¤F¡u´ú¸Õ¸U°ê½X¡v¦r¦ê¡A²Ä 13¡ã15 ¦æ©w¸q¤F¡uWin32 ²Õ¦X»y¨¥¤¤¡A¨Ï¥Î¸U°ê½X¡v¦r¦ê¡C³o¨âÓ¦r¦ê¬Ò¥H¸U°ê½X½s½X¡A¤£¬O¤@¯ëªº BIG¡Ð5 ½X¡C¨º¤p¤ì°¸¤S«ç»òª¾¹D³o¨Ç¤¤¤å¦rªº¸U°ê½X©O¡HÀ³¸Ó¦³³\¦hºØ¤èªk¡A¤p¤ì°¸´£¨Ñ¨âºØ¡C¤@¬O¥Ñ¤¤µØ¥Á°ê°ê®aµo®i©eû·|ªº¥þ¦r®wºô¯¸¬d¸ß¡A³oºô¯¸¥i¥H¥Ñª`µ¬d¸U°ê½X¡C²Ä¤GºØ¥i¥H¥Î UltraEdit¡Ð32 ¬d¸ß ( ¤p¤ì°¸¨Ï¥Î UltraEdit¡Ð32 ¬O v12.10a ª© )¡A¦b UltraEdit¡Ð32 ¤¤·s«Ø¥ß¤@¼È¦sÀÉ¡AµM«á¿é¤J¤¤¤å¦r¡A¨Ò¦p¤U¹Ï¿é¤J¡u´ú¸Õ¸U°ê½X¡v¡G
µM«á¦b¿ï³æ¿ï«ö¡uFile¡v¡÷¡uSave As ...¡v¡A±µ¤U¨Ó·|¼u¥X¤@¹ï¸Ü²°¡A§ÚÌn¦b¡uFormat:¡v½Æ¦X®ØùØ¿ï¾ÜnÀx¦sªº®æ¦¡¡A±z¥i¥H¨£¨ì¡A¦³¦n´XºØ®æ¦¡¥i¥H¿ï¾Ü¡A§ÚÌn¿ïªº¬O¡uUnicode - ASCII Escaped¡v¡C¦p¤U¹Ï¡G ±µµÛ¡Aµe±Åܬ°¤U¹Ï¡A±z´N¥i¥H¬Ý¨ì¡u´ú¸Õ¸U°ê½X¡v³o¤Ó¦rÅܦ¨¤F¸U°ê½X¡G ³o¼Ë´N¥i¥H¦b©³¤Uµ{¦¡½Xªº²Ä 12 ¦æ¶ñ¤J¡u´ú¸Õ¸U°ê½X¡v³o¤Ó¦rªº¸U°ê½X¡C¦¹³Bn¯S§O¤p¤ß¡A·í±z§â©³¤UªºÀɮצs¦¨ ASM ì©l½X®É¡A¤@©wn¥H¡uANSI/ASCII¡vªº®æ¦¡Àx¦s¡A³o¬O¦]¬°²ÕĶ¾¹ ( ML.EXE ) ¥u»{±o ANSI/ASCII ¦r¤¸¡C¦¹¥~¡A¤p¤ì°¸Ä±±o¡A¥Î³oºØ¤è¦¡¬d¤¤¤å¦rªº¸U°ê½X¡A¤´µM³Â·Ð¡C©Ò¥H¥»³¹«á±¡A¤p¤ì°¸µo®i¥X¤@Ó¤u¨ãµ{¦¡¡AA2U.ASM¡A¯à¦Û°Ê§â ANSI ¦r¦ê¡AÅܦ¨¸U°ê½X¦r¦ê¡C1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 |
OPTION CASEMAP:NONE
.386
.MODEL FLAT,STDCALL
__UNICODE__ EQU 1
INCLUDE WINDOWS.INC
INCLUDE KERNEL32.INC
INCLUDE USER32.INC
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
;***************************************************************************************************
.DATA
szTitle DW 6e2ch,8a66h,842ch,570bh,78bch,0 ;´ú¸Õ¸U°ê½X
szMessage DB 57h,0,69h,0,6eh,0,33h,0,32h,0,20h,0,44h,7dh,8,54h ;Win32 ²Õ¦X
DB 9eh,8ah,0,8ah,2dh,4eh,0ch,0ffh,7fh,4fh,28h,75h ;»y¨¥¤¤¡A¨Ï¥Î
DB 2ch,84h,0bh,57h,0bch,78h,0,0 ;¸U°ê½X
;***************************************************************************************************
.CODE
start: INVOKE MessageBox,NULL,ADDR szMessage,ADDR szTitle,MB_OK OR MB_ICONINFORMATION
INVOKE ExitProcess,NULL
;***************************************************************************************************
END start |
¤W±µ{¦¡½Xªº²Ä 12¡B13 ¦æ¡A©w¸q¤F¨âÓ¥H¸U°ê½X½s½Xªº¦r¦ê¡A²Ä 12 ¦æª½±µ¥H¤@Ó¦r²Õªí¥Ü¡A²Ä 13 ¦æ¬O¥H¨âӦ줸²Õªí¥Ü¡A§¡¯à¨Ïµ{¦¡¥¿½T¹B§@¡C·í©I¥s MessageBox ®É¡A¨ä¹ê¬O©I¥s MessageBoxW¡A¦Ó¶Ç¶i¥hªº¦r¦êµ²§À¬° NULL¡A¥H¸U°ê½X½s½X¬O¤@Ó¦r²Õ ( 16 ¦ì¤¸ )¡C©Ò¥H²Ä 15 ¦æ¥H¡uDB¡v©w¸q¦r¦ê¡Aµ²§À¬°¡u0,0¡v¡F²Ä 13 ¦æ¥H¡uDW¡v©w¸q¡Aµ²§À¬°¡u0¡v¡C
¦pªGn¼¶¼g¹ï¸Ü²°µ{¦¡¡A¨Ï¥Î¡u¸ê·½´yzÀÉ¡v´yz¹ï¸Ü²°¤ºªº±±¨î¶µ¡A¬O·¥¨ä¤è«Kªº°µªk¡C·í¸ê·½´yzÀɳQ RC.EXE ½sĶ®É¡ARC.EXE ·|¦Û°Êªº§â¨âÓ¡u"¡v¸¹¤ºªº¤å¦r½s¦¨¸U°ê½X¡C¦]¦¹¼¶¼g¥H¹ï¸Ü²°¬°¥Dªºµ{¦¡¡A¤£¥²¾á¤ß¸ê·½´yzÀɪº°ÝÃD¡A¤@¤Á¥æµ¹ RC.EXE ¥h°õ¦æ´N¥i¥H¤F¡C§Y¨Ï±z§â¸ê·½´yzÀɦs¦¨ ASCII ®æ¦¡¡A¤]¨S¦³Ãö«Y¡A¡u"¡v¤ºªº¤å¦r¤´·|³Q RC.EXE ¥H¸U°ê½Xªº¤è¦¡½sĶ¡C
¦b MASM32 v11 ª©¤º¡A´N¦³¤@Óµ{¦¡¡A¡umasm32\examples\unicode_generic\multi_lingual\multi_lingual.exe¡v¡A°õ¦æ«á·|¦b¦P¤@Ó¹ï¸Ü²°¤ºÅã¥Ü¤QºØ¤å¦r¡C¤p¤ì°¸¼Ò¥é³oÓµ{¦¡¡A¦Û¦æ»s§@¡uMULTILG.ASM¡v¡A¤]¯à¦b¦P¤@¹ï¸Ü²°¡AÅã¥Ü¡u¥¿Å餤¤å¡v¡B¡u²Å餤¤å¡v¡B¡u^¤å¡v¡B¡u©Ô¤B¤å¡v¡B¡u«X¤å¡vµ¥¤å¦r¡CMULTILG °õ¦æ«á¦p¥k¡C©³¤U¬O¡uMULTILG.RC¡vªºì©l½X¡C¤p¤ì°¸¬O¤£À´©Ô¤B¤å©M«X¤åªº¡A¦ý¬OÂÇ¥Ñ Google ¤j¯«ªºÀ°§U¡A¥i»´¦Ó©öÁ|ªºÂ½Ä¶Â²³æªº¥y¤l¡C¥un¦b Google ªººô¶¤¤¿é¤J¡u½Ķ¡v¨Ã·j´M«á¡A²Ä¤@Ó¶µ¥Ø¥ªÃä´N·|¥X²{±z¹q¸£¤º©wªº»y¤å¡A¥kÃä¥i¿ï¾Ü±z·Q½¦¨þ¤@ºØ»y¤å¡C
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 |
#include "c:\masm32\include\resource.h"
#define IDS_TCHINESE 2000
#define IDS_SCHINESE 2001
#define IDS_ENGLISH 2002
#define IDS_LATIN 2003
#define IDS_RUSSIAN 2004
#define IDB_EXIT 2005
#define RT_MANIFEST 24
1 RT_MANIFEST MOVEABLE PURE "multilg.exe.manifest"
GLOBE ICON Globe.ico
MultiLG DIALOG 0,0,170,85
STYLE WS_POPUP|WS_CAPTION|WS_VISIBLE|WS_SYSMENU|WS_MINIMIZEBOX
CAPTION "¦h»y¨¥¹ï¸Ü²°"
FONT 9,"·s²Ó©úÅé"
BEGIN
LTEXT "¥¿Å餤¤å¡G¦¦w¡A²Õ¦X»y¨¥¡C", IDS_TCHINESE,5, 5,150,12
LTEXT "²Å餤¤å¡G¦¤W¦n¡A汇编¡C", IDS_SCHINESE,5,17,150,12
LTEXT "^¤å¡GGood morning, assembly language.",IDS_ENGLISH, 5,29,150,12
LTEXT "©Ô¤B¤å¡GBonum mane, contione lingua.", IDS_LATIN, 5,41,150,12
LTEXT "«X¤å¡Gдоброе утро на языке ассемблера.",IDS_RUSSIAN,5,53,150,12
PUSHBUTTON "Exit",IDB_EXIT,106,66,50,12
END |
³Ì«á§â MULTILG.RC ¦s¦¨¡uUTF-16 - NO BOM¡v®æ¦¡¡A¦pªG±z¥Î UltraEdit¡Ð32 ½s¿è MULTILG.RC ÀÉ¡A©Ò¨£µe±¦p¤U¹Ï¬õ¦â®Ø®Ø¡G
MULTILG.ASM ªºì©l½X¦p¤U¡A¦ý¬O¥²¶·§â¥¦¦s¦¨¡uANSI/ASCII¡v®æ¦¡¡G
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
32 33 34 35
36 37 38 39
40 41 42 43
44 45 46 47
48 49 50 51
52 53 54 55
56 57 58 59
60 |
OPTION CASEMAP:NONE
.586
.MODEL FLAT,STDCALL
IDB_EXIT EQU 2005
__UNICODE__ EQU 1
INCLUDE WINDOWS.INC
INCLUDE COMCTL32.INC
INCLUDE KERNEL32.INC
INCLUDE USER32.INC
INCLUDELIB COMCTL32.LIB
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
INCLUDE C:\masm32\macros\macros.asm
;*******************************************************************************
.DATA
hInstance HANDLE ? ;¼Ò²Õ¥N½X
hButton HANDLE ? ;«ö¶s¥N½X
WSTR szDlgName,"MultiLG" ;¹ï¸Ü²°±ªO¦WºÙ
WSTR szIcon,"GLOBE" ;¹Ï¥Ü¦WºÙ
;*******************************************************************************
.CODE
;-------------------------------------------------------------------------------
DlgProc PROC hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.IF uMsg==WM_INITDIALOG
INVOKE GetDlgItem,hDlg,IDB_EXIT
mov hButton,eax
INVOKE LoadIcon,hInstance,OFFSET szIcon
INVOKE SendMessage,hDlg,WM_SETICON,ICON_SMALL,eax
.ELSEIF uMsg==WM_COMMAND
mov edx,wParam
mov eax,lParam
shr edx,10h
.IF eax==hButton
.IF edx==BN_CLICKED
jmp quit
.ENDIF
.ENDIF
.ELSEIF uMsg==WM_CLOSE
quit: INVOKE EndDialog,hDlg,NULL
.ELSE ;¨ä¥L¥¼³B²zªº°T®§ªð¦^ FALSE
mov eax,FALSE
ret
.ENDIF ;¤w³B²zªº°T®§¡Aªð¦^ TRUE
mov eax,TRUE
ret
DlgProc ENDP
;-------------------------------------------------------------------------------
start: INVOKE GetModuleHandle,NULL
mov hInstance,eax
INVOKE DialogBoxParam,hInstance,OFFSET szDlgName,NULL,OFFSET DlgProc,NULL
INVOKE ExitProcess,eax
INVOKE InitCommonControls
;*******************************************************************************
END start |
©³¤U¬O MULTILG.EXE.MANIFEST Àɪº¤º®e¡G | |
1 2 3
4 5 6 7
8 9 10 11
12 13 14 |
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32'
name='Microsoft.Windows.Common-Controls'
version='6.0.0.0'
processorArchitecture='*'
publicKeyToken='6595b64144ccf1df'
language='*'
/>
</dependentAssembly>
</dependency>
</assembly> |
nª`·Nªº¬O MULTILG.EXE.MANIFEST ¥²¶·¦s¦¨ ANSI/ASCII ®æ¦¡¡A§_«h»s§@¥X¨Óªº¥i°õ¦æÀɵLªk°õ¦æ ( ·|¥X²{¡u¨t²ÎµLªk°õ¦æ«ü©wªºµ{¦¡¡C¡vªº¿ù»~°T®§ )¡C²ÕĶ¤Î³sµ²¤è¦¡¦p¤U
E:\HomePage\SOURCE\Win32\UNICODE>rc multilg.rc [Enter] E:\HomePage\SOURCE\Win32\UNICODE>ml multilg.asm /link multilg.res [Enter] Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: multilg.asm ************* UNICODE Build ************* Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /SUBSYSTEM:WINDOWS "multilg.obj" "/OUT:multilg.exe" "multilg.res" E:\HomePage\SOURCE\Win32\UNICODE>
MULTILG.ASM ªº²Ä 20¡B21 ¦æ©w¸q¹ï¸Ü²°±ªO¤Î¹Ï¥Üªº¦WºÙ¡A¤£½×¨Ï¥Î ASCII ¦r¤¸©Î¸U°ê½X³£µL©Ò¿×¡Aµ{¦¡³£¯à¥¿½T°õ¦æ¡Cì¦]¬O Windows XP ¦bI«á·d°¡AWindows XP ·|¦Û°Ê§â ASCII ¦r¦êÅܦ¨¸U°ê½X¡A¨Ï¤§»P¸ê·½¤ºªº¤å¦r·f°t¡A©Ò¥H¤£·|¦³°ÝÃD¡C¥t¥~²Ä 38 ¦æªºµL±ø¥ó¸õÅDªº¥Øªº¼Ð¸¹¡A¤£¥i¨Ï¥Î¡uexit¡v¡A¦ü¥G¬O¦]¬° WSTR ¥¨¶°¨Ï¥Îªº½t¬G¡A©Ò¥H¤p¤ì°¸§ï¥Î¡uquit¡v¡C
MULTILG ¦b¦P¤@Óµøµ¡¤¤Åã¥Ü¤£¦P»y¨¥¡AµM¦Ó¯àºë³q¨âºØ©Î§ó¦h»y¨¥ªº¤H²¦³º«Ü¤Ö¡A©Ò¥H¹ê¥Î©Ê¤£°ª¡C¤j³¡¤Àªº¤H³£¥u¨Ï¥Î¤@ºØ»y¨¥¡A©Ò¥H¤j³¡¤Àªº±¡§Î¬O¦b¤@Óµøµ¡©Îµ{¦¡ùØ¡A¥un¯àÅã¥Ü¤@ºØ»y¤å´N¥i¥H¤F¡C°ÝÃD¬O¡A¦P¤@µ{¦¡n¯à´£¨Ñ¤£¦Pªº»y¨¥¡Aµ¹Á¿¤£¦P»y¨¥ªº¤H¿ï¾Ü¡C¨Ò¦p¦b¤j³°¦a°Ï¥i¥HÅý¤HÌ¿ï¾Ü²Å餤¤å¡B¦b¥xÆW«h¿ï¾Ü¥¿Å餤¤å¡B¦b¬ü°ê«h¬O^¤å¡B¦b¤é¥»«h¬O¤é¤å¡K¡K¡A¬Æ¦Ü¥i¥H¦bµ{¦¡¤¤¡A¥ô·N¤Á´«»y¨¥¡C¦p¤U¹Ïªºµ{¦¡¡A¯à¦b¿ï³æ¤¤¿ï¾Ü¥Hþ¤@ºØ»y¨¥Åã¥Ü¡A¿ï¦n¤§«á¡A¿ï¶µ¤å¦r¡B¼ÐÃDÄæ¤å¦r³£·|¤Á´«¦¨¸ÓºØ»y¨¥¡C
¡@¡@
¤W¹Ï¤¤¡A¥ªÃ䪺µøµ¡ì¥»¥H¥¿Å餤¤åÅã¥Ü¡A¦pªG¨Ï¥ÎªÌ¿ï¾Ü²Å餤¤å«á¡Aµøµ¡´NÅܦ¨¥kÃ䪺¼Ë¤l¡Cn¹F¨ì¤W±ªº¥Øªº¡A¥i¥H¦³³\¦h¤èªk¡A½Ð°Ñ¦Ò¡u½s¼g Win32 ¦h»y¨¥¥Î¤á¬É±À³¥Îµ{§Ç¡v¡C¦b³o¤@½g¤å³¹¤¤´£¨ì¤TºØ¤èªk¡G
¦]¬°²Ä¤@ºØ¤èªk¥H³vº¥¤£¨Ï¥Î¡A¦¹³B¤p¤ì°¸¥u¤¶²Ð«á¨âºØ¤èªk¡C¥ý¤¶²Ð²Ä¤GºØ¤èªk¡A³oºØ¤èªk¬O¦b¸ê·½´yzÀÉ ( *.RC ÀÉ ) ùبϥΦr¦êªí ( string table )¡C
¦r¦êªí¬O¸ê·½´yzÀɪº¦¨û¤§¤@¡C¦r¦êªí¦b¸ê·½´yzÀɤ¤ªº»yªk¬O¡G
STRINGTABLE CHARACTERISTICS dword LANGUAGE language,sublanguage VERSION dword BEGIN stringID,"string" ...... END
CHARACTERISTICS ¬O¨Ï¥ÎªÌ©w¸qªº¸ê®Æ¡A¥i¥H¬°¬Y¨Ç¤u¨ã¨Ï¥Î¡A¥i¥H¬Ù²¤¡CLANGUAGE «á±±µµÛªº¬O¡ulanguage¡v»P¡usublanguage¡v¡A³o¨âӰѼƬO«ü STRINGTABLE ùتº¦r¦ê©Ò¨Ï¥Î»y¨¥¡CLANGUAGE ¤]¥i¥H¬Ù²¤¡A¬Ù²¤®É§Y¬°¨t²Î©Ò¤º©wªº»y¨¥¡CVERSION ¬°ª©¥»½s¸¹¡A¤]¥i¥H¬Ù²¤¡C¦r¦êªí ( STRINGTABLE ) ¨S¦³ÃѧO½X¡A¥u¦³§¨¦b BEGIN/END ¤¤¶¡ªº¦r¦ê¡A¤~¦³ÃѧO½X¡AºÙ¬°¡u¦r¦êÃѧO½X¡v¡A¦r¦êÃѧO½X¥i¥H±q 0¡ã65535¡C¨CÓ¦r¦ê«e±ªº½s¸¹´N¬O¦r¦êÃѧO½X¡A¦r¦ê¥H¡u"¡v§t¬A°_¨Ó¡A¡u"¡v»P¦r¦êÃѧO½X¤§¶¡¥H¡u,¡v¹j¶}¡C¦b¨âÓ¡u"¡v¤§¶¡ªº¦r¦ê¡A¤]¥i¥H¥Î¡u/x0¼ÆÈ¡v¨Óªí¥Ü¤Q¤»¶i¦ì¼Æ©Ò¥Nªíªº¦r¤¸¡C¨Ò¦p¤U±ªº¦r¦ê°_ÀY¬O¥ý´«¦æ¨â¦¸¡G
¦pªGn¨Ï¥Î¤£¦P»y¨¥¡A§ÚÌ¥un·V¿ï¦r¦êÃѧO½X¡A´N¥i¥HÅý¨Ï¥ÎªÌ¿ï¥Î¤£¦Pªº»y¨¥¤F¡C¤èªk¬O¿í¦u¨âÓì«h¡G²Ä¤@¡A¦PºØ»y¨¥ªº¦r¦êÃѧO½X©ñ¦b¤@°_¡A¨Ò¦p¥¿Å餤¤å±q 20000 ¶}©l¡B²Å餤¤å±q 21000 ¶}©l¡B^¤å±q 22000 ¶}©l¡K¡K¡C²Ä¤G¡A¬Û¹ïÀ³ªº¦r¦êÃѧO½Xªº¦r¦ê·N¸qÀ³¬Û¦P¡A¨Ò¦pÃѧO½X 20000 ªº¦r¦ê¬°¡uÀɮסv¡A¨º»ò 21000 ªº¦r¦êÀ³¬°¡u¤å¥ó¡v¡A22000 ªº¦r¦êÀ³¬°¡uFile¡v¡C
n±q¸ê·½Àɤ¤´£¨ú¦r¦êªí¤¤ªº¦r¦ê¡A¥i©I¥s LoadString¡CLoadString ªºì«¬¬O¡G
int LoadString ( HINSTANCE hInstance, UINT uID, LPTSTR lpBuffer, int nBufferMax );
hInstance ¬O¼Ò²Õ¥N½X¡A¥i¥H¥Ñ GetModuleHandle¡BLoadLibrary µ¥ API ±o¨ì¡CuID ¬On¨ú±oªº¦r¦êÃѧO½X¡ClpBuffer ¬O¨ú±oªº¦r¦ê¦s©ñ¦ì§}¡CnBufferMax ¬On¨ú±oªº¦r¦êªø«×¡A¦pªGn¨ú±oªº¦r¦ê¬O ASCII ¦r¦ê¡A¥H¦ì¤¸²Õ¬°³æ¦ì¡F¦pªGn¨ú±oªº¦r¦ê¬O¼e¦ì¤¸²Õ¦r¦ê¡A¥H¦r²Õ¬°³æ¦ì¡C¦pªG nBufferMax ³]¬°¹s¡A¨º»ò lpBuffer ·|±o¨ì¸Ó¦r¦êªº¦ì§}¡A³oÓ¦ì§}¬O°ßŪ¤£¯à¼g¤J¡C¦pªGn³]©w nBufferMax ¬°¹s¡A¦b½sĶ *.RC ÀɮɡA³Ì¦n¯à¿é¤J¡u-n¡v©Î¡u/n¡v°Ñ¼Æ¡A¦p¤U¡G
E:\HomePage\SOURCE\Win32\UNICODE>rc /n mtlg1.rc [Enter]
¡u/n¡v¬O·|¨Ï¦r¦êªí¤¤ªº¦r¦êµ²§À³B¡A¥[¤W¡uNULL¡v¡C³o¼Ëªº¦n³B¬Oµ{¦¡¤£¥²¬°¸ü¤Jªº¦r¦ê·Ç³Æ¤@¶ô°O¾ÐÅé¡C
ªð¦^®É¡ALoadString ·|¶Ç¦^Ū¨úªº¦r¦êªø«×¡A³æ¦ì¦p¦P nBufferMax¡CLoadString Ū¨ú¦r¦ê®É¡A·|¦Û°Ê¦b¦r¦ê³Ì«á±¥[¤W NULL¡C¦pªG nBufferMax ¤£¬°¹s¥B¤p©ó¸ê·½Àɤºªº¦r¦ê¡A¨º»ò¦r¦ê·|³QºI±¼¡A©Ò¯u¥¿Åª¨úªº¦r¦êªø«×·|¤ñ nBufferMax ÁÙ¤Ö¤@¡A³o¬O¦]¬°n¦b¦r¦ê«á®e¯Ç NULL¡C
©³¤U¥ý¨Ó¬Ý¬Ý MTLG1.EXE.MANIFEST ªº¤º®e¡G | |
1 2 3
4 5 6 7
8 9 10 11
12 13 14 |
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32'
name='Microsoft.Windows.Common-Controls'
version='6.0.0.0'
processorArchitecture='*'
publicKeyToken='6595b64144ccf1df'
language='*'
/>
</dependentAssembly>
</dependency>
</assembly> |
©³¤U¬O MTLG1.RC Àɪº¤º®e¡G | |
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
32 33 34 35
36 37 38 39
40 41 42 43
44 45 46 47
48 49 50 51
52 53 54 55
56 57 58 59
60 61 62 63
64 65 66 67
68 69 70 71
72 73 74 75
76 77 78 79
80 81 82 83
84 85 86 87
88 89 |
#include "c:\masm32\include\resource.h"
#define RT_MANIFEST 24
#define IDC_EDIT 2000
#define IDM_OPEN 10000
#define IDM_EXIT 10001
#define IDM_HELP 10002
#define IDM_TCHINESE 20000
#define IDM_SCHINESE 21000
#define IDM_GERMAN 22000
#define IDM_ENGLISH 23000
#define IDM_RUSSIAN 24000
1 RT_MANIFEST MOVEABLE PURE "MTLG1.EXE.MANIFEST"
Unicode ICON mini_unicode.ico
MTLG DIALOG 300,200,200,150
STYLE WS_POPUP|WS_CAPTION|WS_VISIBLE|WS_SYSMENU|WS_MINIMIZEBOX
CAPTION "¦h»y¨¥¹ï¸Ü²°"
FONT 9,"·s²Ó©úÅé"
BEGIN
EDITTEXT IDC_EDIT,1,1,198,148,ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL
END
MainMenu MENU
BEGIN
POPUP "File"
BEGIN
MENUITEM "Open",IDM_OPEN
MENUITEM "Exit",IDM_EXIT
END
POPUP "View"
BEGIN
MENUITEM "¥¿Å餤¤å",IDM_TCHINESE
MENUITEM "简体中文",IDM_SCHINESE
MENUITEM "Deutsch",IDM_GERMAN
MENUITEM "English",IDM_ENGLISH
MENUITEM "русский",IDM_RUSSIAN
END
MENUITEM "Help",IDM_HELP
END
STRINGTABLE
BEGIN
20000,"ÀÉ®×"
20001,"¶}±Ò"
20002,"Â÷¶}"
20003,"À˵ø"
20004,"»¡©ú"
20005,"³oÓµ{¦¡¯àÅã¥Ü¤£¦P»y¨¥ªº¤¶±¡C"
20006,"\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a²{¦bÅã¥Ü¥¿Å餤¤å¡C"
20007,"¨Ï¥ÎªÌ¥i¥H¥Ñ¡uÀ˵ø¡v¿ï³æ¤¤¡A\n¬D¿ï¨ä¤¤¥ô¤@Ó»y¨¥Åã¥Ü¡C"
21000,"文件"
21001,"开启"
21002,"退出"
21003,"检视"
21004,"说明"
21005,"这个程序能显示不同语言的介面。"
21006,"\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a现在显示简体中文。"
21007,"用户可以由“检视”选单中,\n挑选其中任一个语言显示。"
22000,"Datei"
22001,"Geöffnet"
22002,"Ausgang"
22003,"Ansicht"
22004,"Hilfe"
22005,"Dieses Programm kann in verschiedenen Sprachen Schnittstelle angezeigt werden."
22006,"Zeigen Sie Deutsch jetzt gleich."
22007,"Benutzer können über das Menü 'Ansicht',\nWählen Sie entweder eine Sprache aus."
23000,"File"
23001,"Open"
23002,"Exit"
23003,"View"
23004,"Help"
23005,"This program can be displayed in different languages."
23006,"Now displayed in English."
23007,"Users can from 'View' menu ,\n choose either a language."
24000,"файл"
24001,"открыто"
24002,"выход"
24003,"вид"
24004,"помогите"
24005,"Эта программа может быть отображен в различных Языки интерфейса."
24006,"Дисплей на русском языке."
24007,"Люди могут из меню 'Вид'\nВыберите либо язык." END |
ª`·N¨ì¤W±ªº¸ê·½´yzÀÉ¡Aùرªº¦r¦êªí¤¤ªº¦r¦êÃѧO½X¡A¬O¸g¹L¦³·Nªº¦w±Æ¡C¦PºØ»y¨¥³£©ñ¦b¤@°_¡A¦Ó¥B¶¶§Ç¬Û¦P¡C³o¼Ëªº¸Ü¡A¥un¥Î¤@ÓÅܼơAÀx¦s¤£¦P»y¨¥ªº²Ä¤@Ó¦r¦êÃѧO½X¡Aªí¥Ü²{¦b¨Ï¥Îþ¤@ºØ»y¨¥¡A´N¯à«Ü®e©ö¨ú±o¦PºØ»y¨¥ªº¨ä¥L¦r¦ê¡C¨Ò¦p¡A¦pªG¦¹ÅܼƬ° 20000¡A¨º»ò¼W¥[¤@¡A´N¯à¨ú±o¡uÀɮסv¡F¦pªG¤Á´«¦¨^¤å¡A«h¸ÓÅܼÆÅܬ° 23000¡A¤]¬O¼W¥[¤@¡A´N¯à¨ú±o¡uFile¡v¡C
©³¤U¡A¨Ó¬Ý¬Ý MTLG1.ASM¡G | |
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
32 33 34 35
36 37 38 39
40 41 42 43
44 45 46 47
48 49 50 51
52 53 54 55
56 57 58 59
60 61 62 63
64 65 66 67
68 69 70 71
72 73 74 75
76 77 78 79
80 81 82 83
84 85 86 87
88 89 90 91
92 93 94 95
96 97 98 99
100 101 102 103
104 105 106 107
108 109 110 111
112 113 114 115
116 117 118 119
120 121 122 123
124 125 126 127
128 129 130 131
132 133 134 135
136 137 138 139
140 141 142 143
144 145 146 147
148 149 150 151
152 153 154 155
156 157 158 159
160 161 162 163 |
OPTION CASEMAP:NONE
.586
.MODEL FLAT,STDCALL
__UNICODE__ EQU 1
IDC_EDIT EQU 2000
IDM_OPEN EQU 10000
IDM_EXIT EQU 10001
IDM_HELP EQU 10002
IDM_TCHINESE EQU 20000
IDM_SCHINESE EQU 21000
IDM_GERMAN EQU 22000
IDM_ENGLISH EQU 23000
IDM_RUSSIAN EQU 24000
INCLUDE WINDOWS.INC
INCLUDE COMCTL32.INC
INCLUDE KERNEL32.INC
INCLUDE USER32.INC
INCLUDELIB COMCTL32.LIB
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
INCLUDE C:\masm32\macros\macros.asm
;*************************************************************************************************************
.DATA
hInstance HANDLE ? ;¼Ò²Õ¥N½X
hMenu HANDLE ? ;¥D¿ï³æ¥N½X
hFileMenu HANDLE ? ;Àɮפl¿ï³æ¥N½X
hViewMenu HANDLE ? ;À˵ø¤l¿ï³æ¥N½X
now_language DD ? ;¹ï¸Ü²°²{¦b©Ò¨Ï¥Îªº»y¤å
mii MENUITEMINFO <>
WSTR szDlgName,"MTLG" ;¹ï¸Ü²°±ªO¦WºÙ
WSTR szIconName,"Unicode" ;¹Ï¥Ü¦WºÙ
WSTR szMenuName,"MainMenu" ;¥D¿ï³æ¦WºÙ
;*************************************************************************************************************
.CODE
;-------------------------------------------------------------------------------------------------------------
change_language PROC USES esi hdlg:DWORD
LOCAL menu_name[200h]:BYTE
mov esi,now_language
INVOKE LoadString,hInstance,esi,ADDR menu_name,SIZEOF menu_name
mov mii.fMask,MIIM_STRING
lea edx,menu_name
mov mii.dwTypeData,edx
mov mii.cch,SIZEOF menu_name
INVOKE SetMenuItemInfo,hMenu,0,TRUE,ADDR mii
inc esi
INVOKE LoadString,hInstance,esi,ADDR menu_name,SIZEOF menu_name
INVOKE SetMenuItemInfo,hFileMenu,0,TRUE,ADDR mii
inc esi
INVOKE LoadString,hInstance,esi,ADDR menu_name,SIZEOF menu_name
INVOKE SetMenuItemInfo,hFileMenu,1,TRUE,ADDR mii
inc esi
INVOKE LoadString,hInstance,esi,ADDR menu_name,SIZEOF menu_name
INVOKE SetMenuItemInfo,hMenu,1,TRUE,ADDR mii
inc esi
INVOKE LoadString,hInstance,esi,ADDR menu_name,SIZEOF menu_name
INVOKE SetMenuItemInfo,hMenu,2,TRUE,ADDR mii
inc esi
INVOKE LoadString,hInstance,esi,ADDR menu_name,SIZEOF menu_name
INVOKE SetWindowText,hdlg,ADDR menu_name
inc esi
INVOKE LoadString,hInstance,esi,ADDR menu_name,SIZEOF menu_name
INVOKE SetDlgItemText,hdlg,IDC_EDIT,ADDR menu_name
INVOKE DrawMenuBar,hdlg
ret
change_language ENDP
;-------------------------------------------------------------------------------------------------------------
DlgProc PROC hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL buffer[200h]:BYTE
.IF uMsg==WM_INITDIALOG
;³]©w¹Ï¥Ü
INVOKE LoadIcon,hInstance,OFFSET szIconName
INVOKE SendMessage,hDlg,WM_SETICON,ICON_SMALL,eax
;¨ú±o¥D¿ï³æ¡BÀɮפl¿ï³æ¡BÀ˵ø¤l¿ï³æ¥N½X
INVOKE LoadMenu,hInstance,OFFSET szMenuName
mov hMenu,eax
INVOKE SetMenu,hDlg,eax
INVOKE GetSubMenu,hMenu,0
mov hFileMenu,eax
INVOKE GetSubMenu,hMenu,1
mov hViewMenu,eax
;¨ú±o¨Ï¥ÎªÌ¨Ï¥Îªº»y¨¥
call GetUserDefaultLangID
.IF al==04h
.IF ah==08h
mov now_language,IDM_SCHINESE
mov edx,1
.ELSE
mov now_language,IDM_TCHINESE
sub edx,edx
.ENDIF
.ELSEIF al==07h
mov now_language,IDM_GERMAN
mov edx,2
.ELSEIF al==19h
mov now_language,IDM_RUSSIAN
mov edx,4
.ELSE
mov now_language,IDM_ENGLISH
mov edx,3
.ENDIF
;¨Ì¾Ú¨Ï¥ÎªÌ¨Ï¥Îªº»y¨¥¡A¦bhViewMenu³]©w³Q¤Ä¿ïªº¤l¿ï¶µ
mov mii.cbSize,SIZEOF MENUITEMINFO
mov mii.fMask,MIIM_STATE
mov mii.fState,MFS_CHECKED
INVOKE SetMenuItemInfo,hViewMenu,edx,1,OFFSET mii
;¨Ì¾Ú¨Ï¥ÎªÌ¨Ï¥Îªº»y¨¥¡A¦b¿ï³æ¡B¹ï¸Ü²°¦WºÙÅã¥Ü¤£¦P»y¨¥
INVOKE change_language,hDlg
.ELSEIF uMsg==WM_COMMAND
.IF lParam==0
mov eax,wParam
and eax,0ffffh ;EAX¡×¿ï³æÃѧO½X
.IF eax==IDM_EXIT
jmp quit
.ELSEIF eax==IDM_OPEN
.ELSEIF eax==IDM_HELP
mov ecx,now_language
add ecx,4
INVOKE LoadString,hInstance,ecx,ADDR buffer,SIZEOF buffer
mov ecx,now_language
lea edx,buffer
add ecx,7
add edx,10h
INVOKE LoadString,hInstance,ecx,edx,SIZEOF buffer-10h
lea edx,buffer
add edx,10h
INVOKE MessageBox,hDlg,edx,ADDR buffer,MB_OK or MB_ICONINFORMATION
.ELSE
.IF eax!=now_language
push eax
mov mii.fMask,MIIM_STATE
mov mii.fState,MFS_UNCHECKED
INVOKE SetMenuItemInfo,hViewMenu,now_language,0,OFFSET mii
pop now_language
mov mii.fState,MFS_CHECKED
INVOKE SetMenuItemInfo,hViewMenu,now_language,0,OFFSET mii
INVOKE change_language,hDlg
.ENDIF
.ENDIF
.ENDIF
.ELSEIF uMsg==WM_CLOSE
quit: INVOKE EndDialog,hDlg,NULL
.ELSE ;¨ä¥L¥¼³B²zªº°T®§ªð¦^ FALSE
mov eax,FALSE
ret
.ENDIF ;¤w³B²zªº°T®§¡Aªð¦^ TRUE
mov eax,TRUE
ret
DlgProc ENDP
;-------------------------------------------------------------------------------------------------------------
start: INVOKE GetModuleHandle,NULL
mov hInstance,eax
INVOKE DialogBoxParam,hInstance,OFFSET szDlgName,NULL,OFFSET DlgProc,NULL
INVOKE ExitProcess,eax
INVOKE InitCommonControls
;*************************************************************************************************************
END start |
½Ð¨Ì¤U±¤è¦¡²ÕĶ¡B³sµ²¡G
E:\HomePage\SOURCE\Win32\UNICODE>rc mtlg1.rc [Enter] E:\HomePage\SOURCE\Win32\UNICODE>ml mtlg1.asm /link mtlg1.res [Enter] Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: mtlg1.asm ************* UNICODE Build ************* Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /SUBSYSTEM:WINDOWS "mtlg.obj" "/OUT:mtlg1.exe" "mtlg.res" E:\HomePage\SOURCE\Win32\UNICODE>
MTLG1 °õ¦æ«á¡A¦b³B²z WM_INITDIALOG °T®§®É¡A·|¥ý¨ú±o¨Ï¥ÎªÌªº»y¨¥¡A¨£µ{¦¡²Ä 85 ¦æ¡A©I¥s GetUserDefaultLangID¡CGetUserDefaultLangID ¨S¦³°Ñ¼Æ¡A¥i¨ú±o¨Ï¥ÎªÌ¨Ï¥Îªº»y¨¥¡Aªð¦^®É¡AEAX ¬°»y¨¥ÃѧO½X ( language identifier )¡C»y¨¥ÃѧO½X¬O¤@Ó 16 ¦ì¤¸ªº¼ÆÈ¡A¸û§Cªº 8 Ӧ줸ºÙ¬°¡uPrimary Language ID¡v¡A¸û°ªªº 8 Ӧ줸ºÙ¬°¡uSubLanguage ID¡v¡A©³¤U¬O´XºØ±`¨£ªº»y¨¥¡G
Primary Language ID | SubLanguage ID | ¼ÆÈ | »¡¡@¡@©ú | ||
¼ÆÈ | ²Å¸¹ | ¼ÆÈ | ²Å¸¹ | ||
01 | LANG_ARABIC | 01 | SUBLANG_ARABIC_SAUDI_ARABIA | 0101h | ªü©Ô§B»y ( ¦b¨F¯Q¦aªü©Ô§B¨Ï¥Î ) |
01 | LANG_ARABIC | 02 | SUBLANG_ARABIC_IRAQ | 0201h | ªü©Ô§B»y ( ¦b¥ì©Ô§J¨Ï¥Î ) |
04 | LANG_CHINESE | 01 | SUBLANG_CHINESE_TRADITIONAL | 0104h | ¥¿Å餤¤å ( ¦b¤¤µØ¥Á°ê¥xÆW¨Ï¥Î ) |
04 | LANG_CHINESE | 02 | SUBLANG_CHINESE_SIMPLIFIED | 0204h | ²Å餤¤å ( ¦b¤¤°ê¤j³°¦a°Ï¨Ï¥Î ) |
04 | LANG_CHINESE | 03 | SUBLANG_CHINESE_HONGKONG | 0304h | ¥¿Å餤¤å ( ¦b»´ä¨Ï¥Î ) |
04 | LANG_CHINESE | 04 | SUBLANG_CHINESE_SINGAPORE | 0404h | ¥¿Å餤¤å ( ¦b·s¥[©Y¨Ï¥Î ) |
09 | LANG_ENGLISH | 01 | SUBLANG_ENGLISH_US | 0109h | ^¤å ( ¦b¬ü°ê¨Ï¥Î ) |
09 | LANG_ENGLISH | 02 | SUBLANG_ENGLISH_UK | 0209h | ^¤å ( ¦b^°ê¨Ï¥Î ) |
09 | LANG_ENGLISH | 03 | SUBLANG_ENGLISH_AUS | 0309h | ^¤å ( ¦b¿D¬w¨Ï¥Î ) |
07 | LANG_GERMAN | 01 | SUBLANG_GERMAN | 0107h | ¼w¤å ( ¦b¼w°ê¨Ï¥Î ) |
07 | LANG_GERMAN | 02 | SUBLANG_GERMAN_SWISS | 0207h | ¼w¤å ( ¦b·ç¤h¨Ï¥Î ) |
²Ä 86¡ã103 ¦æ§PÂ_¨Ï¥ÎªÌ¨Ï¥Îþ¤@ºØ»y¨¥¡A§â¹ïÀ³ªº¿ï¶µÃѧO½X¶ñ¨ì now_language ùØ¡C¨Ò¦p¡A¦pªG¬O¨Ï¥Î¥¿Å餤¤å¡Anow_language ¬° IDM_TCHINESE¡F¦pªG¬O«X¤å¡A«h¬O IDM_RUSSIAN¡C±µ¤U¨Ó¬O§â³Q¿ï©wªº¿ï¶µ³]¬°³Q¤Ä¿ïªº¡AµM«á©I¥s change_language °Æµ{¦¡ ( ²Ä 110 ¦æ )¡C¤p¤ì°¸ªº¹q¸£¦w¸Ëªº¬O Windows XP SP3 ¥¿Å餤¤åª©¡A·Ó²z¨Ó»¡¡A©I¥s GetUserDefaultLangID «á¡APrimary Language ID À³¬° LANG_CHINESE¡ASubLanguage ID À³¬° SUBLANG_CHINESE_TRADITIONAL¡A¤]´N¬O»¡ EAX ¤ºªºªð¦^ÈÀ³¬° 0104H ¤~¹ï¡A¦ý«oªð¦^ 0404H¡C¤p¤ì°¸¬d¾\³\¦h¸ê®Æ¡AÁÙ¬O·d¤£²M·¡¡A¦pªG¦³¥ý¶iª¾¹D¡A½Ð¨Ó«H¸Ñ´b¡A¤p¤ì°¸·P¿E¤£ºÉ¡C
change_language °Æµ{¦¡¦b 39¡ã67 ¦æ¡C¦b³o°Æµ{¦¡ùØ¡A©I¥s LoadString ¨ú±o¦r¦ê¡Aºò±µµÛ´N¬O©I¥s SetMenuItemInfo §â©Ò±oªº¦r¦ê¡AÅܦ¨¿ï¶µ¤å¦r¡C¦]¬°¿ï¶µ¤å¦r¦@¦³¤Ó¡A©Ò¥H³oºØ±¡§Î¦@¦³¤¦¸¡C¦Ó¨C¤@¦¸³£¨Ï¦r¦êÃѧO½X¼W¥[¤@¡A´N¯à¨ú±o¤U¤@Ó¦r¦ê¡A¦Ó³Ìªìªº¦r¦êÃѧO½X¡A«h¬O¨ú¨M©ó now_language¡C³Ì«áªº¨â¦¸©I¥s LoadString «h¬On³]©w¹ï¸Ü²°¼ÐÃD»P½s¿è®Ø¤å¦r¡C¦bµ²§ô change_language «e¡A©I¥s DrawMenuBar «·sø»s¿ï³æ¡A§_«h¿ï³æÁÙ¬OÅã¥Üì¥ý DC ( ³]³Æ¤º®e¡Adevice context ) ªº¤º®e¡C
DrawMenuBar ¬O¥Î¦b¨t²Î¤wø»s¦n¾ãÓµøµ¡«á¡Aµ{¦¡§ïÅÜ¿ï³æ®É¡A«·sø»s¿ï³æ¤§¥Î¡C¦pªG¤£©I¥s DrawMenuBar¡A¨º»ò¿Ã¹õ¤Wªº¿ï³æ¨Ã¤£·|§Y¨è§ïÅÜ¡CDrawMenuBar ªºì«¬¬O¡G
BOOL DrawMenuBar( HWND hWnd );
hWnd ¬O¶·«Ã¸ªº¿ï³æ©Ò¦bªºµøµ¡¡C¦pªG©I¥s¦¨¥\¡Aªð¦^Ȭ°«D¹s¡F§_«h©I¥s¥¢±Ñ¡C
·í¨Ï¥ÎªÌÂI¿ï¥D¿ï³æªº¡uÀ˵ø¡v¼u¥X¿ï¶µ¤¤ªº¥ô¦ó¤@ºØ»y¨¥®É¡Aµ{¦¡·|¸õ¨ì²Ä 132 ¦æ°õ¦æ¡C¦¹®É MTLG1 ·|¥ý¤ñ¸û¨Ï¥ÎªÌ©ÒÂI¿ïªº»y¨¥¬O§_´N¬O·í«eÅã¥Üªº»y¨¥¡A¦pªG¤£¬O¤~·| 133¡ã140¡C²Ä 133 ¦æ¡A¥ý§â¨Ï¥ÎªÌ·s¿ï©wªº»y¨¥¦s¤J°ïÅ|¡Aµy«á·|¥ÎµÛ¡C²Ä 134¡ã136 ¬O³]©w·í«e»y¨¥¿ï¶µÅܬ°¡u¥¼¤Ä¿ï¡v¡FµM«á²Ä 137 ¦æ¥Ñ°ïÅ|¨ú¥X¨Ï¥ÎªÌ·s¿ï©wªº»y¨¥¡A¨Ã¦s¤J now_language¡C±µµÛ²Ä 138¡ã139 ¦æ¡A«h¬O§â¨Ï¥ÎªÌ·s¿ï©wªº»y¨¥¿ï¶µ³]¬°¡u¤Ä¿ï¡v¡C³Ì«á©I¥s change_language °Æµ{¦¡¡A§ïÅܹï¸Ü²°¤¤ªº¿ï¶µ¤å¦r¡C
·í¨Ï¥ÎªÌÂI¿ï¥D¿ï³æªº¡u»¡©ú¡v¿ï¶µ®É¡A·|¼u¥X¤@Ó¹ï¸Ü²°¡A¨ä¤¤ªº¹ï¸Ü²°ªº¼ÐÃD¦bµ{¦¡ 120¡ã122 ¦æ¨ú±o¡A¨Ã§â¦¹¦r¦ê¦s¤J buffer ªº«e 10h Ӧ줸²Õ¤º¡C¦Ó¹ï¸Ü²°Åã¥Üªº¤å¦r¡A«h¬O¥Ñ°Ï°ìÅÜ¼Æ buffer ¦r¦êªº²Ä 10h Ó¦ì§}¶}©l¦s©ñ¡C³Ì«á´N¬O©I¥s MessageBox¡A§â¹ï¸Ü²°Åã¥Ü¥X¨Ó¡C
³oÓ¤èªk¬On¬°¨C¤@ºØ»y¨¥»s§@¤@Ӷȧt¦r¦êªíªº°ÊºA³sµ²µ{¦¡®w ( DLL )¡C·í¨Ï¥ÎªÌ©óµ{¦¡µøµ¡¤º¿ï¾Ü¬Y¤@ºØ»y¨¥®É¡A«h¸ü¤J¬Û¹ïÀ³ªº°ÊºA³sµ²µ{¦¡®w§Y¥i¡C±µµÛµ{¦¡n°µªº¨Æ¡A´N¬O§âµøµ¡¤Wªº¤å¦r¥H¨Ï¥ÎªÌ¿ï¾Üªº»y¨¥¨ú¥N¡A¦Ó¨Ï¥ÎªÌ©Ò¿ï¾Üªº»y¨¥«h¬O¨ú¦Û©ó¬Û¹ïÀ³ªº°ÊºA³sµ²µ{¦¡®w¡C
¤p¤ì°¸§â¤W±ªº MTLG1 ¥Î¦¹¤èªk«·s§ï¼g¡A§ï¼g«áªºµ{¦¡ºÙ¬° MTLG2¡CMTLG2 µøµ¡´£¨Ñ¤ºØ»y¨¥¡A¥i¨Ñ¿ï¾Ü¡C¥¦Ì¬O¥¿Å餤¤å¡B²Å餤¤å¡B¼w¤å¡B^¤å¡B«X¤å¡C¦]¬°¦³¤ºØ»y¨¥¡A©Ò¥Hn¥ý»s§@¤Ó DLL ÀÉ¡A¦Ó³o¤Ó DLL ¬O¯Â¸ê·½¡A¥ç§Y¶È§t¸ê·½¦Ó¤£§tµ{¦¡½X¡C©³¤U¬O³o¤Ó DLL Àɮתºì©l½X¤Î»s§@¤è¦¡¡Cº¥ý«Ø¥ß¤Ó¸ê·½´yzÀÉ¡GTW.RC¡BCN.RC¡BDE.RC¡BEN.RC¡BRU.RC¡A¨ä¤º¦U§t¦³³o¤ºØ»y¨¥ªº¦r¦êªí¡A¨CÓ RC Àɳ£n¦s¦¨¡uUTF-16 - NO BOM¡v®æ¦¡¡C³o¤Ó RC Àɪº¤º®e¦p¤U¡G
¥¿Å餤¤åªº¸ê·½´yzÀÉ¡GTW.RC | |
1 2 3
4 5 6 7
8 9 10 11
12 13 |
#include "c:\masm32\include\resource.h"
STRINGTABLE
BEGIN
20000,"ÀÉ®×"
20001,"¶}±Ò"
20002,"Â÷¶}"
20003,"À˵ø"
20004,"»¡©ú"
20005,"³oÓµ{¦¡¯àÅã¥Ü¤£¦P»y¨¥ªº¤¶±¡C"
20006,"\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a²{¦bÅã¥Ü¥¿Å餤¤å¡C"
20007,"¨Ï¥ÎªÌ¥i¥H¥Ñ¡uÀ˵ø¡v¿ï³æ¤¤¡A\n¬D¿ï¨ä¤¤¥ô¤@Ó»y¨¥Åã¥Ü¡C"
END |
²Å餤¤åªº¸ê·½´yzÀÉ¡GCN.RC | |
1 2 3
4 5 6 7
8 9 10 11
12 13 |
#include "c:\masm32\include\resource.h"
STRINGTABLE
BEGIN
20000,"文件"
20001,"开启"
20002,"退出"
20003,"检视"
20004,"说明"
20005,"这个程序能显示不同语言的介面。"
20006,"\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a现在显示简体中文。"
20007,"用户可以由“检视”选单中,/n挑选其"
END |
¼w¤åªº¸ê·½´yzÀÉ¡GDE.RC | |
1 2 3
4 5 6 7
8 9 10 11
12 13 |
#include "c:\masm32\include\resource.h"
STRINGTABLE
BEGIN
20000,"Datei"
20001,"Geöffnet"
20002,"Ausgang"
20003,"Ansicht"
20004,"Hilfe"
20005,"Dieses Programm kann in verschiedenen Sprachen Schnittstelle angezeigt werden."
20006,"Zeigen Sie Deutsch jetzt gleich."
20007,"Benutzer können über das Menü 'Ansicht',\nWählen Sie entweder eine Sprache aus."
END |
^¤åªº¸ê·½´yzÀÉ¡GEN.RC | |
1 2 3
4 5 6 7
8 9 10 11
12 13 |
#include "c:\masm32\include\resource.h"
STRINGTABLE
BEGIN
20000,"File"
20001,"Open"
20002,"Exit"
20003,"View"
20004,"Help"
20005,"This program can be displayed in different languages."
20006,"Now displayed in English."
20007,"Users can from 'View' menu ,\n choose either a language."
END |
«X¤åªº¸ê·½´yzÀÉ¡GRU.RC | |
1 2 3
4 5 6 7
8 9 10 11
12 13 |
#include "c:\masm32\include\resource.h"
STRINGTABLE
BEGIN
20000,"файл"
20001,"открыто"
20002,"выход"
20003,"вид"
20004,"помогите"
20005,"Эта программа может быть отображен в различных Языки интерфейса."
20006,"Дисплей на русском языке."
20007,"Люди могут из меню 'Вид'\nВыберите либо язык."
END |
±µ¤U¨Ó¬O¥H RC.EXE ½sĶ³o¤Ó¸ê·½´yzÀÉ ( *.RC )¡AµM«á¦A¥H LINK.EXE ³sµ²¨Ã«ü©w»s§@¦¨ DLL ÀÉ¡A¤èªk¦p¤U¡G
E:\HomePage\SOURCE\Win32\UNICODE>rc /n tw.rc [Enter] E:\HomePage\SOURCE\Win32\UNICODE>link /DLL /NOENTRY /SUBSYSTEM:WINDOWS /MACHINE:IX86 /OUT:TW.DLL tw.res [Enter] Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. E:\HomePage\SOURCE\Win32\UNICODE>
¥[¤W RC.EXE ªº°Ñ¼Æ¡u/n¡v·|¦b½sĶ¸ê·½´yzÀɮɡA¨Ï¦r¦êªí¤¤ªº¨CÓ¦r¦êµ²§À¦Û°Ê¥[¤W¡uNULL¡v¦r¤¸¡C³o¼Ë©I¥s LoadString ®É¡A¥i¥H¨Ï³Ì«á¤@ӰѼƳ]¬° 0¡A¦Ó¦b lpBuffer ¦ì§}±o¨ì¦r¦ê©Ò¦b¦ì§}¡C³sµ²®É¡A¥[¤W¡u/NOENTRY¡v¬O«Ø¥ß¶È§t¸ê·½¦Ó¤£§t°õ¦æ½Xªº°ÊºA³sµ²µ{¦¡®w®É¡A©Ò¥²¶·¥[¤Wªº°Ñ¼Æ¡A¥¦«ü©w¦¹°ÊºA³sµ²µ{¦¡®wµL¶i¤JÂI¡C°Ñ¼Æ¡u/MACHINE:IX86¡v¬O«ü©w©Òn«Ø¥ßªºÀɮצbþ¤@ºØ¥¥x¨Ï¥Î¡A¥i¥H¦³ ALPHA¡BARM¡BIX86¡BMIPS¡BMIPS16¡BMIPSR41XX¡BPPC¡BSH3¡BSH4 µ¥¿ï¾Ü¡A¨ä¤¤ IX86 ´N¬O IBM ¬Û®e¾÷ºØ¡C
¨C¤@Ó RC Àɳ£¨Ì·Ó¤W±ªº¤èªk¡A»s³y¥X DLL ÀÉ¡C±µ¤U¨Ón»s§@¥Dµøµ¡¡A¥Dµøµ¡©Ò»ÝªºÀɮצ³ MTLG2.ASM¡BMTLG2.RC¡BMTLG.EXE.MANIFEST ¤TÓÀɮסA©³¤U¬O³o¤TÓÀɮתº¤º®e¡A³o¤TÓÀÉ®× MTLG2.ASM ¤@©w±o¦s¦¨¡uANSI/ASCII¡v®æ¦¡¡AMTLG2.RC n¦s¦¨¡uUTF-16 - NO BOM¡v®æ¦¡¡AMTLG2.EXE.MANIFEST ¥i¥H¦s¦¨¡uANSI/ASCII¡v¡A¤]¬O¡uUTF-16 - NO BOM¡v®æ¦¡¡C
MTLG2.EXE.MANIFEST ªº¤º®e¡G | |
1 2 3
4 5 6 7
8 9 10 11
12 13 14 |
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32'
name='Microsoft.Windows.Common-Controls'
version='6.0.0.0'
processorArchitecture='*'
publicKeyToken='6595b64144ccf1df'
language='*'
/>
</dependentAssembly>
</dependency>
</assembly> |
©³¤U¬O MTLG2.RC ªº¤º®e¡G | |
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
32 33 34 35
36 37 38 39
40 41 |
#include "c:\masm32\include\resource.h"
#define RT_MANIFEST 24
#define IDC_EDIT 2000
#define IDM_OPEN 10000
#define IDM_EXIT 10001
#define IDM_HELP 10002
#define IDM_TW 20000
#define IDM_CN 21000
#define IDM_DE 22000
#define IDM_EN 23000
#define IDM_RU 24000
1 RT_MANIFEST MOVEABLE PURE "MTLG2.EXE.MANIFEST"
Unicode ICON mini_unicode.ico
MTLG2 DIALOG 300,200,200,150
STYLE WS_POPUP|WS_CAPTION|WS_VISIBLE|WS_SYSMENU|WS_MINIMIZEBOX
CAPTION "¦h»y¨¥¹ï¸Ü²°"
FONT 9,"·s²Ó©úÅé"
BEGIN
EDITTEXT IDC_EDIT,1,1,198,148,ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL
END
MainMenu MENU
BEGIN
POPUP "File"
BEGIN
MENUITEM "Open",IDM_OPEN
MENUITEM "Exit",IDM_EXIT
END
POPUP "View"
BEGIN
MENUITEM "¥¿Å餤¤å",IDM_TW
MENUITEM "简体中文",IDM_SCHINESE
MENUITEM "Deutsch",IDM_GERMAN
MENUITEM "English",IDM_ENGLISH
MENUITEM "русский",IDM_RUSSIAN
END
MENUITEM "Help",IDM_HELP
END |
©³¤U¬O MTLG2.ASM ªº¤º®e¡G | |
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
32 33 34 35
36 37 38 39
40 41 42 43
44 45 46 47
48 49 50 51
52 53 54 55
56 57 58 59
60 61 62 63
64 65 66 67
68 69 70 71
72 73 74 75
76 77 78 79
80 81 82 83
84 85 86 87
88 89 90 91
92 93 94 95
96 97 98 99
100 101 102 103
104 105 106 107
108 109 110 111
112 113 114 115
116 117 118 119
120 121 122 123
124 125 126 127
128 129 130 131
132 133 134 135
136 137 138 139
140 141 142 143
144 145 146 147
148 149 150 151
152 153 154 155
156 157 158 159
160 161 162 163
164 165 166 167
168 169 170 171
172 173 |
OPTION CASEMAP:NONE
.586
.MODEL FLAT,STDCALL
__UNICODE__ EQU 1
IDC_EDIT EQU 2000
IDM_OPEN EQU 10000
IDM_EXIT EQU 10001
IDM_HELP EQU 10002
IDM_TW EQU 20000 ;¥¿Å餤¤å
IDM_CN EQU 21000 ;²Å餤¤å
IDM_DE EQU 22000 ;¼w¤å
IDM_EN EQU 23000 ;^¤å
IDM_RU EQU 24000 ;«X¤å
INCLUDE WINDOWS.INC
INCLUDE COMCTL32.INC
INCLUDE KERNEL32.INC
INCLUDE USER32.INC
INCLUDELIB COMCTL32.LIB
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
INCLUDE C:\masm32\macros\macros.asm
;*************************************************************************************************************
.CONST
pDLL DD OFFSET szTWDLL,OFFSET szCNDLL,OFFSET szDEDLL,OFFSET szENDLL,OFFSET szRUDLL
;*************************************************************************************************************
.DATA
hInstance HANDLE ? ;¼Ò²Õ¥N½X
hMenu HANDLE ? ;¥D¿ï³æ¥N½X
hFileMenu HANDLE ? ;Àɮפl¿ï³æ¥N½X
hViewMenu HANDLE ? ;À˵ø¤l¿ï³æ¥N½X
hDLLModule HANDLE ? ;DLLªº¼Ò²Õ¥N½X
now_language DD ? ;¹ï¸Ü²°²{¦b©Ò¨Ï¥Îªº»y¤å¡C¥¿Å餤¤å®É¬°20000¡F²Å餤¤å®É¬°21000¡F¼w¤å®É¬°22000¡K
mii MENUITEMINFO <>
szHelpTitle DW ? ;Åã¥Ü¦b»¡©úµøµ¡ªº¼ÐÃDÄæ¦r¦ê¦ì§}
pHelpText DD ? ;Åã¥Ü¦b»¡©úµøµ¡ªº¦r¦ê¦ì§}
WSTR szErrorTitle,"Error" ;§ä¤£¨ì¬YºØ»y¨¥DLL®É¡A¿ù»~µøµ¡ªº¼ÐÃDÄæ¦r¦ê¦ì§}
WSTR szError,"Not found DLL.";§ä¤£¨ì¬YºØ»y¨¥DLL®É¡A¿ù»~µøµ¡ªº¦r¦ê¦ì§}
WSTR szDlgName,"MTLG2" ;¹ï¸Ü²°±ªO¦WºÙ
WSTR szIconName,"Unicode" ;¹Ï¥Ü¦WºÙ
WSTR szMenuName,"MainMenu" ;¥D¿ï³æ¦WºÙ
WSTR szTWDLL,"TW.DLL" ;¥¿Å餤¤åªºDLLÀɦW
WSTR szCNDLL,"CN.DLL" ;²Å餤¤åªºDLLÀɦW
WSTR szDEDLL,"DE.DLL" ;¼w¤åªºDLLÀɦW
WSTR szENDLL,"EN.DLL" ;^¤åªºDLLÀɦW
WSTR szRUDLL,"RU.DLL" ;«X¤åªºDLLÀɦW
;*************************************************************************************************************
.CODE
;-------------------------------------------------------------------------------------------------------------
;¸ü¤JDLLÀÉ¡A¦pªG§ä¤£¨ìDLL¡Aªð¦^®ÉCY¡F§_«hNC
change_language PROC hdlg:DWORD
INVOKE FreeLibrary,hDLLModule
mov eax,now_language
sub edx,edx ;pDLL¬°¤Ó¦ì§}©Ò²Õ¦¨ªº°}¦C¡A³o¤Ó¦ì§}¤À§O«ü¦V¦U»y¨¥ªºDLLÀɦW¡A¦]¦¹n
mov ecx,1000 ;¨ú±o¦U»y¨¥ªºDLLÀɦW¡A¥u»Ý¥ÎEAX·í¦¨«ü¼Ð§Y¥i¡AEAX»P¿ï¶µÃѧO½XªºÃö«Y¦p¤U
div ecx ;»y¤å¡G¡@¥¿Å餤¤å¡@²Å餤¤å¡@¼w¤å¡@^¤å¡@«X¤å
sub eax,20 ;EAX ¡G¡@¡@0¡@¡@¡@¡@¡@4¡@¡@¡@¡@8¡@¡@12¡@¡@16
shl eax,2 ;ÃѧO½X¡G20000¡@¡@¡@21000¡@¡@22000 23000 24000
mov ecx,pDLL[eax] ;¬G¥ý§ânow_language¤ºªº¿ï³æÃѧO½X°£¥H1000¡A§Y±o¤G¤Q´X¡A³oÓ¦ì¼Æ¦A¼¥H
INVOKE LoadLibrary,ecx ;¥|´N±oEAX
mov hDLLModule,eax ;YEAX¡×0¡Aªí¥Ü§ä¤£¨ìDLLÀÉ
.IF eax==0
stc
.ELSE
mov mii.fMask,MIIM_STRING
INVOKE LoadString,hDLLModule,20000,OFFSET mii.dwTypeData,0 ;¨ú±o¡uÀɮסv¦r¦êªº¦ì§}
INVOKE SetMenuItemInfo,hMenu,0,TRUE,ADDR mii
INVOKE LoadString,hDLLModule,20001,OFFSET mii.dwTypeData,0 ;¨ú±o¡u¶}±Ò¡v¦r¦êªº¦ì§}
INVOKE SetMenuItemInfo,hFileMenu,0,TRUE,ADDR mii
INVOKE LoadString,hDLLModule,20002,OFFSET mii.dwTypeData,0 ;¨ú±o¡uÂ÷¶}¡v¦r¦êªº¦ì§}
INVOKE SetMenuItemInfo,hFileMenu,1,TRUE,ADDR mii
INVOKE LoadString,hDLLModule,20003,OFFSET mii.dwTypeData,0 ;¨ú±o¡uÀ˵ø¡v¦r¦êªº¦ì§}
INVOKE SetMenuItemInfo,hMenu,1,TRUE,ADDR mii
INVOKE LoadString,hDLLModule,20005,OFFSET mii.dwTypeData,0 ;¨ú±o¡u³oÓµ{¡K¡v¦r¦êªº¦ì§}
INVOKE SetWindowText,hdlg,mii.dwTypeData
INVOKE LoadString,hDLLModule,20006,OFFSET mii.dwTypeData,0 ;¨ú±o¡u²{¦bÅã¡K¡v¦r¦êªº¦ì§}
INVOKE SetDlgItemText,hdlg,IDC_EDIT,mii.dwTypeData
INVOKE LoadString,hDLLModule,20004,OFFSET mii.dwTypeData,0 ;¨ú±o¡u»¡©ú¡v¦r¦êªº¦ì§}
mov edx,mii.dwTypeData
mov pHelpTitle,edx
INVOKE SetMenuItemInfo,hMenu,2,TRUE,ADDR mii
INVOKE LoadString,hDLLModule,20007,OFFSET pHelpText,0 ;¨ú±oÅã¥Ü¦b»¡©úµøµ¡ªº¦r¦ê¦ì§}
INVOKE DrawMenuBar,hdlg
clc
.ENDIF
ret
change_language ENDP
;-------------------------------------------------------------------------------------------------------------
DlgProc PROC hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.IF uMsg==WM_INITDIALOG
;³]©w¹Ï¥Ü
INVOKE LoadIcon,hInstance,OFFSET szIconName
INVOKE SendMessage,hDlg,WM_SETICON,ICON_SMALL,eax
;¨ú±o¥D¿ï³æ¡BÀɮפl¿ï³æ¡BÀ˵ø¤l¿ï³æ¥N½X
INVOKE LoadMenu,hInstance,OFFSET szMenuName
mov hMenu,eax
INVOKE SetMenu,hDlg,eax
INVOKE GetSubMenu,hMenu,0
mov hFileMenu,eax
INVOKE GetSubMenu,hMenu,1
mov hViewMenu,eax
;¨ú±o¨Ï¥ÎªÌ¨Ï¥Îªº»y¨¥
call GetUserDefaultLangID
.IF al==04h
.IF ah==08h
mov now_language,IDM_CN
mov edx,1
.ELSE
mov now_language,IDM_TW
sub edx,edx
.ENDIF
.ELSEIF al==07h
mov now_language,IDM_DE
mov edx,2
.ELSEIF al==19h
mov now_language,IDM_RU
mov edx,4
.ELSE
mov now_language,IDM_EN
mov edx,3
.ENDIF
;¨Ì¾Ú¨Ï¥ÎªÌ¨Ï¥Îªº»y¨¥¡A¦bhViewMenu³]©w³Q¤Ä¿ïªº¤l¿ï¶µ
mov mii.cbSize,SIZEOF MENUITEMINFO
mov mii.fMask,MIIM_STATE
mov mii.fState,MFS_CHECKED
INVOKE SetMenuItemInfo,hViewMenu,edx,1,OFFSET mii
;¨Ì¾Ú¨Ï¥ÎªÌ¨Ï¥Îªº»y¨¥¡A¦b¿ï³æ¡B¹ï¸Ü²°¦WºÙÅã¥Ü¤£¦P»y¨¥
INVOKE change_language,hDlg
jc not_found_dll
.ELSEIF uMsg==WM_COMMAND
.IF lParam==0
mov eax,wParam
and eax,0ffffh ;EAX¡×¿ï³æÃѧO½X
.IF eax==IDM_EXIT
jmp quit
.ELSEIF eax==IDM_OPEN
.ELSEIF eax==IDM_HELP ;¨Ï¥ÎªÌ«ö¡u»¡©ú¡v¿ï¶µ®É¡AÅã¥Ü»¡©úµøµ¡
INVOKE MessageBox,hDlg,pHelpText,pHelpTitle,MB_OK or MB_ICONINFORMATION
.ELSEIF eax!=now_language
push eax
mov mii.fMask,MIIM_STATE
mov mii.fState,MFS_UNCHECKED
INVOKE SetMenuItemInfo,hViewMenu,now_language,0,OFFSET mii
pop now_language
mov mii.fState,MFS_CHECKED
INVOKE SetMenuItemInfo,hViewMenu,now_language,0,OFFSET mii
INVOKE change_language,hDlg
jnc finish
not_found_dll: INVOKE MessageBox,hDlg,OFFSET szError,OFFSET szErrorTitle,MB_OK or MB_ICONEXCLAMATION
.ENDIF
.ENDIF
.ELSEIF uMsg==WM_CLOSE
quit: INVOKE EndDialog,hDlg,NULL
.ELSE ;¨ä¥L¥¼³B²zªº°T®§ªð¦^ FALSE
mov eax,FALSE
ret
.ENDIF ;¤w³B²zªº°T®§¡Aªð¦^ TRUE
finish: mov eax,TRUE
ret
DlgProc ENDP
;-------------------------------------------------------------------------------------------------------------
start: INVOKE GetModuleHandle,NULL
mov hInstance,eax
INVOKE DialogBoxParam,hInstance,OFFSET szDlgName,NULL,OFFSET DlgProc,NULL
INVOKE ExitProcess,eax
INVOKE InitCommonControls
;*************************************************************************************************************
END start |
¤W±¤TÓÀɮסAMTLG2.RC ¦]§t¦³¸U°ê½X¤~¯à¨Ï¥Î¤£¦P»y¨¥¤å¦r¡A©Ò¥H¥²¶·¦s¦¨¡uUTF-16 - NO BOM¡v®æ¦¡¡A¦Ó MTLG2.ASM »P MTLG2.EXE.MANIFEST ¤@©wn¦s¦¨¡uANSI/ASCII¡v®æ¦¡¤~¯à¨Ï ML.EXE ²ÕĶ¡A©Ò»s§@ªº°õ¦æÀɤ~¥i°õ¦æ¡CµM«á¥H¤U±¤è¦¡²ÕĶ¡B³sµ²¡G
E:\HomePage\SOURCE\Win32\UNICODE>rc mtlg2.rc [Enter] E:\HomePage\SOURCE\Win32\UNICODE>ml mtlg2.asm /link mtlg2.res [Enter] Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: mtlg2.asm ************* UNICODE Build ************* Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /SUBSYSTEM:WINDOWS "mtlg2.obj" "/OUT:mtlg2.exe" "mtlg2.res" E:\HomePage\SOURCE\Win32\UNICODE>
³oµ{¦¡»P MTLG1 ®t¤£¦h¡A³Ì¤jªº®t§O¦b change_language °Æµ{¦¡¡Cchange_language ©I¥s LoadLibrary ¸ü¤J§t¦³¨Ï¥ÎªÌ¿ï©w»y¨¥ªº DLL ÀÉ¡A³oÓ DLL Àɧt¦³¦r¦êªí¡C¦Ü©ón¸ü¤Jþ¤@Ó DLL ÀÉ¡A¦bµ{¦¡ªº²Ä 54¡ã60 ¦æpºâ¨äÀɦW¦ì§}¡C¦pªG¥¢±Ñ¡A«h³]©w¶i¦ìºX¼Ð¡Aªð¦^µøµ¡¨ç¦¡¡F¦pªG¦¨¥\¡A«h¸ü¤J¦U¦r¦ê¡A¨Ã³]©w¬ÛÃö¿ï¶µ¤å¦r©Î¼ÐÃDÄæ¡A³Ì«á²M°£¶i¦ìºX¼Ð¡Aªð¦^µøµ¡¨ç¦¡¡C
¥t¥~¦¹µ{¦¡È±o¤@´£ªº¬O¡A¤@¶i¤J change_language¡A²Ä¤@Ó°õ¦æªº¬O©I¥s FreeLibrary¡C·íµ{¦¡ÀY¤@¦¸©I¥s change_language ®É¡A¨Æ¹ê¤W¨Ã¨S¦³¸ü¤J¥ô¦ó»y¨¥ªº°ÊºA³sµ²®w¡A©Ò¥H³o¤@¦¸°õ¦æ·|¦³¿ù»~¡A¤£¹L¨Ã¤£¥²³B²z¡C¦¹«á¡A¨C¦¸·í¨Ï¥ÎªÌ§ïÅÜ»y¨¥®É¡A³£·|©I¥s change_language¡A¤@¶i¦¹°Æµ{¦¡¡Aº¥ý°µªº´N·|ÄÀ©ñì¥ý»y¨¥ªº°ÊºA³sµ²®w¡C¬°¦ó¤£§âÄÀ©ñ°ÊºA³sµ²®w¼g¦b¤w¸g¸ü¤J©Ò¦³¦r¦ê¤§«á©O¡Hì¦]¬O¦pªG¼g¦b¸ü¤J©Ò¦³¦r¦ê¤§«á¡A¨º»ò·í¨Ï¥ÎªÌ¿ï¾Ü¡u»¡©ú¡v¿ï¶µ®É¡A°ÊºA³sµ²µ{¦¡®w¤w³QÄÀ©ñ¡A´N·|¥X²{¹H¤Ï¦s¨ú³W«h¡C
¦³Å²©ó¦b½s¿è²Õ¦X»y¨¥ì©l½X®É¡A¦pn¨Ï¥Î¸U°ê½X¡A¥²¶·§â¤¤¤å¥H¼ÆȪº¤è¦¡ªí¥Ü¡C¦Ñ¹ê»¡¡A³o¹ê¦b¦³ÂI¨à³Â·Ð¡C¤p¤ì°¸§Æ±æ¯à¹³^¤å¤@¼Ë¡A¦³Ó¥¨¶°´N¯à§¹¦¨¡C¦ý¥ª«ä¥k·Q¡A¦ü¥G«Ü§xÃø¡C¤£¹L¦pªG¼gÓ¹ï¸Ü²°µ{¦¡¡AÅý¨Ï¥ÎªÌ¿é¤J¤¤¤å¡B^¤å¡A¬Æ¦Ü¤¤^¤å§¨Âøªº¦r¦ê¡A¤¤¤å¥H Big¡Ð5 ½s½X¡A^¤å¥H ASCII ½s½X¡CµM«á«öÓ¡uÂà´«¡v«ö¶s¡A´N¯à§â¿é¤Jªº¦r¦ê¡A¥H¸U°ê½X½s½Xªº¤è¦¡§e²{¦b¥t¤@Ó½s¿è®Ø¡A¤£¤]´î»´¤F³Â·Ð¶Ü¡H¹ê»Ú°õ¦æªºµe±¦p¤U¹Ï¡G
¤p¤ì°¸¼¶¼g A2U.ASM ªº·Qªk¥»¨Ó¬O³o¼Ëªº¡GÅý¨Ï¥ÎªÌ¦b¿é¤J½s¿è®Ø¿é¤J¦r¦ê«á«ö¤U¡uÂà´«¡v«ö¶s¡AA2U ·|¥ý¨ú±o¸Ó¦r¦êªø«×¡AµM«á¥H¦¹¦r¦êªø«×¦V¨t²Î¥Ó½Ð°O¾ÐÅé¡A¦A©I¥s GetWindowText ´N¥i¥H§â¦r¦êŪ¨ì³oÓ°O¾ÐÅ餺¡A³oÓ¦r¦ê¬° ASCII ¦r¦ê©Î Big¡Ð5 ¦r¦ê¡A¬Æ¦Ü¥i¯à¬O Big¡Ð5 »P ASCII ¤¤^¤å§¨Âøªº¦r¦ê¡CµM«á¦A©I¥s MultiByteToWideChar ¨â¦¸¡A²Ä¤@¦¸¥i¨ú±on¦h¤jªº°O¾ÐÅé¤~¯à®e¯ÇÂà´««áªº¦r¦ê¡A²Ä¤G¦¸«K¯u¥¿ªº§â ASCII ¦r¦ê¡BBig¡Ð5 ¦r¦ê¡A¬Æ¦Ü¥i¯à¬O Big¡Ð5 »P ASCII ¤¤^¤å§¨Âøªº¦r¦êÂà´«¦¨¸U°ê½X¦r¦ê¡C
¤p¤ì°¸¨Ì·Ó¤W±¤èªk¡A¼g¦n¤F A2U.ASM¡A¤@¤Á³£ºâ¶¶§Q¡A¤]¯à¹ê»Ú¤u§@¡C¦ý¬O¦³¨Ç¦r¡A¨Ò¦p珉¡B煊¡B堃¡B喆¡B嚞¡B瀞¡B斈¡Kµ¥¦rµLªkÂà´«¡Cì¦]¬O Big¡Ð5 ¨S¦³¦¬¿ý³o¨Ç¦r¡A©Ò¥H§Y¨Ï¯à¦b¿é¤J½s¿è®Ø¤¤¿é¤J³o¨Ç¦r¡A¤]µLªkÂà´«¡CA2U ©I¥s GetWindowText ±o¨ì¦r¦ê¡A©Ò±o¨ìªº¦r¦ê¬O¥H ASCII ©Î Big¡Ð5 ½s½X¡A©Ò¥H³o¨Ç¦rµLªk¥¿±`³QÂà´«¦¨¸U°ê½X¡C¨Ó·½¦r¦ê´N¬O¿ù»~ªº¡A±z¤S«ç¯à´Á«Ý·|¥¿½TªºÂà´«©O¡H©Ò¥H¤£¯à¥Î GetWindowText ¨ú±o ASCII ©Î Big¡Ð5 ¦r¦ê¡A¤]µLªk¥Î MultiByteToWideChar Âà´«¦r¦ê¡CÁöµM¦p¦¹¡A¤p¤ì°¸ÁÙ¬O§Æ±æ¯à¤¶²Ð MultiByteToWideChar ªº¥Îªk¡A²¦³º³oÓ API ¤]¸ò¤å¦r½s½X¦³Ãö¡AÂ÷³o³¹¥DÃD¤£»·¡C¦³Ãö MultiByteToWideChar ªº¥Îªk¡A½Ð°Ñ¦Òµù¤G¡C
¨¥Âk¥¿¶Ç¡C¬JµM¤£¯à¥Î GetWindowText ¨ú±o ASCII ©Î Big¡Ð5 ¦r¦ê¡A¨º¸Ó«ç»ò¿ì©O¡H¨Æ¹ê¤W¡A¥i¥H§Q¥Î Windows XP ªº©Ê½è¡A§ï©I¥s GetWindowTextW ´N¥i¥H¤F¡Cnª`·N¡A©I¥s GetWindowTextW «á¡A©Ò±oªº¦r¦ê´N¬O¥H¸U°ê½X½s½Xªº¦r¦ê¡A¤]´N¤£¥Î¦A©I¥s MultiByteToWideChar ¤F¡C
©³¤U¬O A2U.RC¡G
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27 |
#include "c:\masm32\include\resource.h"
#define DEF_STYLE ES_AUTOHSCROLL|ES_AUTOVSCROLL|ES_MULTILINE
#define IDC_QUIT 3000
#define IDC_INPUT 3001
#define IDC_OUTPUT 3002
#define IDC_COPY 3003
#define IDC_CHANGE 3004
#define RT_MANIFEST 24
A2U DIALOG 200,200,176,110
STYLE WS_CAPTION|WS_VISIBLE|WS_SYSMENU
CAPTION "BIG-5 ½XÂà´«¦¨¸U°ê½X"
FONT 10,"·s²Ó©úÅé"
BEGIN
LTEXT "¿é¤J¦r¦ê¡G",100, 5, 8, 40, 12
EDITTEXT IDC_INPUT, 42, 5,125, 36,DEF_STYLE|ES_WANTRETURN
LTEXT "¿é¥X¦r¦ê¡G",101, 5, 47, 40, 12
EDITTEXT IDC_OUTPUT, 42, 46,125, 36,DEF_STYLE|ES_READONLY
PUSHBUTTON "Âà´«",IDC_CHANGE, 5, 90, 50, 13
PUSHBUTTON "½Æ»s",IDC_COPY, 63, 90, 50, 13
PUSHBUTTON "Â÷¶}",IDC_QUIT, 121, 90, 50, 13
END
1 RT_MANIFEST MOVEABLE PURE "A2U.EXE.MANIFEST"
Search ICON Help2.ico |
©³¤U¬O A2U.EXE.MANIFEST Àɮתº¤º®e¡G
1 2 3
4 5 6 7
8 9 10 11
12 13 14 |
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32'
name='Microsoft.Windows.Common-Controls'
version='6.0.0.0'
processorArchitecture='*'
publicKeyToken='6595b64144ccf1df'
language='*'
/>
</dependentAssembly>
</dependency>
</assembly> |
©³¤U¬O A2U.ASM ì©l½X¡G
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
32 33 34 35
36 37 38 39
40 41 42 43
44 45 46 47
48 49 50 51
52 53 54 55
56 57 58 59
60 61 62 63
64 65 66 67
68 69 70 71
72 73 74 75
76 77 78 79
80 81 82 83
84 85 86 87
88 89 90 91
92 93 94 95
96 97 98 99
100 101 102 103
104 105 106 107
108 109 110 111
112 113 114 115
116 117 118 119
120 121 122 123
124 125 126 127
128 129 130 131
132 133 134 135
136 137 138 139
140 141 142 143
144 145 146 147
148 149 150 151
152 153 154 155
156 |
OPTION CASEMAP:NONE
.586
.MODEL FLAT,STDCALL
INCLUDE WINDOWS.INC
INCLUDE COMCTL32.INC
INCLUDE KERNEL32.INC
INCLUDE USER32.INC
INCLUDELIB COMCTL32.LIB
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
IDC_QUIT EQU 3000
IDC_INPUT EQU 3001
IDC_OUTPUT EQU 3002
IDC_COPY EQU 3003
IDC_CHANGE EQU 3004
;*************************************************************************************************************
.CONST
szDlgName DB "A2U",0 ;¹ï¸Ü²°±ªO¦WºÙ
szIconName DB "Search",0 ;¹Ï¥Ü¦WºÙ
szDW DB " DW "
szWordFmt DB "0%xh,",0
;*************************************************************************************************************
.DATA
hInstance DD ? ;¼Ò²Õ¥N½X
hEdtInput DD ? ;¿é¤J½s¿è®Ø¥N½X
hEdtOutput DD ? ;¿é¥X½s¿è®Ø¥N½X
;*************************************************************************************************************
.CODE
;-------------------------------------------------------------------------------------------------------------
;§âhEdtInput½s¿è®Ø¤ºªº¤å¦rÅܦ¨¤Q¤»¶i¦ì¼ÆÈ¡AÅã¥Ü¦bhEdtOutput¤º
;¿é¤J¡GEAX¡ÐhEdtInput½s¿è®Ø¤ºªº¤å¦r½s¿è®ØªºÓ¼Æ¡A¥H¦r²Õ¬°³æ¦ì
;¡@¡@¡@hEdtInput¡ÐhEdtInput½s¿è®Øªº¥N½X
;¡@¡@¡@hEdtOutput¡ÐhEdtOutput½s¿è®Øªº¥N½X
;¿é¥X¡GhEdtOutput½s¿è®Ø·|Åã¥Ü¤Q¤»¶i¦ì¼ÆÈ
get_hex_code PROC USES esi edi
LOCAL n,hMemIn,hMemOut,cbPerLine:DWORD
mov n,eax
and eax,0fffffff0h
inc n
shl eax,1 ;EAX¡×2*EAX
add eax,20h
INVOKE GlobalAlloc,GPTR,eax
mov hMemIn,eax
INVOKE GetWindowTextW,hEdtInput,hMemIn,n
mov eax,n
sub edx,edx
shl eax,3
mov ecx,100- SIZEOF szDW
sub eax,n ;EAX¡×7n
push eax
div ecx ;EAX¡×INT( 7n/(100-SIZEOF szDW) )
inc eax ;EAX¡×EAX¡Ï1¡×¦b¿é¥X½s¿è®Ø¤ºªº¦r¦ê³Q¤À¦¨ªº¦æ¼Æ¡×Line
sub edx,edx
mov ecx,SIZEOF szDW+2
mul ecx ;x¡×x¡×Line*( SIZEOF szDW+2 )¡×¦]szDW¤Î´«¦æ©Ò³y¦¨¼W¦hªº¦ì¤¸²ÕÓ¼Æ
pop edx
add edx,eax
add edx,800h ;EDX¡×x¡Ï7n¡Ï800h¡A¦h¥X¨Óªº800h¬O¬°¤F¥H¨¾¸U¤@
INVOKE GlobalAlloc,GPTR,edx
mov hMemOut,eax
mov edi,eax
inc n ;¦]¬°¤@¶}©l«K´î¤@¡A©Ò¥H¦¹³Bn¥ý¥[¤@
xor eax,eax
mov esi,hMemIn
jmp @f
.WHILE n>0
lodsw
INVOKE wsprintf,edi,OFFSET szWordFmt,eax
add edi,eax
add cbPerLine,eax
.IF cbPerLine>100 ;¦pªG¶W¹L100Ӧ줸²Õ¡A«h´«¦æ
mov ax,0a0dh
dec edi
stosw
@@: push esi
mov ecx,SIZEOF szDW ;§âszDW¦r¦ê¦s¤JEDI©Ò«ü¦ì§}
mov esi,OFFSET szDW
rep movsb
mov cbPerLine,SIZEOF szDW
pop esi
.ENDIF
dec n
.ENDW
mov BYTE PTR [edi-1],0
INVOKE SetWindowText,hEdtOutput,hMemOut
INVOKE GlobalFree,hMemIn
INVOKE GlobalFree,hMemOut
ret
get_hex_code ENDP
;-------------------------------------------------------------------------------------------------------------
DlgProc PROC hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL cbOutput,hMemTitle:DWORD
.IF uMsg==WM_INITDIALOG
;¸ü¤J¹Ï¥Ü
INVOKE LoadIcon,hInstance,OFFSET szIconName
INVOKE SendMessage,hDlg,WM_SETICON,ICON_SMALL,eax
;¨ú±o¿é¤J»P¿é¥X½s¿è®Ø¥N½X
INVOKE GetDlgItem,hDlg,IDC_INPUT
mov hEdtInput,eax
INVOKE GetDlgItem,hDlg,IDC_OUTPUT
mov hEdtOutput,eax
.ELSEIF uMsg==WM_COMMAND
mov ecx,wParam
mov edx,wParam
shr ecx,10h ;ECX¡×³qª¾½X
and edx,0ffffh ;EDX¡×±±¨î¤¸¥óÃѧO½X
.IF ecx==BN_CLICKED
.IF edx==IDC_QUIT
jmp quit
.ELSEIF edx==IDC_CHANGE
INVOKE GetWindowTextLengthW,hEdtInput
.IF eax!=0
call get_hex_code
.ENDIF
.ELSEIF edx==IDC_COPY
INVOKE GetWindowTextLength,hEdtOutput
.IF eax!=0
mov cbOutput,eax
and eax,0fffffff0h
add eax,20h
inc cbOutput ;»Ý¥[¤WNULL¦r¤¸
INVOKE GlobalAlloc,GPTR,eax
mov hMemTitle,eax
INVOKE GetDlgItemText,hDlg,IDC_OUTPUT,eax,cbOutput
INVOKE OpenClipboard,hDlg
call EmptyClipboard
INVOKE SetClipboardData,CF_TEXT,hMemTitle
INVOKE GlobalFree,hMemTitle
call CloseClipboard
.ENDIF
.ENDIF
.ENDIF
.ELSEIF uMsg==WM_CLOSE
quit: INVOKE EndDialog,hDlg,NULL
.ELSE ;¨ä¥L¥¼³B²zªº°T®§ªð¦^ FALSE
mov eax,FALSE
ret
.ENDIF ;¤w³B²zªº°T®§¡Aªð¦^ TRUE
mov eax,TRUE
ret
DlgProc ENDP
;-------------------------------------------------------------------------------------------------------------
start: INVOKE GetModuleHandle,NULL
mov hInstance,eax
INVOKE DialogBoxParam,hInstance,OFFSET szDlgName,NULL,OFFSET DlgProc,NULL
INVOKE ExitProcess,eax
INVOKE InitCommonControls
;*************************************************************************************************************
END start |
©³¤U¥ý¬Ý¬Ý A2U ªºµe±¡AµM«á»¡©ú A2U µ{¦¡¡C
·í¨Ï¥ÎªÌ¦b A2U ¹ï¸Ü²°ªº¿é¤J½s¿è®Ø¿é¤J¦n¦r¦ê«á¡A«ö¤U¡uÂà´«¡v«ö¶s¡Aµ{¦¡«K·|±o¨ì Windows ¨t²Î¶Ç¨Óªº WM_COMMAND °T®§¡A¨ä wParam ¬° IDC_CHANGE¡A¦]¦¹·|°õ¦æ²Ä 107 ¦æªºµ{¦¡½X¡C¸g¹L¤@³s¦ê¤ñ¹ï«ö¤UþÓ«ö¶s¡A¨Ó¨ì²Ä 115 ¦æ©I¥s GetDlgItemTextLengthW¡A¨ú±o¿é¤J½s¿è®Ø¤º®eªºªø«×¡A³oùØ©Ò»¡ªº¤º®eªø«×¬O¥H¦r²Õ ( ¦r²Õ^¤å¬O word¡A¤@Ó¦r²Õªø 16 ¦ì¤¸ ) ¬°³æ¦ì¡A¥B¤£§t NULL¡C¨Ò¦p¿é¤J½s¿è®Ø¤º®e¬°¡uWin32²Õ¦X»y¨¥¡v¡A¨º»ò¿é¤J½s¿è®Ø¤º®eªºªø«×¬° 9 Ó¦r¤¸¡A¥ç§Y 18 Ӧ줸²Õ¡C±µ¤U¨Ó²Ä 116 ¦æ¡AÀˬd¿é¤J½s¿è®Ø¤º®eªºªø«×¬O§_¬°¹s¡A¦pªG¬Oªº¸Ü¡Aªí¥Ü¨Ï¥ÎªÌ©|¥¼¿é¤J¥ô¦ó¦r¦ê¡Aª½±µµ²§ô³B²z WM_COMMAND °T®§¡Aªð¦^¨t²Î¡C¦pªG¤£¬°¹s¡A´Nn©I¥s get_hex_code °Æµ{¦¡ ( ²Ä 117 ¦æ )¡C
get_hex_code °Æµ{¦¡¦b 33¡ã92 ¦æ¡C³oӰƵ{¦¡¬O§â¨Ï¥ÎªÌ¿é¤Jªº¦r¦ê¡AÅܦ¨¸U°ê½X½s½Xªº¤Q¤»¶i¦ì¼ÆÈ¡AÅã¥Ü¦b¿é¥X½s¿è®ØùØ¡C¨Ò¦p¡A¨Ï¥ÎªÌ¿é¤J¡uWin32²Õ¦X»y¨¥¡v¡A´N·|¦b¿é¥X½s¿è®ØÅã¥Ü¡u DW 057h,069h,06eh,033h,032h,07d44h,05408h,08a9eh,08a00h,00h¡v¡A¡uW¡v¦r¥Àªº¸U°ê½X¼ÆȬO 57h¡B¡ui¡vªº¸U°ê½X¼ÆȬO 69h¡K¡K¡Cget_hex_code °Æµ{¦¡°õ¦æ®É¡ADlgProc ·|§ân³B²zªº¦r¤¸Ó¼Æ¦s¦b EAX ùØ¡A¶Çµ¹ get_hex_code¡A¦ý¬O³oÓ¦r¤¸Ó¼Æ¤£¥]§t NULL¡C©Ò¥H get_hex_code ·|¥ý§â EAX¡A¦s¦b°Ï°ìÅܼơAn¡AùØ¡A¨Ã¨Ï n ¼W¥[¤@ ( ²Ä 43 ¦æ )¡A³o¼Ë´N¥]§t¤F NULL ¦r¤¸¡C±µ¤U¨Ón¦V¨t²Î¥Ó½Ð°t¸m°O¾ÐÅé¡A¥Ó½Ð°O¾ÐÅ骺¤j¤p¬O EAX ªº¨â¿¡A¦]¬°¤@Ó¸U°ê½X¦r¤¸»Ýn¨âӦ줸²Õ¡A¤S¬°¤F§Æ±æ¥Ó½Ðªº°O¾ÐÅé¤j¤p¬O¥H para ¬°³æ¦ì ( 16 Ӧ줸²Õ¬°¤@Ó para )¡A¥H¤Î¥H¨¾¸U¤@¡A¦]¦¹¥Ó½Ð¸û¤j¤@ÂIªº°O¾ÐÅé¡C²Ä 41¡B42¡B44 ¦æªºµ{¦¡½X¹ê²{¤Wz¥Øªº¡C¥Ó½Ð°t¸m¦n°O¾ÐÅé«á¡A§â°O¾ÐÅé¦ì§}Àx¦s¦b hMemIn ùØ¡C²Ä 47 ¦æ¡A´N¬O§â¿é¤J½s¿è®Øªº¦r¦ê²¾¨ì hMemIn ùØ¡A³o®ÉÔ hMemIn ùتº¦r¦ê¤w¸g¬O¸U°ê½X½s½Xªº¦r¦ê¤F¡C
²Ä 48¡ã61 ¦æ¡A¬Opºâ hMemIn ùتº¸U°ê½X¦r¦ê¤¤ªº¨CÓ¦rÅܦ¨¤@ÓÓ¤Q¤»¶i¦ì¼ÆȮɡA©Ò»Ýªº°O¾ÐÅé¤j¤p¡Cµ{¦¡²Ä 55 ¦æºâ¥X¦b¿é¥X½s¿è®Ø»Ýn¦³´X¦æªºì©l½X¡C³oÓ¦æ¼Æ¡A¥i¥H¥Î 7n¡Ò(100-SIZEOF szDW) ±o¨ì¡A¦¹³Bªº n ¬O¨Ï¥ÎªÌ¿é¤Jªº¦r¦ê©Ò§t¦r¤¸¼Æ¡A¥²¶·¥]§t NULL ¦r¤¸¡C¤£½×¤¤¤å©Î^¤å¡A¥H¸U°ê½X½s½Xªº¨CÓ¦r¡A¦b²Õ¦X»y¨¥ì©l½X¤¤³£»Ýn 7 Ӧ줸²Õªí¥Ü¡C¨Ò¦p²Õ¦X»y¨¥ªº¡u²Õ¡v¡A¸U°ê½X¬O¡u07d44h¡v¡A¦A¥[¤W¤@Ó¡u,¡v¡A©Ò¥H»Ýn 7 Ӧ줸²Õ¡C¦b²Ä 50 ¦æ§â EAX ¥ª²¾¤TӦ줸¡A´N¬Û·í©ó¼¥H 8¡A¦A´î¥h¤@Ó n¡A´N±o¨ì 7n¡C¤p¤ì°¸§Æ±æ¨C¤@¦æ¦r¤£¶W¹L 110 Ӧ줸²Õ ( ¦¹³B¤@Ó¦r¦û¾Ú¤@Ӧ줸²Õ )¡A©Ò¥H¶W¹L 100 Ó¦r´N±o´«¦æ¡C¦]¦¹¡A¦b 51 ¦æ¡A§â (100-SIZEOF szDW) ¦s¤J ECX ùØ¡A·í¦¨°£¼Æ¡Cºâ¥X¦æ¼Æ¤§«á¡A¦A¼¤W ( SIZEOF szDW+2 )¡A´N±o¨ì¡u DW ¡v¥H¤Î´«¦æªº¨âÓ¦r¤¸¡AÁ`¦@n¦û¥Î¦h¤Ö¦ì¤¸²Õ¡C
±µµÛ¡A¥Hèèpºâ©Ò±oªº¦ì¤¸²ÕӼơA¦V¨t²Î¥Ó½Ð°t¸m°O¾ÐÅé ( ²Ä 62 ¦æ )¡A¨Ã§â°O¾ÐÅé¥N½X°O¿ý©ó hMemOut ùØ¡CµM«á¶i¤J°j°é¡A°j°é°õ¦æªº¦¸¼Æ¡A§Y¬°¸U°ê½X¦r¦êªº¦r¤¸¼Æ¡A¥H n ªí¥Ü¡C¦]¬°¨C¤@¦æªº«e´XӦ줸²Õ³£¬O szDW ¦r¦ê¡A©Ò¥H¥ý¸õ¨ì 78 ¦æ¡A³o¼Ëªº¸ÜÁÙ¨S³B²z¥ô¦ó¤@Ó¸U°ê½X¡A´N¤w¸g´î¤@¤F¡A©Ò¥H²Ä 65 ¦æ¥ý¥[¤@¡C¶i¤J°j°é«e¡A§â EDI ·í°µ«ü¼Ð¡A«ü¦V hMemOut ( ²Ä 64 ¦æ )¡An¶ñ¤Jªº¦ì§}¡FESI «h¬O«ü¦V hMemIn ¦r¦ê¡A§Y±N³B²zªº¸U°ê½X¦r¦êªº¦ì§}¡C¨C¤@¦æ²{¦³¦h¤Ö¦ì¤¸²Õ¡A¦s©ó cbPerLine ùØ¡A¦]¦¹¨C³B²z§¹¤@Ó¦r¤¸¡A´NÀˬd¬O§_¶W¹L 100¡A¦pªG¬Oªº¸Ü´N´«¦æ¡C´«¦æn°µªº¨Æ¦³§â 0a0dh ¦s¤J EDI ©Ò«ü¦r¦ê¡B§â szDW ¦r¦ê¶ñ¤J EDI ©Ò«ü¦ì§}¡B«³] cbPerLine¡C
ANSI ¨CÓ¦r¤¸¶È¦û¤@Ӧ줸²Õ¡F¦Ó UNICODE «h¦û¨âӦ줸²Õ¡A¦]¦¹ºÙ UNICODE ¬°¼e¦r¤¸ ( wide character )¡C
n§â¨Ï¥ÎªÌ¿é¤Jªº ASCII ½X©Î Big-5 ½X¡A¬Æ¦Ü¨âªÌ§¨Âøªº¦r¦ê¡AÂà´«¦¨¸U°ê½X¡A©Ò¨Ï¥Îªº API ºÙ¬° MultiByteToWideChar¡C¦r±¤Wªº·N«ä¬O§â¦hӦ줸²Õ¦r¦êÂà´«¦¨¼e¦r²Õ¡A¦hӦ줸²Õ¦r¦êªº·N«ä¬O«ü¡A³oºØ¦r¦ê¥]§t¥þ¬°^¤å¦r¡B¤¤^§¨Âø©Î¥þ¬°¤¤¤å¦r¡F¦Ó©Ò¿×ªº¼e¦r²Õ¡A«h¬O«ü¸U°ê½X¡C©Ò¥H¥i¥H²q·Q±o¨ì¡A³oÓ API ¬Û·í½ÆÂø¡A¥ú¬On¤À¿ë¤¤¤å©Î^¤å´N¤w¸g«Ü½ÆÂø¤F¡C©¯¦n³o¨Ç¨Æ±¡¡A³£¥Ñ·L³n¸Ñ¨M¤F¡A¨Ã¥B¤w¸g¹ê§@§¹¦¨¤F¡CMultiByteToWideChar ªºì«¬¬O¡G
int MultiByteToWideChar( UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar );
²Ä¤@ӰѼơACodePage¡A¬O«ü¦hӦ줸²Õ¦r¦êªº¡u¶½X¡v¡A·N§YnÂà´«¦r¦êªº¶½X¡A¥i¥H¬O¤U±ªº¤@ºØ¡G
¶½X | ¼ÆÈ | »¡¡@¡@©ú |
CP_ACP | 0 | ANSI ¶½X¡C¹ï©ó Big-5 ½X¦Ó¨¥¡A¤]¬O¨Ï¥Î CP_ACP¡C¨Æ¹ê¤W¡A¹ï©ó¦h¦ì¤¸²Õ½s½XªºÀô¹Ò ( ¦p¤¤¤éÁú®õ¤åµ¥ )¡ACP_ACP »P CP_OEMCP ¬O¬Û¦Pªº¡CCP_ACP »P CP_OEMCP §ó¸Ô²Óªº»¡©ú¡A½Ð«ö³oùØ¡C |
CP_OEMCP | 1 | OEM ¶½X |
CP_MACCP | 2 | Macintosh ¶½X ( ³Áª÷¶ð¶½X ) |
CP_THREAD_ACP | 3 | ¦b°õ¦æºü¤¤Âà´« ANSI ¶½X¡C |
CP_SYMBOL | 42 | Symbol ¶½X ( 42 ¶½X )¡A¥u¯à¦b Windows 2000 ¥H«áªº¨t²Î¨Ï¥Î¡C |
CP_UTF7 | 65000 | UTF-7¡C |
CP_UTF8 | 65001 | §â UTF-8 Âà´«¦¨¸U°ê½X¡A³o®É²Ä¤GӰѼơAdwFlags¡A¥²¶·³]¬° 0 ©Î MB_ERR_INVALID_CHARS¡A§_«h·|²£¥Í ERROR_INVALID_FLAGS ¿ù»~½X¡C |
²Ä¤GӰѼơAdwFlags¡A¥Î¨Ó«ü©w¤@¨ÇÃB¥~ªº³]©w¡A¥H«ü¥Ü¨t²Î¦p¦óÂà´«¡A¥i¥H¬O¤U±¼ÆÈ¡G
dwFlags | ¼ÆÈ | »¡¡@¡@©ú |
MB_PRECOMPOSED | 1 | ¤º©wÈ¡A¤£¥i©M MB_COMPOSITE ¦X¥Î¡C¦³¨Ç§t¦³«µ²Å¸¹ªº¦è¬v¦r¥À¡A¨Ò¦pÄ¡A¨Ï¥Î MB_PRECOMPOSED ®É¡A·|Åܦ¨¤@Ó¸U°ê½Xªº¦r¤¸¡A¡uÄ¡v( U+00C4 )¡C |
MB_COMPOSITE | 2 | ¤£¥i©M MB_PRECOMPOSED ¦X¥Î¡C¦³¨Ç§t¦³«µ²Å¸¹ªº¦è¬v¦r¥À¡A¨Ò¦pÄ¡A¨Ï¥Î MB_PRECOMPOSED ®É¡A·|Åܦ¨¤À¶}ªº¨âÓ¸U°ê½Xªº¦r¤¸¡A¡uA ̈¡v( LATIN CAPITAL LETTER A (U+0041) + COMBINING DIAERESIS (U+0308) )¡C |
MB_USEGLYPHCHARS | 4 | ¥Î¦r§Î¥N´À±±¨î¦r¤¸¡A¨Ò¦p ¥N´À U+0008¡C |
MB_ERR_INVALID_CHARS | 8 | ¦pªG lpMultiByteStr ©Ò«ü¦r¦ê¥]§tµL®Äªº¦r¤¸¡AÂà´«µo¥Í¥¢±Ñ¡C¦pªG³]©w¦¹ºX¼Ð¡A´N·|¶Ç¦^ ERROR_NO_UNICODE_TRANSLATION¡F§_«h¥i¥H±µµÛ©I¥s GetLastErro ¶Ç¦^ ERROR_NO_UNICODE_TRANSLATION¡C¥u¯à¦b Windows 2000 SP4 ©Î XP ¥H«á¨Ï¥Î¡C |
²Ä¤TӰѼơAlpMultiByteStr¡A¬O«ü¦V¦h¦ì¤¸²Õ¦r¦êªº¦ì§}¡A·N§Y¨Ó·½¦r¦ê¦ì§}¡F¦Ó¦b¦¹¦ì§}ªº¦r¦ê¦û¦³¦h¤Ö¦ì¤¸²Õ¡A«h¬O¥Ñ²Ä¥|ӰѼơAcbMultiByte¡A«ü©w¡CcbMultiByte ¦³´XºØ±¡§Î¡G
²Ä¤Ó°Ñ¼Æ¡AlpWideCharStr¡A¬O«ü¦VÂà´««á¦s©ñ¼e¦ì¤¸²Õ¦r¦êªº¦ì§}¡A¤]´N¬O¦s©ñ¸U°ê½X¦r¦êªº½w½Ä°Ï¦ì§}¡A¤£¥i©M lpMultiByteStr «ü¦V¬Û¦P¦ì§}©Î«Å|¡A³o¼Ë·|²£¥Í ERROR_INVALID_PARAMETER ¿ù»~½X¡C³Ì«á¤@ӰѼơAcchWideChar «h¬O lpWideCharStr ©Ò¯à®e¯Ç¦r¦êªº³Ì¤j¦r¤¸Ó¼Æ¡C¦pªG cchWideChar ³]¬°¹s¡A¨º»ò MultiByteToWideChar ·|¶Ç¦^Âà´««á©Ò»Ý¦r¤¸¦h¹è¡A¤~¯à®e¯Ç¼e¦ì¤¸²Õ¦r¦ê¡A³o®É¤£»Ýn lpWideCharStr¡A©Ò¥H lpWideCharStr ¤]À³³]¬° 0¡C
lpMultiByteStr ©Ò«üªº¨Ó·½¦r¦ê¥i¥H¤£¬O¥H NULL µ²§À¡A¦pªG¬O³o¼Ëªº¸Ü¡A´N¥²¶·¦b cbMultiByte «ü©wnÂà´«ªº¦ì¤¸²ÕӼơA¦ÓÂà´««áªº¼e¦ì¤¸²Õ¦r¦ê¤]¤£¬O¥H NULL µ²§À¡C·íµM¡A¦pªG¨Ó·½¦r¦ê¬O¥H NULL µ²§À¡A³o®ÉÔ´N¥i¥H§â cbMultiByte ³]¬° -1¡A¦ÓÂà´««áªº¼e¦ì¤¸²Õ¦r¦ê´N¬O¥H NULL µ²§À¡C
ªð¦^®É¡A¦pªG©I¥s¦¨¥\¡A¨Ã¥B cchWideChar ¤£¬°¹s¡Aªð¦^È¡AEAX¡A¬O¼g¤Jªº¼e¦r¤¸Ó¼Æ¡A¼g¤Jªº¼e¦r²Õ¦r¦ê¦ì©ó lpWideCharStr «ü¦Vªº½w½Ä°Ï¡F¦pªG©I¥s¦¨¥\¡A¨Ã¥B cchWideChar ¬°¹s¡Aªð¦^ȬO±µ¦¬¨ì«ÝÂà´«¦r¦êªº½w½Ä°Ï©Ò»Ýªº¼e¦r¤¸Ó¼Æ¤j¤p¡A¦ý¤£§â¼e¦r²Õ¦r¦ê¼g¤J lpWideCharStr ©Ò«ü¦ì§}¡C¦pªG©I¥s¥¢±Ñ¡Aªð¦^Ȭ°¹s¡A¥i¥H©I¥s GetLastError ¨ú±o¿ù»~½X¡A¿ù»~½X¥i¯à¬O¤U±¤§¤@¡GERROR_INSUFFICIENT_BUFFER¡BERROR_INVALID_FLAGS¡BERROR_INVALID_PARAMETER ©Î ERROR_NO_UNICODE_TRANSLATION¡C
¨Ó·½¦r¦ê¥i¯à¤£¦Xªkªºì¦]¦³¤U±¨âºØ¡C¤@¬OÂù¦ì¤¸²Õ¦r¤¸ ( DBCS ) ¥H¥¿±`¦ì¤¸²Õ¶}©l¡A¦ýµ²§À¦ì¤¸²Õ«o¬O¿ùªº¡C¥t¤@ºØ¥i¯à¬O¨S¦³³]©w MB_ERR_INVALID_CHARS ºX¼Ð¡A¦Ó¥B¨Ó·½¦r¦ê¨S¦³¨Ï¥Î¤º©w¦r¤¸«o½Ķ¦¨¤º©w¦r¤¸¡C
»¡©ú§¹ MultiByteToWideChar «á¡AÀ³¥i¤F¸Ñ¡An§â¦h¦ì¤¸²Õ¦êÂà´«¦¨¸U°ê½X¦r¦ê¡A¨BÆJ¦p¤U¡G
©³¤U¬O¹ê²{ªº¨BÆJ¡G
1 2 3
4 5 6 7 |
INVOKE MultiByteToWideChar,CP_ACP,0,nÂà´«ªº¦r¦ê¦ì§},-1,0,0 ;¨ú±oÂà´««áªº¦r¦êªø«×
mov dwLen,eax
shl eax,1 ;§â¦r¦êªø«×¼ 2¡AÅܦ¨¦ì¤¸²Õ
INVOKE GlobalAlloc,GPTR,eax ;°t¸m°O¾ÐÅé
mov hMem,eax ;Âà´««áªº¦r¦ê±N¦s©óhMem©Ò«ü¦ì§}
INVOKE MultiByteToWideChar,CP_ACP,0,nÂà´«ªº¦r¦ê¦ì§},-1,hMem,dwLen
INVOKE GlobalFree,hMem |