Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: odd results using Borland's FindFirst function

25 May 2011   #1

Win 7 Home Premium 64bit
odd results using Borland's FindFirst function

After using Win7 for several months, suddenly getting odd file attribute values using FindFirst|FindNext VCL functions using Borland C++ Builder6 Enterprise.
The following code worked fine (for years in several versions of Windows)

TSearchRec sr;
int iAttributes = faDirectory;
if (FindFirst("*.*", iAttributes, sr) == 0)
if((sr.Name!=".") && (sr.Name!= ".."))
while (FindNext(sr) == 0)
if((sr.Name!=".") && (sr.Name!= ".."))

This writes all directories within a selected directory to a listbox.
Only it doesnt do this all of a sudden.
TSearchRec.Attr has begun to return a value of 0x2010 regardless of whether the file pointed to is a directory or a hidden|system|Any file!

Which means my listbox is filled with every file|directory in the specified dir, and not just the intended directories.
Can anybody make sense out of this? Is this a virus? Or is it a Win7 "feature" that packs more values into a file attribute?

My System SpecsSystem Spec
27 May 2011   #2

Win 7 Home Premium 64bit

since my post found a solution:
test TSearchRec.Attr with wanted attribute by and-ing them

if((sr.Attr & faDirectory) != 0)

Like the Borland Help documentation says ...

"To test for an attribute, combine the value of the Attr field with the attribute constant with the and operator. If the file has that attribute, the result will be greater than 0. For example, if the found file is a hidden file, the following expression will evaluate to true: (SearchRec.Attr & faHidden) != 0."

It helps to read the manual sometimes! (But still cant figure why my abbreviated version worked for so many years - until it ran into Win7 - maybe to do with 64bit integers?)

You can all sleep peacefully now...
My System SpecsSystem Spec

 odd results using Borland's FindFirst function

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar help and support threads
Thread Forum
Search function displays no results, harddrive error?
Hi. This laptop is only about 6 months old so I'm surprised to see this issue. I've found that if I go to search anything, it won't load. Icons also have an issue loading. I think this is best to describe in some images: Whatever I search, it won't load. I'll be sat here for literally 10...
Performance & Maintenance
My windows search function brings 0 results
Hey there seven forums, when i try to search something in the windows menu (I hit the windows button and type something) the only results it brings up is Control Panel. Nothing else. I did some messing around in the indexing options to try and fix it, and i might of messed it up even more, here...
General Discussion
Help with Borland x64
First thing is where can i find it, and next thing, can anyone give me tips on how to use it, i want to be ahead of the game when i go to do my A-levels
borland 5.02 help
i am trying to instal borland 5.02 but keep getting abnormal process terminated so it will not install how can i fiz this
search function in explorer yields no results?!
the start menu program search still works, but when I search in explorer for files I know exist, I get 'no result' ...usually. I mean, it's weirdly inconsistent. I can get results if I type in one or two letters, and I get incomplete results on other things (after finding a file myself, it showed...
Function keys produce unexpected results--how to reset?
Suddenly, my function keys (i.e., F1, F2, F3, etc.) produces results different from expected. I.e., in Excel, F2 used to allow me to edit the cell. Now it undoes last paste. I had set F4 in Firefox to open / close addons. Now it opens a new tab. There are many other changes to the function...
Performance & Maintenance

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 10:04.

Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App