Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

WIN32_FIND_DATA

Posted on 1998-05-20
8
685 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

829 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