Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Locate a file in user's windows drive
Message
 
 
To
02/05/2006 12:14:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01118452
Message ID:
01118454
Views:
26
This message has been marked as the solution to the initial question of the thread.
>Hi all,
>How to make my exe find that there is a file named x in windows drive?
>It is easy when it happens in inno setup. All I have to do is to write (win)and it will automatically refer to user's windows drive which can be in C:\ or D:\ because I believe that windows is not always installed in C:. just like mine, it is installed in D:\. So to repeat again how to make my exe locate that there is a file named x (surely it has been there before my exe is installed) in user's windows drive? Please help.Thank you.
>
>
>Regards
>
>
>Dudin

Old program of mine:
********************************************************************
*  Description.......: FindFileInNetwork - searches for a file in a Network
*  Calling Samples...: FindFileInNetwork("pdfmon.dll","c:\")
*  Parameter List....: tcFileToSearch, tcSearchPath, tlEntireNetwork
*  Created by........: Houston Brennan 06/13/2000
*  Modified by.......: Nadya Nosonovsky 06/16/2000 11:30:52 AM (with assistance of BP and JH)
********************************************************************
lparameters tcFileToSearch, tcSearchPath, tlEntireNetwork
** Check passed parameters
if vartype(m.tcFileToSearch)<>'C' or empty(m.tcFileToSearch)
	return .f. && First parameter is required
endif
#define NoAttributesSet       0
#define readonly              1
#define hidden                2
#define system                4
#define Archived              32
#define DoNotSearchSubFolder  0
#define SearchSubFolder       1

local lcRetPath, lcDrive, lcSearchPath, lnStartTime,;
	lcPrevOnEsc, lcPrevEscape, MsgTail, halt, loFiler

lcRetPath=''
* note clock reading for generating final timing statistics
lnStartTime = seconds()					&& # seconds since midnight

* support user Escapes for interrupting the loop
lcPrevOnEsc = on('escape')				&& save previous Escape handler
lcPrevEscape = set('escape')			&& previous Escape enablement state
set escape on							&& enable escape handling
halt = .f.								&& allow loop to run until this flag is toggled
on escape halt = .t.					&& force immediate termination if user escapes

* assemble fixed portion of status bar message outside of loop, for speed
MsgTail = "...         Wait or press Esc to cancel ..."

wait window nowait 'Searching file '+m.tcFileToSearch+iif(m.tlEntireNetwork,' in the whole network...',' ...')
loFiler = createobject( "Filer.FileUtil" )
loFiler.FileExpression = m.tcFileToSearch
loFiler.SubFolder = SearchSubFolder && Search all tree

if vartype(m.tcSearchPath)<>'C' or (empty(m.tcSearchPath) and !m.tlEntireNetwork)
	lcSearchPath='c:\' && Local drive
else
	lcSearchPath=m.tcSearchPath
endif
if !tlEntireNetwork && Only specified path to search
	loFiler.SearchPath = m.lcSearchPath
	set message to 'Searching in '+m.lcSearchPath + m.MsgTail
	loFiler.find(0) && Perform search
	if m.halt or lastkey()=27 && Escape was pressed
		exit
	endif
	if loFiler.files.count>0 && At least one file was found, pick up the first
		lcRetPath=loFiler.files.item[1].path
	endif
else
	local lni, lcDrive
** Want to search in the whole network
	for lni = 67 to 90
		lcDrive = chr(m.lni)
		if inlist(drivetype(m.lcDrive),3,4)
* Make sure the drive is ready (type 4 is either removeable or a network drive)
			set message to 'Searching drive '+m.lcDrive+m.MsgTail
			loFiler.SearchPath = m.lcDrive+':\'
			loFiler.find(0) && Perform search
			if m.halt or lastkey()=27 && Escape was pressed
				exit
			endif
			if loFiler.files.count>0 && At least one file was found, pick up the first
				lcRetPath=loFiler.files.item[1].path
				exit
			endif
		endif
	endfor
endif
* Restore settings
if m.lcPrevEscape='OFF'
	set escape off
endif
on escape &lcPrevOnEsc
set message to ' '
wait clear
=messagebox("File "+iif(!empty(m.lcRetPath),m.lcRetPath+m.tcFileToSearch,"not")+" found in "+ ;
           alltrim(str(seconds()-m.lnStartTime,10,3))+" sec.")
return m.lcRetPath && Path to the first found file
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform