Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DECLARE API FindFirstFile FindNextFile FindClose ??

Status
Not open for further replies.

DJVisuaL

Programmer
May 31, 2000
52
US
what am I doing wrong?
I've been on UT looking and the DECLARE statements is all
I can find (only for FindFirstFile and FindNextFile)
here is my code... I did have a FindNextFile call in there but I can't get FindFirstFile to work so I took it out...
the output after running this is an empty string

Code:
*-------------
* APITest.prg
*-------------

* declare API functions
DECLARE INTEGER FindFirstFile IN Win32API STRING @lpFileName, STRING @lpFindData
DECLARE SHORT FindNextFile IN Win32API INTEGER hFindFile,  STRING @lpFindData
DECLARE INTEGER FindClose IN Win32API INTEGER hFindFile

* find first file
PUBLIC sFileName, sFindData
sFileName = "d:\poems\*.txt"
sFindData = ""
hSearch = FindFirstFile(@sFileName,@sFindData)
IF hSearch = -1
	=MessageBox("NO files found!",16,"ERROR")
	RETURN
ENDIF

* print out the info
? sFindData
    
* close the handle
=FindClose(hSearch)
 
HI

When there is a FoxPro function, I prefer to use that.

YOu can read on...
GETFILE()
ADIR
FILE() && gotIt = IIF(FILE("poem.txt",.t.,.f.))

and such related functions are available. If only, they dont serve the purpose, you should go to API functions.

Hope this helps you. ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Actually in this case look at SYS(2000) - it's FoxPro's implementation of the API's FindFirstFile and FindNextFile.

Rick
 
ramani
I need the filenames the way they are on disk
ADIR returns the names in ALL CAPS
 
rick
same thing with SYS(2000)
it returns ALL CAPS filenames
is there any other way to do it so the names are right?
as they are on disk i mean...
 
My files are in the form
FirstnameLastname TheNameOfTheWorkHere.txt
so it would be nice if I could get the capitolization
as it is on disk...
any ideas let me know!
-DJ
 
DJ,
Since all MS OS's don't differentiate using the case (i.e. abc.txt and ABC.TXT can't both be in the same directory), why does it matter? Are you accessing data on non-MS file servers?

Rick
 
it is a cataloging program to keep track of a persons files from cdr's they have written.. so they can just goto this program and look up a file instead of having to search through cd's manually. It would be nice if the filenames were in the original form as they are on win9x.
example. it is alot harder to read EDGARALLENPOE THERAVEN.TXT
than EdgarAllenPoe TheRaven.txt
 
DJ,
If you still haven't got this working, and you haven't been to the UT, go to then after you login (basic membership is free you just need to register), go to and click on the "List only functions containing an example in Visual FoxPro" link. Then do a seach on Find.

Rick
 
OOps, the example code isn't there! Rather go to and enter 'File Name' (no quotes) for the Search item, and download "Windows File Names" - George has created a class that uses these API calls and it offers even more information than you need.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top