Solved

Searching for files in path longer than 255 characters

Posted on 2002-03-10
13
403 Views
Last Modified: 2010-05-18
Hi there,

I am looking for a FindFirst, FindNext equivalent to find files and directories even if the path is longer than 255 characters.

I was trying to use the FindFistFileW function and prefixing the path name with "\\?\", however, I always get error code 3.

I'll give 300 points for some working code, it's urgent.

In a nutshell: I need to be able to search for directories and files even if the path name is longer than 255 characters.


Thanks,
Oliver
0
Comment
Question by:novowi
13 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 6854688
It works fine for me with "\\?\C:\boot.ini" (I don't have such long pathes on my PC) - but only in NT based systems! I guess you're trying it in win9x? That is not supported there. If you need this stuff for win9x, then you will probably have to deal with IShellFolder and that stuff...   :-(

Regards, Madshi.
0
 

Author Comment

by:novowi
ID: 6854695
Thanks Madshi,

I am running it on NT4 and W2K, not W95/98.

Regards,
Oliver
0
 

Author Comment

by:novowi
ID: 6854700
Madshi,

Does your madSecurity etc. work with such long file and path names ?

Thanks,
Oliver
0
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 

Author Comment

by:novowi
ID: 6854767
Madshi,

Does your madSecurity etc. work with such long file and path names ?

Thanks,
Oliver
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6854777
I've not tested it yet. Perhaps madShell can do that, madShell encapsulates the IShellFolder stuff. See here for documentation:

http://help.madshi.net/Data/madShell.htm

However, I think it should work with that \\?\. Can you show a short piece of your code?

Regards, Madshi.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 300 total points
ID: 6854781
P.S: Does it work with your code, when you use that \\?\ on a short path, like e.g. '\\?\C:\*.*'?
0
 

Author Comment

by:novowi
ID: 6854788
Unfortunately not :(

Is there anything you can do about ?

Thanks,
Oliver
0
 

Author Comment

by:novowi
ID: 6854812
By the way, I solved the problem with the FindFirstFileW function. Used the wrong variable type.

However, two problems remain.
- Using madSecurity with such long dir/file names doesn't work.

- Using the FindFirstFileW function uses the wrong character set. I need to get the file names returned in OEM
and the SetFileAPIsToOEM function does not help. It works only if I use the normal FindFirst and Findnext functions.

Regards,
Oliver
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6854827
>> Using the FindFirstFileW function uses the wrong character set.

?  Converting from wide character to ansi is very easy. Something like this:

var w32fd : TWin32FindDataW;
    str   : string;
begin
  ...
  str := wideString(w32fd.cFileName);

That's it. Or do you mean something different? I'm not sure.

And where exactly is the problem with madSecurity? Which call exactly fails? Some code, please!

Regards, Madshi.
0
 

Author Comment

by:novowi
ID: 6854832
By the way, I solved the problem with the FindFirstFileW function. Used the wrong variable type.

However, two problems remain.
- Using madSecurity with such long dir/file names doesn't work.

- Using the FindFirstFileW function uses the wrong character set. I need to get the file names returned in OEM
and the SetFileAPIsToOEM function does not help. It works only if I use the normal FindFirst and Findnext functions.

Regards,
Oliver
0
 
LVL 17

Expert Comment

by:inthe
ID: 6854867
i was following q wondering why you wouldnt get it to work as
i just tried FindFirstFileW on a path of 673 length and it worked ok as it should.


>>get the file names returned in OEM
now sure what that means but it wouldnt be:

Win32FindData.cAlternateFileName

would it?
0
 
LVL 33

Expert Comment

by:Slick812
ID: 6855400
this may help, I've used it to bypass real long file paths in some API functions that only take MAX_PATH charaters, but I don't remember which OS it will work under, I think NT, Win9x


function ShortPathName(const LongName: string): string;
var
  Buffer: array[0..MAX_PATH - 1] of Char;
begin
  SetString(Result, Buffer,
    GetShortPathName(PChar(LongName), Buffer, SizeOf(Buffer)));
end;
0
 

Author Comment

by:novowi
ID: 6862836
Madshi,

I did some thourough checking and your questions and suggestions finally helped me to sort it all out. It's all working.

Thanks,
Oliver
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question