Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use the QM code to achieve the following CMD code effect
#2
Try this

Function SearchDrivesForFile
Code:
Copy      Help
str FilenameFull file drives driveletter ffn
file="1.txt"
sub.GetLogicalDrives(drives)
if(!empty(file))
,OnScreenDisplay("Searching drives for file. Please wait!" -1)
,foreach driveletter drives
,,sub.SearchForFileName(F"{driveletter}{file}" FilenameFull)
,,if FilenameFull.len
,,,foreach ffn FilenameFull
,,,,out F"{ffn} Found."
,,,,cop+ ffn "$Desktop$" FOF_ALLOWUNDO|FOF_NOCONFIRMMKDIR|FOF_NOERRORUI|FOF_FILESONLY
,,else
,,,out F"The file {file} was not Found on drive {driveletter}"
,,OsdHide
,,OnScreenDisplay("Search Complete")
#sub GetLogicalDrives
function ~&result
;dll kernel32 #GetLogicalDrives;; you may or may not need this declaration uncomment if needed

ARRAY(str) a
int i ds dm
str s(" :\") s2
dm=GetLogicalDrives ;;32-bit mask of available drives
for i 0 32
,if(dm>>i&1)
,,s[0]='A'+i
,,ds=sub.GetDriveStatus(s)
,,if ds=1
,,,a[]=s
result=a
ret 
#sub SearchForFileName
function# ~file [~&result]
ARRAY(str) fl
Dir d; str s
foreach(d file FE_Dir 0|4|32)
,s = d.FileName
,if s.len
,,fl[]= d.FileName(1)
result=fl
ret
#sub GetDriveStatus
function# $drivename ;;returns: 0 does not exist, 1 ready, 2 not ready

int i=GetDriveType(drivename)
if(i=DRIVE_NO_ROOT_DIR) ret 0

int pem=SetErrorMode(SEM_FAILCRITICALERRORS)
i=GetDiskFreeSpaceEx(drivename 0 0 0)
SetErrorMode(pem)
if(i) ret 1


Messages In This Thread
RE: How to use the QM code to achieve the following CMD code effect - by Kevin - 01-19-2019, 02:00 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)