能力值:
(RANK: )
|
-
-
2 楼
请看richedit.asm中第132行开始的代码:
; ------------------------------
; get any command line filename
; ------------------------------
invoke PathGetArgs,CommandLine
mov lpArg, eax
mov esi, eax
lodsb
cmp al, 0
je noArgs ; jump if no arg
cmp al, 34
jne @F ; jump if no quote
invoke PathUnquoteSpaces,lpArg
mov lpArg, eax
@@:
invoke exist,lpArg
.if eax == 1
invoke StreamFileIn,hRichEd,lpArg
invoke SetWindowText,hWnd,lpArg
invoke SendMessage,hRichEd,EM_SETMODIFY,0,0
.else
szText cantfind,"Sorry, cannot find that file."
invoke MessageBox,hWnd,lpArg,ADDR cantfind,MB_OK
.endif
|
能力值:
( LV2,RANK:10 )
|
-
-
7 楼
权限不够.不能上传文件.我以前的一个小例子
.386
.model flat, stdcall ;32 bit memory model
option casemap :none ;case sensitive
include open.inc
.const
MAXSIZE EQU 256
.data
szBuffer db MAXSIZE DUP (0)
FilterStringCut db "全部文件(*.*)",0,"*.*",0,0
FilterStringCombine db "所有的可执行文件(*.exe)",0,"*.exe",0,"全部文件(*.*)",0,"*.*",0,0
ofn OPENFILENAME {0} ;打开文件所需结构
inBuffer db 200 dup(0) ;字符串输入缓冲区
outBuffer db 200 dup(0) ;字符串输出缓冲区
hEdit1 dd 0 ;编辑框1句柄
hEdit2 dd 0 ;编辑框2句柄
hIcon dd 0 ;图标句柄
fMtStrinG db "%lu",0 ;字符串格式
Buffer db 128 dup(0) ;临时缓冲区
SetWindowF dd 0 ;窗口风格设置标志
.code
_GetFileName proc hWnd:dword,lpFilterString:dword
;文件打开对话框
mov ofn.lStructSize,sizeof ofn
push hWnd
pop ofn.hWndOwner
push hInstance
pop ofn.hInstance
mov eax,lpFilterString
mov ofn.lpstrFilter,eax
mov ofn.lpstrFile,offset szBuffer
mov ofn.nMaxFile,MAXSIZE
MOV ofn.Flags,OFN_FILEMUSTEXIST OR OFN_PATHMUSTEXIST\
OR OFN_LONGNAMES OR OFN_EXPLORER OR OFN_HIDEREADONLY
invoke GetOpenFileName,addr ofn
ret
_GetFileName endp
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
invoke ExitProcess,0
;########################################################################
DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL TheValue :DWORD
invoke GetDlgItem,hWin,1001
;获取编辑框1控件的句柄
mov hEdit1, eax
mov eax,uMsg
.if eax==WM_INITDIALOG
szText dlgTitle,"文件打开对话框演示"
invoke SendMessage,hWin,WM_SETTEXT,0,ADDR dlgTitle
invoke LoadIcon,hInstance,500
;载入图标
mov hIcon, eax
invoke SendMessage,hWin,WM_SETICON,1,hIcon
;设置程序图标
.elseif uMsg == WM_DROPFILES
;如果有文件拖放,设编辑框1的内容为文件路径
invoke DragQueryFile,wParam,0,ADDR Buffer,128
invoke SetWindowText,hEdit1,ADDR Buffer
.elseif eax==WM_COMMAND
.if wParam==1002 ;计算按钮
invoke _GetFileName,hWin,addr FilterStringCombine
cmp szBuffer[0],0 ; 对话框放弃返回时为零
je @F
invoke SetDlgItemText,hWin,1001,addr szBuffer
;设置编辑框1的内容为打开文件的路径
@@:
.endif
.elseif eax==WM_ACTIVATEAPP
;当前进程被激活
mov eax,SetWindowF
or eax,eax
jnz @F
invoke SetWindowLong,hWin,GWL_EXSTYLE,WS_EX_LEFT or WS_EX_ACCEPTFILES
;设置风格,可以接受文件拖放
mov eax,1
mov SetWindowF,eax
;设置标志位
@@:
.elseif eax==WM_DESTROY
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
end start
|