问题描述
问题集中在 MASM 上,并且仅使用 Irvine 32 位。除非真的需要,否则我不打算使用宏等。
.386
.model flat,stdcall
INCLUDE Irvine32.inc
.stack 4096
.Data
inputFilename byte "Enter filename : ",0
errorMssg byte "Unable to open file !",0
newAmount byte "2021",0 ;updated from dword to byte
fileHandle HANDLE ?
buffer dword 200 DUP(?)
.Code
main PROC
我想提示用户输入文件名。然后打开文件(如果存在),如果不存在则显示错误消息。让我们假设文件已创建并因此存在。文件中只包含一个数字,即 2020。
OPEN_EXISTING_FILE:
mov edx,offset inputFilename ;ask user enter the existing filename
;currently in existing file content is 2020
call WriteString
call Crlf
mov ecx,SIZEOF inputFilename
call ReadString
call OpenInputFile
mov fileHandle,eax
;file error check
cmp eax,INVALID_HANDLE_VALUE
jne OVERWRITE_FILE
mov edx,offset errorMssg
call WriteString
call Crlf
jmp OPEN_EXISTING_FILE
似乎我的写入文件不起作用。我错过了一些代码吗?谁能指导我如何将文件中的“2020”替换为“2021”。
OVERWRITE_FILE:
mov eax,fileHandle
mov edx,OFFSET newAmount ;i want to overwrite 2020 to 2021 in the existing file
mov ecx,LENGTHOF newAmount
call WritetoFile
call CloseFile
call crlf
call waitMsg
END main
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)