'Function with a latency of N milliseconds
Private declare sub msecsleep lib "Kernel32" alias "Sleep" (byval lngmsec as long)
Dim virstr as string
Dim virsample as string
Required virustest. Enabled = false
'Use two strings to ensure that the virus sample will not be scanned and killed before being generated!
Virstr = "x5o! P % @ AP [4/pzx54 (P ^) 7cc) 7 }"
Virstr = virstr + "$ EICAR-STANDARD-ANTIVIRUS-TEST-FILE! $ H + H *"
'Use Date & timer as the name of the virus sample to ensure that the file names are different each time and the anti-virus software cannot be used for blocking.
Virsample = "C:/testvir" & right $ (Year (now), 2) & month (now) & Day (now) & int (timer) & ". EXE"
On Error goto kill
'Generate a virus sample
Open virsample for output as #1
Print #1, virstr
Close #1
Doevents
'File writing is completed with a latency of 2.5 s
Msecsleep 2500
Doevents
'Access the file for anti-virus software Detection
On Error goto kill
open virsample for input as #1
input #1, virstr
close #1
'latency of 5.0 s ensures that the antivirus software completes virus database query
msecsleep 5000
doevents
'whether the sample has been killed
If dir $ (virsample) = "" Then
kill:
msgbox "Your antivirus software has successfully cleared virus samples! ", Vbokonly
else
kill virsample
msgbox" Warning: your anti-virus software fails to detect and kill virus samples correctly. We recommend that you change or upgrade your anti-virus software immediately! ", Vbokonly
end if