Home All Groups Group Topic Archive Search About

Are there alternatives to using WIN32_Find_Data?

Author
19 Mar 2006 5:20 PM
Howard Kaikow
The description of the Win32_Find_Data structure documents how to determine
a file's size.

Well, the described method does not work for large files, e.g., for a file
of 25406543872 bytes.

I ran into the problem in my own code, but I've seen the same problem with
other well known code posted on the web.
I've communicated this privately to an author of similar code posted at his
web site.

The following just does not get the job done, even if converted to the
Currency data type.

(nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow

Is there a more reliable way to get the file size?

I sure wish MSFT would not publish incorrect info, oh well, I can dream,
n'est-ce pas!?

Let's start a revolution and fix this problem.

Author
19 Mar 2006 5:56 PM
AGP
No revolution needed. VB6 is geared toward 32 bit operations and
as such it will fail at certain points. I overcame the problem a long
time ago with the help of this newsgroup. Look at the post several
days ago entitled "Zip API in WindowsXP" about 2/3 of the way down. And also
my
post at PSC:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=49884&lngWId=1

AGP




Show quoteHide quote
"Howard Kaikow" <kai***@standards.com> wrote in message
news:Ozbaul3SGHA.5908@TK2MSFTNGP14.phx.gbl...
> The description of the Win32_Find_Data structure documents how to
determine
> a file's size.
>
> Well, the described method does not work for large files, e.g., for a file
> of 25406543872 bytes.
>
> I ran into the problem in my own code, but I've seen the same problem with
> other well known code posted on the web.
> I've communicated this privately to an author of similar code posted at
his
> web site.
>
> The following just does not get the job done, even if converted to the
> Currency data type.
>
> (nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow
>
> Is there a more reliable way to get the file size?
>
> I sure wish MSFT would not publish incorrect info, oh well, I can dream,
> n'est-ce pas!?
>
> Let's start a revolution and fix this problem.
>
>
Author
19 Mar 2006 6:20 PM
Howard Kaikow
Thanx, I'll take a look.

"AGP" <sindizzy.***@softhome.net> wrote in message
news:uXgTf.48502$F_3.21829@newssvr29.news.prodigy.net...
> No revolution needed. VB6 is geared toward 32 bit operations and
> as such it will fail at certain points. I overcame the problem a long
> time ago with the help of this newsgroup. Look at the post several
> days ago entitled "Zip API in WindowsXP" about 2/3 of the way down. And
also
> my
> post at PSC:
>
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=49884&lngWId=1
Show quoteHide quote
>
> AGP
>
>
>
>
> "Howard Kaikow" <kai***@standards.com> wrote in message
> news:Ozbaul3SGHA.5908@TK2MSFTNGP14.phx.gbl...
> > The description of the Win32_Find_Data structure documents how to
> determine
> > a file's size.
> >
> > Well, the described method does not work for large files, e.g., for a
file
> > of 25406543872 bytes.
> >
> > I ran into the problem in my own code, but I've seen the same problem
with
> > other well known code posted on the web.
> > I've communicated this privately to an author of similar code posted at
> his
> > web site.
> >
> > The following just does not get the job done, even if converted to the
> > Currency data type.
> >
> > (nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow
> >
> > Is there a more reliable way to get the file size?
> >
> > I sure wish MSFT would not publish incorrect info, oh well, I can dream,
> > n'est-ce pas!?
> >
> > Let's start a revolution and fix this problem.
> >
> >
>
>
Author
19 Mar 2006 6:18 PM
Mike D Sutton
Show quote Hide quote
> The description of the Win32_Find_Data structure documents how to
> determine
> a file's size.
>
> Well, the described method does not work for large files, e.g., for a file
> of 25406543872 bytes.
>
> I ran into the problem in my own code, but I've seen the same problem with
> other well known code posted on the web.
> I've communicated this privately to an author of similar code posted at
> his
> web site.
>
> The following just does not get the job done, even if converted to the
> Currency data type.
>
> (nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow
>
> Is there a more reliable way to get the file size?
>
> I sure wish MSFT would not publish incorrect info, oh well, I can dream,
> n'est-ce pas!?

Have a look at this post from a few days ago on the subject:
http://groups.google.co.uk/group/microsoft.public.vb.winapi/msg/3221dfa4e713ed7e
If you need a version that also copes with Unicode file names then I can
post that one instead.
Hope this helps,

    Mike


- Microsoft Visual Basic MVP -
E-Mail: ED***@mvps.org
WWW: Http://EDais.mvps.org/
Author
19 Mar 2006 6:26 PM
Howard Kaikow
Thanx, I'll take a look.

Show quoteHide quote
"Mike D Sutton" <ED***@mvps.org> wrote in message
news:eKToTG4SGHA.1868@TK2MSFTNGP10.phx.gbl...
> > The description of the Win32_Find_Data structure documents how to
> > determine
> > a file's size.
> >
> > Well, the described method does not work for large files, e.g., for a
file
> > of 25406543872 bytes.
> >
> > I ran into the problem in my own code, but I've seen the same problem
with
> > other well known code posted on the web.
> > I've communicated this privately to an author of similar code posted at
> > his
> > web site.
> >
> > The following just does not get the job done, even if converted to the
> > Currency data type.
> >
> > (nFileSizeHigh * (MAXDWORD + !)) + nFileSizeLow
> >
> > Is there a more reliable way to get the file size?
> >
> > I sure wish MSFT would not publish incorrect info, oh well, I can dream,
> > n'est-ce pas!?
>
> Have a look at this post from a few days ago on the subject:
>
http://groups.google.co.uk/group/microsoft.public.vb.winapi/msg/3221dfa4e713ed7e
Show quoteHide quote
> If you need a version that also copes with Unicode file names then I can
> post that one instead.
> Hope this helps,
>
>     Mike
>
>
>  - Microsoft Visual Basic MVP -
> E-Mail: ED***@mvps.org
> WWW: Http://EDais.mvps.org/
>
>
Author
19 Mar 2006 8:00 PM
Howard Kaikow
The mechanism diddling with the value 2^32 seems to get around the problem.
No need to use, ugh!, Variant, works with Currency type.
Author
19 Mar 2006 8:05 PM
Howard Kaikow
Here's what I used:

                curHigh = CCur(WFD.nFileSizeHigh)
                curLow = CCur(WFD.nFileSizeLow)
                If curHigh < 0 Then
                    curHigh = curHigh + curBit32
                End If
                If curLow < 0 Then
                    curLow = curLow + curBit32
                End If
                ByteCount = (curHigh * curBit32) + curLow

Where curHigh, curLow, ByteCount, and curBit32 are type Currency.
Author
19 Mar 2006 8:45 PM
Jim Edgar
Show quote Hide quote
"Howard Kaikow" <kai***@standards.com> wrote in message
news:eMXnGC5SGHA.5108@TK2MSFTNGP09.phx.gbl...
> Here's what I used:
>
>                 curHigh = CCur(WFD.nFileSizeHigh)
>                 curLow = CCur(WFD.nFileSizeLow)
>                 If curHigh < 0 Then
>                     curHigh = curHigh + curBit32
>                 End If
>                 If curLow < 0 Then
>                     curLow = curLow + curBit32
>                 End If
>                 ByteCount = (curHigh * curBit32) + curLow
>
> Where curHigh, curLow, ByteCount, and curBit32 are type Currency.
>
>

That's pretty much the same solution as posted here:

http://www.freevbcode.com/ShowCode.asp?ID=6836

Looks like you fixed it.

Jim Edgar
Author
19 Mar 2006 9:05 PM
Howard Kaikow
--
http://www.standards.com/; See Howard Kaikow's web site.
Show quote Hide quote
"Jim Edgar" <djedgarRemoveT***@cox.net> wrote in message
news:uDN4PY5SGHA.4608@tk2msftngp13.phx.gbl...
>
> "Howard Kaikow" <kai***@standards.com> wrote in message
> news:eMXnGC5SGHA.5108@TK2MSFTNGP09.phx.gbl...
> > Here's what I used:
> >
> >                 curHigh = CCur(WFD.nFileSizeHigh)
> >                 curLow = CCur(WFD.nFileSizeLow)
> >                 If curHigh < 0 Then
> >                     curHigh = curHigh + curBit32
> >                 End If
> >                 If curLow < 0 Then
> >                     curLow = curLow + curBit32
> >                 End If
> >                 ByteCount = (curHigh * curBit32) + curLow
> >
> > Where curHigh, curLow, ByteCount, and curBit32 are type Currency.
> >
> >
>
> That's pretty much the same solution as posted here:
>
> http://www.freevbcode.com/ShowCode.asp?ID=6836
>
> Looks like you fixed it.

Ayup.

I've lost track of how many hours/daze/weeks/etc. I've wasted because MSFT
posts incorrect solutions.
Of course, what the gorilla says must be correct, so we SHEEPishly just copy
their crap.
Show quoteHide quote
>
> Jim Edgar
>
>
Author
20 Mar 2006 8:21 AM
J French
On Sun, 19 Mar 2006 15:05:51 -0500, "Howard Kaikow"
<kai***@standards.com> wrote:

>Here's what I used:
>
>                curHigh = CCur(WFD.nFileSizeHigh)
>                curLow = CCur(WFD.nFileSizeLow)
>                If curHigh < 0 Then
>                    curHigh = curHigh + curBit32
>                End If
>                If curLow < 0 Then
>                    curLow = curLow + curBit32
>                End If
>                ByteCount = (curHigh * curBit32) + curLow
>
>Where curHigh, curLow, ByteCount, and curBit32 are type Currency.

I prefer to use two UDTs
- on contains a Currency, the other has two Longs

LSet the 'Longs' UDT into the Currency UDT and you have a
calculation-less conversion

Then multiply the Currency by 10,000 and off you go.
Author
20 Mar 2006 1:55 PM
Howard Kaikow
Has it been the conclusion that the following works for all the OS?

curHigh = CCur(WFD.nFileSizeHigh)
                curLow = CCur(WFD.nFileSizeLow)
                If curHigh < 0 Then
                    curHigh = curHigh + curBit32
                End If
                If curLow < 0 Then
                    curLow = curLow + curBit32
                End If
                ByteCount = (curHigh * curBit32) + curLow

Where curHigh, curLow, ByteCount, and curBit32 are type Currency.