Solved

WIN32_FIND_DATA

Posted on 1998-05-20
8
661 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
Comment Utility
the .ftCreationTime has creation time
the .ftLastWriteTime has modified time
nFileSizeHigh & nFileSizeLow contain the size


0
 
LVL 1

Author Comment

by:hozempa
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:hozempa
Comment Utility
I'm not very familiar with C.  Do you think you could expand upon the MAKELONG example for VB?
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:hozempa
Comment Utility
Adjusted points to 75
0
 
LVL 1

Accepted Solution

by:
dnavarro earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now