Solved

WIN32_FIND_DATA

Posted on 1998-05-20
8
671 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 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

21 Experts available now in Live!

Get 1:1 Help Now