Private Sub Command1_Click() Open "C:\My Documents\zjm.txt" For Binary Access Write As #1 Put #1, LOF(1) + 1, "rrrrr" Close #1 End Sub
是要增加txt文件的大小而不容易被发觉。 哈。。
//是要增加txt文件的大小而不容易被发觉增加文件大小可以这样: Option Explicit Const OFS_MAXPATHNAME = 128 Const OF_CREATE = &H1000 Const OF_READ = &H0 Const OF_WRITE = &H1 Private Const FILE_END = 2 Private Type OFSTRUCT cBytes As Byte fFixedDisk As Byte nErrCode As Integer Reserved1 As Integer Reserved2 As Integer szPathName(OFS_MAXPATHNAME) As Byte End Type Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function GetFileSize Lib "kernel32" (ByVal hfile As Long, lpFileSizeHigh As Long) As Long Private Declare Function SetFilePointer Lib "kernel32" (ByVal hfile As Long, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long Private Declare Function SetEndOfFile Lib "kernel32" (ByVal hfile As Long) As LongPrivate Sub Command1_Click() Dim OF As OFSTRUCT Dim i As Long Dim hfile As Long hfile = OpenFile("e:\mc\1.txt", OF, OF_READ Or OF_WRITE) i = SetFilePointer(hfile, 100, ByVal 0&, FILE_END) SetEndOfFile hfile CloseHandle hfile End Sub至于不容易被发觉,恐怕很难实现,原因是txt文件并没有文件结束标志
Open "C:\My Documents\zjm.txt" For Binary Access Write As #1
Put #1, LOF(1) + 1, "rrrrr"
Close #1
End Sub
哈。。
Option Explicit
Const OFS_MAXPATHNAME = 128
Const OF_CREATE = &H1000
Const OF_READ = &H0
Const OF_WRITE = &H1
Private Const FILE_END = 2
Private Type OFSTRUCT
cBytes As Byte
fFixedDisk As Byte
nErrCode As Integer
Reserved1 As Integer
Reserved2 As Integer
szPathName(OFS_MAXPATHNAME) As Byte
End Type
Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetFileSize Lib "kernel32" (ByVal hfile As Long, lpFileSizeHigh As Long) As Long
Private Declare Function SetFilePointer Lib "kernel32" (ByVal hfile As Long, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long
Private Declare Function SetEndOfFile Lib "kernel32" (ByVal hfile As Long) As LongPrivate Sub Command1_Click()
Dim OF As OFSTRUCT
Dim i As Long
Dim hfile As Long
hfile = OpenFile("e:\mc\1.txt", OF, OF_READ Or OF_WRITE)
i = SetFilePointer(hfile, 100, ByVal 0&, FILE_END)
SetEndOfFile hfile
CloseHandle hfile
End Sub至于不容易被发觉,恐怕很难实现,原因是txt文件并没有文件结束标志