LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing LabVIEW to the GetFileTime function in kernel32.dll

I am attempting to get the creation date/time of a file. The GetFileTime function inside kernel32.dll seems like a good choice. It requires a handle to the file, so I open the file, typecast the refnum to a U32 and pass the U32 to the Call Library function node. The outputs I expect are pointers to strings, so I use the C string pointer.

I am at a loss of why this doesn't work. I have my crude VI (LV7.0) attached.
0 Kudos
Message 1 of 3
(3,300 Views)
Hi,

If you use GetFileTime, the handle has to be opened with:

HFILE OpenFile(
LPCSTR lpFileName, // file name
LPOFSTRUCT lpReOpenBuff, // file information
UINT uStyle // action and attributes
);

LV's file handle is not compatible!

Also, this function is tricky. lpCreationTime is not a pointer to a string,
but a pointer to a FILETIME structure. You should provide it with pointers
to clusters with two U32's in it. You can do this by making a cluster with
two integers in it, and wire it (three times) to the dll. The dll has to be
configured as "adapt to type".

You should convert the FILETIME structures to SYSTEMTIME's with:

BOOL FileTimeToSystemTime(
CONST FILETIME *lpFileTime, // file time to convert
LPSYSTEMTIME lpSystemTime
// receives system time
);

Regards,

Wiebe.


"Mark Borodkin" wrote in message
news:506500000008000000D0A20000-1042324653000@exchange.ni.com...
> I am attempting to get the creation date/time of a file. The
> GetFileTime function inside kernel32.dll seems like a good choice. It
> requires a handle to the file, so I open the file, typecast the refnum
> to a U32 and pass the U32 to the Call Library function node. The
> outputs I expect are pointers to strings, so I use the C string
> pointer.
>
> I am at a loss of why this doesn't work. I have my crude VI (LV7.0)
> attached.
0 Kudos
Message 2 of 3
(3,300 Views)
Hi Mark

This VI should do what you want.

Regards,
Luca
Regards,
Luca
0 Kudos
Message 3 of 3
(3,300 Views)