- UID
- 13801
注册时间2006-5-22
阅读权限40
最后登录1970-1-1
独步武林
该用户从未签到
|
调用WIN32 API获取了当前目录,在MASM环境下编译。。。。。。。
;----------------
;编译模式="CON"
;----------------
.386
.model flat, stdcall
option casemap :none
include windows.inc
include user32.inc
include kernel32.inc
include masm32.inc
includelib user32.lib
includelib kernel32.lib
includelib masm32.lib
;-------------------------------------------------------
.DATA
szPath db 256 dup(?)
.CODE
START:
invoke GetCurrentDirectory,256,addr szPath ;获取当前目录
invoke StrLen,addr szPath
mov ebx,eax ;得到字符串长度,用于修正缓冲区内容
mov szPath[ebx],13
inc ebx
mov szPath[ebx],10
inc ebx
mov szPath[ebx],0
push ebx
invoke StdOut,addr szPath
pop ebx
.while(ebx!=0) ;清空缓冲区,此处WHILE为MASM新增的高级特性
mov szPath[ebx],0
dec ebx
.endw
mov szPath[ebx],0
invoke StdIn,addr szPath,sizeof szPath
invoke StrLen,addr szPath
mov ebx,eax
sub ebx,2
mov szPath[ebx],0
invoke SetCurrentDirectory,addr szPath
invoke GetCurrentDirectory,256,addr szPath
invoke StrLen,addr szPath
mov ebx,eax
mov szPath[ebx],13
inc ebx
mov szPath[ebx],10
inc ebx
mov szPath[ebx],0
invoke StdOut,addr szPath
invoke ExitProcess,0
end START
[ 本帖最后由 caterpilla 于 2006-6-22 13:35 编辑 ] |
|