ICZelion Tut11

zhaozj2021-02-11  235

Tutorial 11: More about Dialog Box

We will learn more about dialog box in this tutorial. Specifically, we will explore the topic of how to use dialog boxs as our input-output devices. If you read the previous tutorial, this one will be a breeze since only a minor modification is All That's needed to beable to us................ ...

Download The Dialog Box Examples Here and here. Download Common Dialog Box Example Here.

Theory: Very little is to be said about how to use dialog boxes as input-output devices of our program Your program creates the main window as usual and when you want to display the dialog box, just call CreateDialogParam or DialogBoxParam With DialogBoxParam call.. , you do not have to do anything more, just process the messages in the dialog box procedure. With CreateDialogParam, you must insert IsDialogMessage call in the message loop to let dialog box manager handle the keyboard navigation in your dialog box for you. Since The Two Cases Are Trivial, I'll NOT PUT The Source Code Here. You Can Download The Examples and Examine Them Yourself,

Here and

Here.

Let's go on to the common dialog boxes. Windows has prepared predefined dialog boxes for use by your applications. These dialog boxes exist to provide standardized user interface. They consist of file, print, color, font, and search dialog boxes. You should use them as much as possible. The dialog boxes reside in comdlg32.dll. in order to use them, you have to link to comdlg32.lib. you create these dialog boxes by calling appropriate functions in the common dialog library. For open file dialog, it is GetOpenFileName, for save as dialog it is GetSaveFileName, for print dialog it is PrintDlg and so on. Each one of these functions takes a pointer to a structure as its parameter. You should look them up in Win32 API reference. in this tutorial , I'll Demonstrate How To create and use an open file dialog.blow is the function prototype of getopenfilename function:

GetopenFileName Proto LPOFN: DWORD

You can see that it receives only one parameter, a pointer to an OPENFILENAME structure. The return value TRUE means the user selected a file to open, it's FALSE otherwise. We will look at OPENFILENAME structure next.

OpenFileName Struct

LSTRUCTSIZE DWORD?

HWNDOWNER HWND?

Hinstance Hinstance?

LPSTRFILTER LPCSTR?

LPSTRCUSTOMFILTER LPSTR?

Nmaxcustfilter DWORD?

NFILTERINDEX DWORD?

LPSTRFILE LPSTR?

NMAXFILE DWORD?

LPSTRFILETIL LPSTR?

NMAXFILETITLE DWORD?

LPSTRINTIALDIR LPCSTR?

LPSTRTILE LPCSTR?

Flags DWORD?

NFILEOFFSET WORD?

NFILEEXTENSION WORD?

LPSTRDEFEXT LPCSTR?

LCUSTDATA LPARAM?

LPFNHOOK DWORD?

LPTEMPLATENAME LPCSTR?

OpenFileName Ends

Let's see the meaning of the frequently used memory.

lStructSizeThe size of the OPENFILENAME structure, in byteshwndOwnerThe window handle of the open file dialog box.hInstanceInstance handle of the application that creates the open file dialog boxlpstrFilterThe filter strings in the format of pairs of null terminated strings. The first string in each pair is the Description. The second string is the filter pattern. for example: filter filestring db "all files (*. *)", 0, "*. *", 0 dB "text files (* .txt)", 0, "*. txt ", 0,0 Note that only the pattern in the second string in each pair is actually used by Windows to filter out the files. Also noted that you have to put an extra 0 at the end of the filter strings to denote the end of it.nFilterIndexSpecify which pair of the filter strings will be initially used when the open file dialog is first displayed. The index is 1-based, that is the first pair is 1, the second pair is 2 and so on. So in the Above Example, IF WE Specify NfilterIndex As 2, The Second Pattern, "*. txt "will be used.lpstrFilePointer to the buffer that contains the filename used to initialize the filename edit control on the dialog box. The buffer should be at least 260 bytes long. After the user selects a file to open, the filename with full path is stored in this buffer. You can extract the information from it later.nMaxFileThe size of the lpstrFile buffer.lpstrTitlePointer to the title of the open file dialog boxFlagsDetermine the styles and characteristics of the dialog box.nFileOffsetAfter the user selects a file to open, THIS Member Contains The Index To The First Character of The Actual FileName. for Example, IF The Full Name with path is "c: /windows/system/lz32.dll"

, The this member will contain the value 18.nFileExtensionAfter the user selects a file to open, this member contains the index to the first character of the file extensionExample: The following program displays an open file dialog box when the user selects File-> Open From The menu. When the user selects a file in the dialog box, the program of the success name, filename, and extension of the success.

.386 .model flat, stdcall option casemap: none WinMain proto: DWORD,: DWORD,: DWORD,: DWORD include /masm32/include/windows.inc include /masm32/include/user32.inc include / masm32 / include / kernel32. Include /masm32/include/comdlg32.incinc includelib /masm32/lib/user32.lib incrudelib /masm32/lib/kernel32.lib includeliB /masm32/lib/comdlg32.lib

.const IDM_Open EQU 1 IDM_EXIT EQU 2 MaxSize EQU 260 OutputSize EQU 512

.DATA CLASSNAME DB "SimpleWinclass", 0 Appname DB "Our main window", 0 menuname DB "firstmenu", 0 OFN OpenFileName <> Filterstring DB "All Files", 0, "*. *", 0 DB "Text Files" , 0, "*. Txt", 0, 0) OURTITLE DB "- = OUR First Open file Dialog box = -: chourt the file to open", 0 fullpathname db "The Full FileName with path IS : ", 0 Fullname DB" The FileName IS: ", 0 ExtensionName DB" The Extension IS: ", 0 OutputString DB OutputSize DUP (0) CRLF DB 0DH, 0AH, 0

.DATA? Hinstance Hinstance? Commandline LPSTR?

. Code Start: Invoke GetModuleHandle, Null Mov Hinstance, Eax Invoke Getcommandline Mov Commandline, Eax Invoke Winmain, Hinstance, Null, CommandLine, SW_SHOWDEFAULT INVOKE EXITPROCESS, EAX

WinMain proc hInst: HINSTANCE, hPrevInst: HINSTANCE, CmdLine: LPSTR, CmdShow: DWORD LOCAL wc: WNDCLASSEX LOCAL msg: MSG LOCAL hwnd: HWND mov wc.cbSize, SIZEOF WNDCLASSEX mov wc.style, CS_HREDRAW or CS_VREDRAW mov wc.lpfnWndProc, OFFSET WndProc mov wc.cbClsExtra, NULL mov wc.cbWndExtra, NULL push hInst pop wc.hInstance mov wc.hbrBackground, COLOR_WINDOW 1 mov wc.lpszMenuName, OFFSET MenuName mov wc.lpszClassName, OFFSET ClassName invoke LoadIcon, NULL, IDI_APPLICATION mov wc. hIcon, eax mov wc.hIconSm, eax invoke LoadCursor, NULL, IDC_ARROW mov wc.hCursor, eax invoke RegisterClassEx, addr wc invoke CreateWindowEx, WS_EX_CLIENTEDGE, aDDR ClassName, aDDR AppName, / WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, / CW_USEDEFAULT, 300,200, NULL, NULL , / Hinst, null mov hwnd, eax invoke showwindow, hwnd, sw_shownormal invoke updateWindow, hwnd .While true invoke getMessage, Addr MSG, NULL, 0, 0.Break .if (! EAX) Invoke TranslateMessage, Addr Msg Invoke DispatchMessage, Addr Msg .Endw Mov Eax, Msg.wParam Ret Winmain Endp

WndProc proc hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM .IF uMsg == WM_DESTROY invoke PostQuitMessage, NULL .ELSEIF uMsg == WM_COMMAND mov eax, wParam .if ax == IDM_OPEN mov ofn.lStructSize, SIZEOF ofn push hWnd pop ofn.hwndOwner push hInstance pop ofn.hInstance mov ofn.lpstrFilter, OFFSET FilterString mov ofn.lpstrFile, OFFSET buffer mov ofn.nMaxFile, MAXSIZE mov ofn.Flags, OFN_FILEMUSTEXIST or / OFN_PATHMUSTEXIST or OFN_LONGNAMES or / OFN_EXPLORER or OFN_HIDEREADONLY mov ofn .lpstitle, Offset OURTITE Invoke GetopenFileName, Addr OFN .IF EAX ==

TRUE invoke lstrcat, offset OutputString, OFFSET FullPathName invoke lstrcat, offset OutputString, ofn.lpstrFile invoke lstrcat, offset OutputString, offset CrLf invoke lstrcat, offset OutputString, offset FullName mov eax, ofn.lpstrFile push ebx xor ebx, ebx mov bx, ofn .nFileOffset add eax, ebx pop ebx invoke lstrcat, offset OutputString, eax invoke lstrcat, offset OutputString, offset CrLf invoke lstrcat, offset OutputString, offset ExtensionName mov eax, ofn.lpstrFile push ebx xor ebx, ebx mov bx, ofn.nFileExtension add Eax, EBX POP EBX INVOKE LSTRCAT, OFFSET OUTPUTSTRING, EAX INVOKE Messagebox, Hwnd, Offset OutputString, Addr Appname, MB_OK Invoke RTLZEROME mory, offset OutputString, OUTPUTSIZE .endif .else invoke DestroyWindow, hWnd .endif .ELSE invoke DefWindowProc, hWnd, uMsg, wParam, lParam ret .ENDIF xor eax, eax ret WndProc endp end startAnalysis:

Mov ofn.lstructsize, Sizeof off

Push hwnd

POP OFN.HWNDOWNER

Push hinstance

POP OFN.HINSTANCE

We Fill in The Routine Members of OF OFN STRUCTURES.

Mov ofn.lpstrfilter, Offset Filterstring

This Filterstring Is The FileName Filter That We Specify As Follows:

Filterstring DB "All Files", 0, "*. *", 0

DB "Text Files", 0, "*. TXT", 0, 0

Note that All four strings are zero terminated. The first string is the description of the following string. The actual pattern is the even number string, in this case, "*. *" And "* .txt". Actually we can specify any pattern we want here. We MUST put an extra zero after the last pattern string to denote the end of the filter string. Do not forget this else your dialog box will behave strangely.mov ofn.lpstrFile, OFFSET buffer mov ofn.nMaxFile, MaxSize

..........................

Mov offsflags, OFN_FILEMUSTEXIST OR / OFN_PATHMUSTEXIST OR OFN_LONGNAMES OR / OFN_EXPLORER OR OFN_HIDEREADONLY

Flags specifies the characteristics of the dialog box. OFN_FILEMUSTEXIST and OFN_PATHMUSTEXIST flags demand that the filename and path that the user types in the filename edit control MUST exist. OFN_LONGNAMES flag tells the dialog box to show long filenames. OFN_EXPLORER flag specifies that the appearance of the Dialog Box Must Be Explorer-Like. OFN_HIDEREADONLY FLAG HIDES The Read-Only Checkbox on The Dialog Box. There Many More Flags That You Can Use. Consult Your Win32 API Reference.

Mov off.lpstitle, Offset OURTITLE

Specify The title of the dialog box.

Invoke GetopenFileName, Addr OFN

Call the GetOpenFileName function. Passing the pointer to the ofn structure as its parameter. At this time, the open file dialog box is displayed on the screen. The function will not return until the user selects a file to open or presses the cancel button or closes the dialog box. It 'll return the value TRUE in eax if the user selects a file to open. It returns FALSE otherwise..if eax == TRUE invoke lstrcat, offset OutputString, oFFSET FullPathName invoke lstrcat, offset OutputString, ofn. LPSTRFILE INVOKE LSTRCAT, OFFSET OUTPUTSTRING, OFFSET CRLF INVOKE LSTRCAT, OFFSET OUTPUTSTRING, OFFSET FULLNAME

In case the user selects a file to open, we prepare an output string to be displayed in a message box. We allocate a block of memory in OutputString variable and then we use an API function, lstrcat, to concatenate the strings together. In order To Put The Strings Into Several Lines, WE Must Separate Each Line with a carriage return-line feed pair.

MOV EAX, OFN.LPSTRFILE PUSH EBX XOR EBX, EBX MOV BX, OFN.NFILEOFFSET Add Eax, EBX POP EBX INVOKE LSTRCAT, OFFSET OUTPUTSTRING, EAX

The above lines require some explanation. NFileOffset contains the index into the ofn.lpstrFile. But you can not add them together directly since nFileOffset is a WORD-sized variable and lpstrFile is a DWORD-sized one. So I have to put the value of nFileOffset INTO The Low Word of Ebx and add it to the value of lpstrfile.

Invoke Messagebox, HWnd, Offset OutputString, Addr Appname, MB_OK

We display the string in a message box.

Invoke RTLZEROLMEMORY, OFFSet OutputString, OutputSize

WE Must * Clear * The OutputString Before We can Fill in Another String. So we use rtlzeromeMory function to do the job.tutorial 11: more about Dialog Box

We will learn more about dialog box in this tutorial. Specifically, we will explore the topic of how to use dialog boxs as our input-output devices. If you read the previous tutorial, this one will be a breeze since only a minor modification is All That's needed to beable to us................ ...

Download The Dialog Box Examples Here and here. Download Common Dialog Box Example Here.

THEORY:

Very little is to be said about how to use dialog boxes as input-output devices of our program. Your program creates the main window as usual and when you want to display the dialog box, just call CreateDialogParam or DialogBoxParam. With DialogBoxParam call, you do not have to do anything more, just process the messages in the dialog box procedure. With CreateDialogParam, you must insert IsDialogMessage call in the message loop to let dialog box manager handle the keyboard navigation in your dialog box for you. Since the two cases are trivial, I'll not put the source code here. You can download the examples and examine them yourself, here and here. Let's go on to the common dialog boxes. Windows has prepared predefined dialog boxes for use by your applications. These dialog boxes exist to provide standardized user interface. They consist of file, print, color, font, and search dialog boxes. You should use them as much as possible. The dialog boxes reside in comdlg32.dll. in order to us e them, you have to link to comdlg32.lib. You create these dialog boxes by calling appropriate functions in the common dialog library. For open file dialog, it is GetOpenFileName, for save as dialog it is GetSaveFileName, for print dialog it is PrintDlg and so on. Each one of these functions takes a pointer to a structure as its parameter. You should look them up in Win32 API reference. in this tutorial, I'll demonstrate how to create and use an open file dialog. Below is the Function Prototype of getopenFileName Function: GetopenFileName Proto LPOFN: DWORD

You can see that it receives only one parameter, a pointer to an OPENFILENAME structure. The return value TRUE means the user selected a file to open, it's FALSE otherwise. We will look at OPENFILENAME structure next.OPENFILENAME STRUCT

LSTRUCTSIZE DWORD?

HWNDOWNER HWND?

Hinstance Hinstance?

LPSTRFILTER LPCSTR?

LPSTRCUSTOMFILTER LPSTR?

Nmaxcustfilter DWORD?

NFILTERINDEX DWORD?

LPSTRFILE LPSTR?

NMAXFILE DWORD?

LPSTRFILETIL LPSTR?

NMAXFILETITLE DWORD?

LPSTRINTIALDIR LPCSTR?

LPSTRTILE LPCSTR?

Flags DWORD?

NFILEOFFSET WORD?

NFILEEXTENSION WORD?

LPSTRDEFEXT LPCSTR?

LCUSTDATA LPARAM?

LPFNHOOK DWORD?

LPTEMPLATENAME LPCSTR?

OpenFileName Ends

Let's see the meaning of the frequently used memory.

lStructSizeThe size of the OPENFILENAME structure, in byteshwndOwnerThe window handle of the open file dialog box.hInstanceInstance handle of the application that creates the open file dialog boxlpstrFilterThe filter strings in the format of pairs of null terminated strings. The first string in each pair is the Description. The second string is the filter pattern. for example: filter filestring db "all files (*. *)", 0, "*. *", 0 dB "text files (* .txt)", 0, "*. txt ", 0,0 Note that only the pattern in the second string in each pair is actually used by Windows to filter out the files. Also noted that you have to put an extra 0 at the end of the filter strings to denote the end of it.nFilterIndexSpecify which pair of the filter strings will be initially used when the open file dialog is first displayed. The index is 1-based, that is the first pair is 1, the second pair is 2 and so on. So in the Above Example, IF WE Specify NfilterIndex As 2, The Second Pattern, "*. txt "will be used.lpstrFilePointer to the buffer that contains the filename used to initialize the filename edit control on the dialog box. The buffer should be at least 260 bytes long. After the user selects a file to open, the filename with full path is stored in this buffer. You can extract the information from it later.nMaxFileThe size of the lpstrFile buffer.lpstrTitlePointer to the title of the open file dialog boxFlagsDetermine the styles and characteristics of the dialog box.nFileOffsetAfter the user selects a file to open, THIS Member Contains The Index To The First Character of The Actual FileName. for Example, IF The Full Name with path is "c: /windows/system/lz32.dll"

, The this Member Will Contain The Value 18.nfileExtensionAfter The User Selects a File To Open, this Member Contains The INDEX TO The First Character of The File ExtensionExample:

The following program displays an open file dialog box when the user selects File-> Open from the menu. When the user selects a file in the dialog box, the program displays a message box showing the full name, filename, and extension of the selected File.

.386 .model flat, stdcall option casemap: none WinMain proto: DWORD,: DWORD,: DWORD,: DWORD include /masm32/include/windows.inc include /masm32/include/user32.inc include / masm32 / include / kernel32. Include /masm32/include/comdlg32.incinc includelib /masm32/lib/user32.lib incrudelib /masm32/lib/kernel32.lib includeliB /masm32/lib/comdlg32.lib

.const IDM_Open EQU 1 IDM_EXIT EQU 2 MaxSize EQU 260 OutputSize EQU 512

.DATA CLASSNAME DB "SimpleWinclass", 0 Appname DB "Our main window", 0 menuname DB "firstmenu", 0 OFN OpenFileName <> Filterstring DB "All Files", 0, "*. *", 0 DB "Text Files" , 0, "*. Txt", 0, 0) OURTITLE DB "- = OUR First Open file Dialog box = -: chourt the file to open", 0 fullpathname db "The Full FileName with path IS : ", 0 Fullname DB" The FileName IS: ", 0 ExtensionName DB" The Extension IS: ", 0 OutputString DB OutputSize DUP (0) CRLF DB 0DH, 0AH, 0

.DATA? Hinstance Hinstance? Commandline LPSTR?

. Code Start: Invoke GetModuleHandle, Null Mov Hinstance, Eax Invoke Getcommandline Mov Commandline, Eax Invoke Winmain, Hinstance, Null, CommandLine, SW_SHOWDEFAULT INVOKE EXITPROCESS, EAX

WinMain proc hInst: HINSTANCE, hPrevInst: HINSTANCE, CmdLine: LPSTR, CmdShow: DWORD LOCAL wc: WNDCLASSEX LOCAL msg: MSG LOCAL hwnd: HWND mov wc.cbSize, SIZEOF WNDCLASSEX mov wc.style, CS_HREDRAW or CS_VREDRAW mov wc.lpfnWndProc, OFFSET WndProc mov wc.cbClsExtra, NULL mov wc.cbWndExtra, NULL push hInst pop wc.hInstance mov wc.hbrBackground, COLOR_WINDOW 1 mov wc.lpszMenuName, OFFSET MenuName mov wc.lpszClassName, OFFSET ClassName invoke LoadIcon, NULL, IDI_APPLICATION mov wc. hIcon, eax mov wc.hIconSm, eax invoke LoadCursor, NULL, IDC_ARROW mov wc.hCursor, eax invoke RegisterClassEx, addr wc invoke CreateWindowEx, WS_EX_CLIENTEDGE, aDDR ClassName, aDDR AppName, / WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, / CW_USEDEFAULT, 300,200, NULL, NULL , / Hinst, null mov hwnd, eax invoke showwindow, hwnd, sw_shownormal invoke updateWindow, hwnd .While true invoke getMessage, Addr MSG, NULL, 0, 0.Break .if (! EAX) Invoke TranslateMessage, Addr Msg Invoke DispatchMessage, Addr Msg .Endw Mov Eax, Msg.wParam Ret Winmain Endp

WndProc proc hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM .IF uMsg == WM_DESTROY invoke PostQuitMessage, NULL .ELSEIF uMsg == WM_COMMAND mov eax, wParam .if ax == IDM_OPEN mov ofn.lStructSize, SIZEOF ofn push hWnd pop ofn.hwndOwner push hInstance pop ofn.hInstance mov ofn.lpstrFilter, OFFSET FilterString mov ofn.lpstrFile, OFFSET buffer mov ofn.nMaxFile, MAXSIZE mov ofn.Flags, OFN_FILEMUSTEXIST or / OFN_PATHMUSTEXIST or OFN_LONGNAMES or / OFN_EXPLORER or OFN_HIDEREADONLY mov ofn .lpstitle, Offset OURTITE Invoke GetopenFileName, Addr OFN .IF EAX ==

TRUE invoke lstrcat, offset OutputString, OFFSET FullPathName invoke lstrcat, offset OutputString, ofn.lpstrFile invoke lstrcat, offset OutputString, offset CrLf invoke lstrcat, offset OutputString, offset FullName mov eax, ofn.lpstrFile push ebx xor ebx, ebx mov bx, ofn .nFileOffset add eax, ebx pop ebx invoke lstrcat, offset OutputString, eax invoke lstrcat, offset OutputString, offset CrLf invoke lstrcat, offset OutputString, offset ExtensionName mov eax, ofn.lpstrFile push ebx xor ebx, ebx mov bx, ofn.nFileExtension add Eax, EBX POP EBX INVOKE LSTRCAT, OFFSET OUTPUTSTRING, EAX INVOKE Messagebox, Hwnd, Offset OutputString, Addr Appname, MB_OK Invoke RTLZEROME mory, offset OutputString, OUTPUTSIZE .endif .else invoke DestroyWindow, hWnd .endif .ELSE invoke DefWindowProc, hWnd, uMsg, wParam, lParam ret .ENDIF xor eax, eax ret WndProc endp end startAnalysis:

Mov ofn.lstructsize, Sizeof offn Push HWnd pop offshwndowner push hinstance pop ofn.hinstance

We Fill in The Routine Members of OF OFN STRUCTURES.

Mov ofn.lpstrfilter, Offset Filterstring

This Filterstring Is The FileName Filter That We Specify As Follows:

Filterstring DB "All Files", 0, "*. *", 0

DB "Text Files", 0, "*. TXT", 0, 0

Note that All four strings are zero terminated. The first string is the description of the following string. The actual pattern is the even number string, in this case, "*. *" And "* .txt". Actually we can specify any pattern we want here. We MUST put an extra zero after the last pattern string to denote the end of the filter string. Do not forget this else your dialog box will behave strangely.mov ofn.lpstrFile, OFFSET buffer mov ofn.nMaxFile, MaxSize

..........................

Mov offsflags, OFN_FILEMUSTEXIST OR / OFN_PATHMUSTEXIST OR OFN_LONGNAMES OR / OFN_EXPLORER OR OFN_HIDEREADONLY

Flags specifies the characteristics of the dialog box. OFN_FILEMUSTEXIST and OFN_PATHMUSTEXIST flags demand that the filename and path that the user types in the filename edit control MUST exist. OFN_LONGNAMES flag tells the dialog box to show long filenames. OFN_EXPLORER flag specifies that the appearance of the Dialog Box Must Be Explorer-Like. OFN_HIDEREADONLY FLAG HIDES The Read-Only Checkbox on The Dialog Box. There Many More Flags That You Can Use. Consult Your Win32 API Reference.

Mov off.lpstitle, Offset OURTITLE

Specify The title of the dialog box.

Invoke GetopenFileName, Addr OFN

Call the GetOpenFileName function. Passing the pointer to the ofn structure as its parameter. At this time, the open file dialog box is displayed on the screen. The function will not return until the user selects a file to open or presses the cancel button or closes the dialog box. It 'll return the value TRUE in eax if the user selects a file to open. It returns FALSE otherwise..if eax == TRUE invoke lstrcat, offset OutputString, oFFSET FullPathName invoke lstrcat, offset OutputString, ofn. LPSTRFILE INVOKE LSTRCAT, OFFSET OUTPUTSTRING, OFFSET CRLF INVOKE LSTRCAT, OFFSET OUTPUTSTRING, OFFSET FULLNAME

In case the user selects a file to open, we prepare an output string to be displayed in a message box. We allocate a block of memory in OutputString variable and then we use an API function, lstrcat, to concatenate the strings together. In order To Put The Strings Into Several Lines, WE Must Separate Each Line with a carriage return-line feed pair.

MOV EAX, OFN.LPSTRFILE PUSH EBX XOR EBX, EBX MOV BX, OFN.NFILEOFFSET Add Eax, EBX POP EBX INVOKE LSTRCAT, OFFSET OUTPUTSTRING, EAX

The above lines require some explanation. NFileOffset contains the index into the ofn.lpstrFile. But you can not add them together directly since nFileOffset is a WORD-sized variable and lpstrFile is a DWORD-sized one. So I have to put the value of nFileOffset INTO The Low Word of Ebx and add it to the value of lpstrfile.

Invoke Messagebox, HWnd, Offset OutputString, Addr Appname, MB_OK

We display the string in a message box.

Invoke RTLZEROLMEMORY, OFFSet OutputString, OutputSize

转载请注明原文地址:https://www.9cbs.com/read-4680.html

New Post(0)