?
Solved

WIN32_FIND_DATA

Posted on 1998-05-20
8
Medium Priority
?
753 Views
Last Modified: 2010-05-18
As stated in another question, I am using the WinInet API to create an FTP client program.  While I have gotten the handle (no pun intended) on most of it's functionality, I am not sure how to extract the information I need from the WIN32_FIND_DATA structure.  Specifically, the filesize and the date created and modified.  If anyone can help with this little problem, your comments and suggestions will be greatly appreciated.  Thank you in advance, John
0
Comment
Question by:hozempa
  • 4
  • 2
  • 2
8 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1455979
the .ftCreationTime has creation time
the .ftLastWriteTime has modified time
nFileSizeHigh & nFileSizeLow contain the size


0
 
LVL 1

Author Comment

by:hozempa
ID: 1455980
I'm aware of the WIN32_FIND_DATA structure and it's elements but I was hoping for more of an example illustrating how to display the information.  When I tried to display the ftCreationTime(.dwLowDateTime and .dwHighDateTime) and nFileSizeHigh, they didn't show up as anything I recognized.  I assume that a function has to be performed upon the returned information in order to get it to display properly.  Please let me know if this is correct and if you have simple example of how to display the contents of a WIN32_FIND_DATA structure.  Thanks, John
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1455981
C has a macro defines, MAKELONG. It will be best for this case. The problem is, I don't think there is a way in VB to do the same thing. You can write a dll, pass the two values, and it will use MAKELONG to combine them, and return them as long
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:hozempa
ID: 1455982
I'm not very familiar with C.  Do you think you could expand upon the MAKELONG example for VB?
0
 
LVL 1

Author Comment

by:hozempa
ID: 1455983
Adjusted points to 75
0
 
LVL 1

Accepted Solution

by:
dnavarro earned 400 total points
ID: 1455984
FileSize# = (nFileSizeHigh * 4294967296) + nFileSizeLow

You need to call the Win32 API in order to convert the ftLastWriteTime value into a string.

DIM st AS SYSTEMTIME
DIM t AS STRING
DIM d AS STRING

' -- Convert the file time from UTC to local time
FileTimeToLocalFileTime fd.ftLastWriteTime, fd.ftLastWriteTime

' -- Convert the file time into a compatible system time
FileTimeToSystemTime fd.ftLastWriteTime, st

' Convert the date and time into strings that can be displayed
t = SPACE$(256)
d = SPACE$(256)

GetDateFormat LOCALE_USER_DEFAULT, DATE_SHORTDATE, st, BYVAL 0&, BYVAL d, 256
GetTimeFormat LOCALE_USER_DEFAULT, TIME_NOSECONDS, st, BYVAL 0&, BYVAL t, 256

The strings will need to be trimmed, but their ready to go.  If you don't have the Declares and constants for the API stuff, let me know.

--Dave
0
 
LVL 1

Author Comment

by:hozempa
ID: 1455985
Thanks, Dave, I would greatly appreciate the declares and constants for the mentioned API's.  I increased the points again since I think that this was trickier business than I had anticipated.  Anything other tidbits or gems you can throw my way would also be greatly appreciated.
0
 
LVL 1

Expert Comment

by:dnavarro
ID: 1455986
TYPE SYSTEMTIME
  wYear AS INTEGER
  wMonth AS INTEGER
  wDayOfWeek AS INTEGER
  wDay AS INTEGER
  wHour AS INTEGER
  wMinute AS INTEGER
  wSecond AS INTEGER
  wMilliseconds AS INTEGER
END TYPE

TYPE FILETIME
  dwLowDateTime AS LONG
  dwHighDateTime AS LONG
END TYPE

CONST LOCALE_USER_DEFAULT  = &H0000
CONST DATE_SHORTDATE = &H1
CONST DATE_LONGDATE = &H2
CONST TIME_NOSECONDS = &H2

DECLARE FUNCTION FileTimeToLocalFileTime LIB "KERNEL32.DLL" (lpFileTime AS FILETIME, lpLocalFileTime AS FILETIME) AS LONG

DECLARE FUNCTION GetDateFormat LIB "KERNEL32.DLL" (BYVAL Locale AS LONG, BYVAL dwFlags AS LONG, lpDate AS SYSTEMTIME, ByVal lpFormat AS String, ByVal lpDateStr AS String, BYVAL cchDate AS LONG) AS LONG

DECLARE FUNCTION GetTimeFormat LIB "KERNEL32.DLL" (BYVAL Locale AS LONG, BYVAL dwFlags AS LONG, lpTime AS SYSTEMTIME, ByVal lpFormat AS String, ByVal lpTimeStr AS String, BYVAL cchTime AS LONG) AS LONG

---

This code is actually from the PowerBASIC DLL Compiler for Windows, but I modified it for VB.  Email me at dave@powerbasic.com if you have any problems with it.

--Dave
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

862 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