Question SystemTimeToFileTime function

forgery

New member
Joined
Jul 28, 2009
Messages
1
Programming Experience
1-3
Hi, I'm trying to use the SystemTimeToFileTime function but i'm not sure where what is missing.

My code generally looks like

VB.NET:
 Private Declare Function SystemTimeToFileTime Lib "kernel32" (ByVal _ lpSystemTime As SYSTEMTIME, ByVal lpFileTime As FILETIME) As Long


Sub Main

Dim lgDate as Long

mySystemTime as New SYSTEMTIME
fileTIME as New FILETIME

  lgDate = SystemTimeToFileTime(mySystemTime, fileTime)

End Sub

Obviously this is not everything, just the relevant sections.
mySystemTime is correct and it is passed through the fuction. fileTime however is just '0' HighDateTime and LowDateTime which obviously makes lgDate = 0.

I'm not sure what I need to do to actually to get the function to fill fileTime.

Any help would be greatly appreciated!! Many Thanks

Forg
 
Date type has a ToFileTime method among others: DateTime Methods (System)

About the SystemTimeToFileTime declaration you posted, it differs from the one returned by my system, so I'll post that here too:
VB.NET:
Declare Function SystemTimeToFileTime Lib "kernel32.dll" ( _ 
	 ByRef lpSystemTime As SYSTEMTIME, _ 
	 ByRef lpFileTime As FILETIME) As Int32
 
Please post in the most appropriate forum for the topic. Thread moved.

As JohnH says, your API declaration is incorrect. If you are going to use API functions then make sure you have a VB.NET declaration and not a VB6 one. Any declarations that contains Longs are very likely to be VB6. Windows API functions normally work with 32-bit numbers. In VB6 the Long type is 32-bits wide and the Integer type is 16-bits wide. In VB.NET the Long type is 64-bits wide and the Integer type is 32-bits wide.
 
Back
Top