A Preliminary Study of Series 2 from C to Win32 Compilation

Source: Internet
Author: User

Who makes a horse rider Jinghua?
The small building listens to the spring rain overnight, and the Ming Dynasty in shenxiang sells apricot flowers.
Low paper oblique line idle for grass, clear window thin milk drama tea.
Suyi moqi from the dust sigh, still and pure brightness can be home.

It is the charm of this book because of the "Spring rain for a night in a small building" in yuyue bending knife.

Fang Cao Xi, Gu Xiu. Floral Yiyi, Colorful butterfly.
Let Xuan Qin play a wonderful song, and let the light floor listen to the rain dance and bend the knife!
Love, hate, and searching. This situation can be waited, but it has become a recollection!
The meteor is gone, and now there is only one soul and one moon.

So I was interested in this article.

In detail, the ofn_allowmultiselect bit mark of the openfilename structure in the open file dialog box (you can select multiple names in the specified file name list box ).
I believe many people are struggling with this attribute, mainly because it is different from multiple choice.
Look at the data zone and you will know:
{
Function onclick ()
{
If (this. width> = 700) window. Open ('HTTP: // www.darkcb.com/attachment/mon_1006/49_26_29230fe1de3a94b.jpg ');
}
} "Src =" http://www.darkcb.com/attachment/Mon_1006/49_26_29230fe1de3a94b.jpg "border =" 0 "alt =" ">
Figure 1 single-choice File
{
Function onclick ()
{
If (this. width> = 700) window. Open ('HTTP: // www.darkcb.com/attachment/mon_1006/49_26_0627caffdce1232.jpg ');
}
} "Src =" http://www.darkcb.com/attachment/Mon_1006/49_26_0627caffdce1232.jpg "border =" 0 "alt =" ">
Figure 2 multiple file selection
When a single-choice file is found
"C:/Documents and Settings/Administrator/desktop/myok/Xiaolou listen to the spring rain overnight, Shen Xiang Ming Dynasty sells apricot flowers .. TXT.
When multiple files are selected, the result is as follows:
"C:/Documents and Settings/Administrator/desktop/myok" "The Light building listens to spring rain overnight, and the Ming Dynasty sells apricot flowers in shenxiang .. TXT"
"Who makes a horse rider Jinghua ?. ASM"

Why do we need to analyze this? The main points are as follows:
1. provides a unified processing interface for file selection
2. Extract and recognize file extensions
3. provides some ideas for the formation of the file list (such as the playback file list.

It took me one morning to write the program. C program will not be exposed, just write a Win32 assembly, slowly look.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
; 1. provides a unified processing interface for file selection
2. Extract and recognize file extensions
3. provides some ideas for the formation of the file list (such as the playback file list.
By goldenspider QQ: 287014897
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
. 386
. Model flat, stdcall
Option Casemap: none; case sensitive
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
; Include data
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
Includelib kernel32.lib
Includelib user32.lib
Includelib gdi32.lib
Includelib comctl32.lib
Includelib comdlg32.lib

Include windows. inc
Include kernel32.inc
Include user32.inc
Include gdi32.inc
Include comctl32.inc
Include comdlg32.inc
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
; Equ data
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
Dlg_main equ 1000
Id_browse equ 1001
Id_file equ 1002
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
; Data Segment
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
. Data?
Hwinmain dd?
Hinstance dd?
Lpbuffer dd?
Szbuffer dB max_path * 40 DUP (?) ; Buffer used by multiple file names
Sztemp dB max_path DUP (?) ; Save the file name path prefix
Sztemp1 dB max_path DUP (?)
Sztemp2 dB max_path DUP (?)
Szpath dB max_path DUP (?)
; Buf dB 256 DUP (?)
Stopenfilename openfilename <?>
. Data
Inform dB 0dh, 0ah, 0
Sztitlesave DB "ye xianyu by G-spider", 0
Sztitlemesg DB "Linan Chunyu first-day Land tour", 0
Szext dB '*. txt; *. C', 0
Szfilter dB 'files (*. TXT ,*. c) ', 0 ,'*. txt ;*. c', 0, 'all files (*. *) ', 0 ,'*. * ', 0
; Buffmt DB "% d", 0; // used for numerical data testing
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
; Subroutine Declaration
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
_ Procdlgmain proto: DWORD,: DWORD
_ Getfilename proto
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
; Code segment
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>
. Code
; **************************************** ***************************
; File Processing, good job! By goldenspider
Function: the full path of the lpstrfile is obtained no matter whether multiple choices are selected.
"***""***"... "***" Where A is the full path prefix, and B is the file name (including the extension)
; Return Value: Header pointer of B (excluding full path Prefix A, Prefix A is saved to sztemp cache)
Example 1: Obtain "D:/masm32/My. ASM" by single choice and split it into: A = "D:/masm32/" B = "My. ASM"
; Example 2: Select "D:/masm32" "My. ASM "" my1.c "is processed as: a =" D:/masm32/"B =" My. ASM "" my1.c"
In the above two examples, the returned values are the header pointer of "My. ASM", and the string "D:/masm32/" is in the sztemp cache.
; **************************************** ***************************
_ Getfilename proc

MoV stopenfilename. Flags, ofn_pathmustexist or ofn_filemustexist
MoV stopenfilename. lstructsize, sizeof stopenfilename
MoV eax, hwinmain
MoV stopenfilename. hwndowner, eax
MoV stopenfilename. lpstrfilter, offset szfilter
MoV stopenfilename. lpstrfile, offset szbuffer
MoV stopenfilename. nmaxfile, max_path
MoV stopenfilename. lpstrinitialdir, 0
MoV stopenfilename. lpstrtitle, offset sztitlemesg
MoV stopenfilename. lpstrdefext, offset szext
MoV stopenfilename. Flags, ofn_hidereadonly or ofn_filemustexist/
Or ofn_pathmustexist or ofn_explorer or ofn_allowmultiselect
Invoke getopenfilename, offset stopenfilename

. If eax = false
RET
. Endif
Invoke setdlgitemtext, hwinmain, id_file, ADDR szbuffer
Xor ebx, EBX
MoV BX, stopenfilename. nfileoffset
Invoke lstrcpyn, offset sztemp, offset szbuffer, EBX; // obtain string.
; The following processing Terminator '/'
Invoke lstrlen, offset sztemp
Lea ESI, sztemp
Add ESI, eax
XOR eax, eax
MoV Al ,'/'
. If byte PTR [esi-1]! = Al
MoV word PTR [esi], ax
. Endif

Xor ebx, EBX
MoV BX, stopenfilename. nfileoffset
Lea ESI, szbuffer
Add ESI, EBX
MoV eax, ESI

RET
_ Getfilename endp
; **************************************** ****************************
; Pathfindextensiona by G-spider [Moon cave]
Pathfindextension function: return the header pointer of the path "D:/masm32/examples/LCD. ASM" string suffix string ". ASM"
Input parameter: path pointer lppathbuffer, which can be obtained by lpstrfile
; Return Value: eax
; **************************************** ****************************
Pathfindextension proc uses ESI lppathbuffer: DWORD
;----------------------------------------------------------------------
MoV eax, lppathbuffer
Xor esi, ESI
Test eax, eax
Je short l77f5f625
MoV Cl, byte ptr ds: [eax]
Test Cl, Cl
Je short l77f5f625
L77f5f603:
CMP Cl, 20 h; 20 h = 32D, which is an ascii code space, that is, check whether it is a space character
Je short l77f5f62a; jump to Space
CMP Cl, 2EH; 2EH = 46d, which is the ASCII code '.', that is, check whether the node number is
Je short l77f5f5e5; jump
CMP Cl, 5ch; 5ch = 92d, which is the ASCII code '/', that is, check whether it is a delimiter slash
Je short l77f5f62a; jump if it is a slash
L77f5f612:

Push eax
Call charnexta

MoV Cl, byte ptr ds: [eax]
Test Cl, Cl
Jnz short l77f5f603
Test ESI, ESI
Je short l77f5f625
MoV eax, ESI
L77f5f625:
RET
L77f5f62a:
Xor esi, ESI; indicates that the dot '.' is not followed by a suffix. Therefore, the pointer is cleared to 0, and the pointer value of this vertex is no longer saved.
JMP short l77f5f612

L77f5f5e5:
MoV ESI, eax; if it is a '.' dot, use ESI to save its pointer Value
JMP short l77f5f612; then judge the next character
;----------------------------------------------------------------------
Pathfindextension endp
; **************************************** ****************************
_ Procdlgmain proc uses ebx edi esi ,/
Hwnd: DWORD, wmsg: DWORD, wparam: DWORD, lparam: DWORD
Local @ strlongcount; // used to save the length of a file name string with a suffix
Local @ delextcount; // It is used to save the length of the file name string excluding the suffix.

MoV @ strlongcount, 0
MoV @ delextcount, 0

MoV eax, wmsg
. If eax = wm_close
Invoke enddialog, hwnd, null
. Elseif eax = wm_initdialog
MoV eax, hwnd
MoV hwinmain, eax
Invoke senddlgitemmessage, hwinmain, id_file, em_setreadonly, true, null
. Elseif eax = wm_command
MoV eax, wparam
. If eax = id_browse
Invoke _ getfilename
MoV lpbuffer, eax; get the file name pointer
; /// Invoke lstrcat, ADDR sztemp, lpbuffer; display full path
. Elseif eax = idok
Invoke lstrlen, lpbuffer
MoV @ strlongcount, eax
MoV @ delextcount, eax
. Repeat
Invoke pathfindextension, lpbuffer
Invoke lstrlen, eax
Dec eax
Sub @ delextcount, eax
; Invoke wsprintf, offset Buf, offset buffmt, extcount; // used for testing
; Invoke MessageBox, null, offset Buf, ADDR sztitlesave, 0

Invoke lstrcpyn, offset sztemp1, lpbuffer, @ delextcount; remove the filename suffix such as. ASM.
Invoke lstrcat, ADDR sztemp1, ADDR inform; Add the carriage return line break
Invoke lstrcat, ADDR sztemp2, ADDR sztemp1; form a continuous long string

MoV eax, @ strlongcount
INC eax
Add lpbuffer, eax; point to the header of the next substring
Invoke lstrlen, lpbuffer
MoV @ strlongcount, eax
MoV @ delextcount, eax

. Until eax = 0
Invoke MessageBox, hwinmain, ADDR sztemp2, ADDR sztitlemesg, 0; display verse
. Endif
. Else
; **************************************** ****************************
Note: After message processing in the dialog box, true is returned for messages not processed.
; To return false
; **************************************** ****************************
MoV eax, false
RET
. Endif
MoV eax, true
RET
_ Procdlgmain endp
; **************************************** ****************************
Start:
Invoke initcommoncontrols
Invoke getmodulehandle, null
MoV hinstance, eax
Invoke dialogboxparam, hinstance, dlg_main, null, offset _ procdlgmain, 0
Invoke exitprocess, null

End start
; **************************************** ****************************

{
Function onclick ()
{
If (this. Width >=700) window. Open ('HTTP: // www.darkcb.com/attachment/mon_1006/49_26_4cedda581db4599.jpg ');
}
} "Src =" http://www.darkcb.com/attachment/Mon_1006/49_26_4cedda581db4599.jpg "border =" 0 "alt =" ">

{
Function onclick ()
{
If (this. width> = 700) window. Open ('HTTP: // www.darkcb.com/attachment/mon_1006/49_26_e220a563869da82.jpg ');
}
} "Src =" http://www.darkcb.com/attachment/Mon_1006/49_26_e220a563869da82.jpg "border =" 0 "alt =" ">

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.