Solved

WIN32_FIND_DATA

Posted on 1998-05-20
8
679 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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 100 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

773 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