[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Mike Williams

7/21/2012 7:42:00 AM

Does anybody know how to use FindFirstFile / FindNextFile (or any other
suitable function) so that it finds Junctions as well as standard files and
folders?

Mike


10 Answers

BeeJ

7/21/2012 10:32:00 PM

0

Mike Williams explained :
> Does anybody know how to use FindFirstFile / FindNextFile (or any other
> suitable function) so that it finds Junctions as well as standard files and
> folders?
>
> Mike

Maybe you already know about this.

http://www.visualbasicscript.com/vbscript-and-junctions-m...

--
Noah's Ark was built by amateurs,
The Titanic was built by professionals.
Row, row, row your boat gently down the stream ...
Life is but a dream!


unknown

7/22/2012 3:20:00 AM

0

"Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message
news:judmfq$jch$1@dont-email.me...
> Does anybody know how to use FindFirstFile / FindNextFile (or any other
> suitable function) so that it finds Junctions as well as standard files
> and folders?

See this page:

http://blogs.msdn.com/b/oldnewthing/archive/2010/02/12/99...

Constants:

Const FILE_ATTRIBUTE_REPARSE_POINT As Long = &H400
Const IO_REPARSE_TAG_SYMLINK As Long = &HA000000C
Const IO_REPARSE_TAG_MOUNT_POINT As Long = &HA0000003

The last constant is perhaps returned, I am not sure. See this link for more
details:

http://www.codeproject.com/Articles/21202/Reparse-Point...

Also see:

Reparse Point Tags:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365511%28v=vs....


Mike Williams

7/22/2012 9:01:00 AM

0

"BeeJ" <nospam@spamnot.com> wrote in message
news:jufalm$ih2$1@dont-email.me...
> Mike Williams explained :
>> Does anybody know how to use FindFirstFile / FindNextFile
>> (or any other suitable function) so that it finds Junctions as well
>> as standard files and folders?
>
> Maybe you already know about this.
>
> http://www.visualbasicscript.com/vbscript-and-junctions-m...

Thanks, BeeJ. I'd prefer to do it without using an external exe though so
I'll follow Farnsworth's suggestion. But thank anyway.

Mike




Mike Williams

7/22/2012 9:02:00 AM

0

"Farnsworth" <nospam@nospam.com> wrote in message
news:jufri5$8tt$1@speranza.aioe.org...
> "Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message
> news:judmfq$jch$1@dont-email.me...
>> Does anybody know how to use FindFirstFile / FindNextFile
>> (or any other suitable function) so that it finds Junctions as well
>> as standard files and folders?
>
> See this page:
>
> http://blogs.msdn.com/b/oldnewthing/archive/2010/02/12/99...
>
> Constants: Const FILE_ATTRIBUTE_REPARSE_POINT As Long = &H400
> Const IO_REPARSE_TAG_SYMLINK As Long = &HA000000C
> Const IO_REPARSE_TAG_MOUNT_POINT As Long = &HA0000003
> [other stuff snipped for brevity]

Thank you. Much appreciated.

Mike



Tony Toews

7/22/2012 8:04:00 PM

0

On Sat, 21 Jul 2012 08:41:47 +0100, "Mike Williams"
<Mike@WhiskyAndCoke.com> wrote:

>Does anybody know how to use FindFirstFile / FindNextFile (or any other
>suitable function) so that it finds Junctions as well as standard files and
>folders?

Thanks for asking. I am having a junction related problem when
creating subfolders of the My Documents folder in 64 bit Windows 7. I
was going to ask here but you beat me to it.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/ac...
Tony's Microsoft Access Blog - http://msmvps.com/blo...
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeup...

Tony Toews

7/23/2012 4:30:00 AM

0

On Sat, 21 Jul 2012 23:20:07 -0400, "Farnsworth" <nospam@nospam.com>
wrote:

>The last constant is perhaps returned, I am not sure. See this link for more
>details:
>
>http://www.codeproject.com/Articles/21202/Reparse-Point...

I see the following note: "FILE_FLAG_BACKUP_SEMANTICS is required in
order to get a directory handle; this means that before opening the
file, we have to adjust the privileges, thus: ..."

Does this mean the user has to have backup privileges? I'm soooo
confused here.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/ac...
Tony's Microsoft Access Blog - http://msmvps.com/blo...
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeup...

unknown

7/23/2012 4:46:00 AM

0

"Tony Toews" <ttoews@telusplanet.net> wrote in message
news:uikp08dedqujif1fkqa0phti3fe0ahml43@4ax.com...
> On Sat, 21 Jul 2012 23:20:07 -0400, "Farnsworth" <nospam@nospam.com>
> wrote:
>
>>The last constant is perhaps returned, I am not sure. See this link for
>>more
>>details:
>>
>>http://www.codeproject.com/Articles/21202/Reparse-Point...
>
> I see the following note: "FILE_FLAG_BACKUP_SEMANTICS is required in
> order to get a directory handle; this means that before opening the
> file, we have to adjust the privileges, thus: ..."
>
> Does this mean the user has to have backup privileges? I'm soooo
> confused here.
>
> Tony

No. There are two ways it seems to test for junctions. One by using
FindFirstFile, and this doesn't require opening a handle to the junction,
and the second by opening a handle(by using CreateFile with flags
FILE_FLAG_OPEN_REPARSE_POINT and FILE_FLAG_BACKUP_SEMANTICS), and then call
DeviceIoControl() on the returned handle. The comments that he was referring
to is about the second case.


Tony Toews

7/30/2012 6:32:00 AM

0

On Sun, 22 Jul 2012 10:01:59 +0100, "Mike Williams"
<Mike@WhiskyAndCoke.com> wrote:

>Thank you. Much appreciated.

I haven't got that far with this and would appreciate some help.
I've got the following.

Private Const FILE_SHARE_NONE As Long = &H0
Private Const FILE_SHARE_READ As Long = &H1
Private Const FILE_SHARE_WRITE As Long = &H2

Private Const FILE_FLAG_OPEN_REPARSE_POINT = &H200000
Private Const FILE_FLAG_BACKUP_SEMANTICS = &H2000000

hFile = CreateFile(IncomingJunctionPointFolder & vbNullChar,
GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_NONE, 0&, _
OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT Or
FILE_FLAG_BACKUP_SEMANTICS, 0&)

But it's not opening the folder. I'm just getting -1 as the return
code and I'm not sure where my error is.

I've removed the trailing backslash from the incoming folder name.
I'm darned sure that the folder is indeed such a symbolic link as I
tested for that earlier. Beside it's 'C:\Users\ttoews\My Documents'
which is a junction point.

Tony

Tony Toews

7/30/2012 6:42:00 AM

0

On Mon, 30 Jul 2012 00:32:05 -0600, Tony Toews
<ttoews@telusplanet.net> wrote:

>Private Const FILE_SHARE_WRITE As Long = &H2
>
>Private Const FILE_FLAG_OPEN_REPARSE_POINT = &H200000
>Private Const FILE_FLAG_BACKUP_SEMANTICS = &H2000000
>
> hFile = CreateFile(IncomingJunctionPointFolder & vbNullChar,
>GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_NONE, 0&, _
> OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT Or
>FILE_FLAG_BACKUP_SEMANTICS, 0&)

Never mind. Saw a link somewhere else. I needed to use
FILE_READ_EA &H8 instead of GENERIC_READ Or GENERIC_WRITE

<sigh>

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/ac...
Tony's Microsoft Access Blog - http://msmvps.com/blo...
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeup...

Tony Toews

8/1/2012 5:46:00 AM

0

On Sun, 22 Jul 2012 10:01:59 +0100, "Mike Williams"
<Mike@WhiskyAndCoke.com> wrote:

I got back to this and am struggling with the DeviceIoControl stuff.
I'm currently getting error code 6 which is invalid handle.

hFile = CreateFile(Temp & vbNullChar, FILE_READ_EA, FILE_SHARE_NONE,
0&, _
OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT Or
FILE_FLAG_BACKUP_SEMANTICS, 0&)

ReturnCode = DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, 0&, 0, _
ReparseDataBuffer, ReparseDataBufferLength, BytesReturned, 0&)

Also I'm not sure how to setup the two sub structures as found in the
following page
.....
union {
struct {
USHORT SubstituteNameOffset;
.....
http://msdn.microsoft.com/en-us/library/ff5...

Tony