Jump to content

Problem with the creation and processing of FILETIME structures


Go to solution Solved by Danyfirex,

Recommended Posts

I am still working on the UDF for for BITS (Background Intelligent Transfer Service).
This time I have a problem with the implementation of the IBackgroundCopyJob::GetTimes method.
My determined timestamps all have the date January 1, 1601, which is the start date for time calculation for the FILETIME structure.
I do use the _Date_Time_FileTimeToSystemTime function to convert to a system time, but I must have made a mistake somewhere that I am not getting the correct, current timestamps.

Here is a link to the current working state of the UDF:
https://github.com/DonChunior/BITS-UDF/tree/GetTimes

And with this sample code the problem can be reproduced:

#include <BITS.au3>
#include <Array.au3>

Main()

Func Main()
    Local $oBackgroundCopyManager = _BITS_Connect()
    Local $oJob = _BITS_BackgroundCopyManager_CreateJob($oBackgroundCopyManager, "Test_Job", $BG_JOB_TYPE_DOWNLOAD)
    _BITS_BackgroundCopyJob_AddFile($oJob, "http://ipv4.download.thinkbroadband.com/1GB.zip", "C:\Temp\1GB.zip")
    _BITS_BackgroundCopyJob_Resume($oJob)
    Sleep(10000)
    Local $aTimes = _BITS_BackgroundCopyJob_GetTimes($oJob)
    ConsoleWrite(_ArrayToString($aTimes) & @CRLF)
    _BITS_BackgroundCopyJob_Cancel($oJob)
EndFunc

As always, I appreciate any help!

Link to comment
Share on other sites

Hello I think is this way:

Local $iSizeFILETIME = 2 * 4
Local $tFILETIME = DllStructCreate($tagFILETIME, DllStructGetPtr($tBG_JOB_TIMES) + ($iSizeFILETIME * 0))  ;FILETIME1
$tFILETIME = DllStructCreate($tagFILETIME, DllStructGetPtr($tBG_JOB_TIMES) + ($iSizeFILETIME * 1))  ;FILETIME2
$tFILETIME = DllStructCreate($tagFILETIME, DllStructGetPtr($tBG_JOB_TIMES) + ($iSizeFILETIME * 2))  ;FILETIME3

Saludos

Link to comment
Share on other sites

25 minutes ago, Danyfirex said:

Hello I think is this way:

Local $iSizeFILETIME = 2 * 4
Local $tFILETIME = DllStructCreate($tagFILETIME, DllStructGetPtr($tBG_JOB_TIMES) + ($iSizeFILETIME * 0))  ;FILETIME1
$tFILETIME = DllStructCreate($tagFILETIME, DllStructGetPtr($tBG_JOB_TIMES) + ($iSizeFILETIME * 1))  ;FILETIME2
$tFILETIME = DllStructCreate($tagFILETIME, DllStructGetPtr($tBG_JOB_TIMES) + ($iSizeFILETIME * 2))  ;FILETIME3

Saludos

Thanks for trying, @Danyfirex.
I implemented your idea in the following code to test it for the first FILESYSTEM structure - the creation time:

Func _BITS_BackgroundCopyJob_GetTimes(Const ByRef $oBackgroundCopyJob)
    Local $tBG_JOB_TIMES = 0
    Local $tFILETIME = 0
    Local $tSYSTEMTIME = 0
    Local $aTimes[3] = ["", "", ""]

    $tBG_JOB_TIMES = DllStructCreate($tagBG_JOB_TIMES)
    $oBackgroundCopyJob.GetProgress($tBG_JOB_TIMES)
    $tFILETIME = DllStructCreate($tagFILETIME, DllStructGetPtr($tBG_JOB_TIMES))
    $tSYSTEMTIME = _Date_Time_FileTimeToSystemTime($tFILETIME)
    ConsoleWrite(_Date_Time_SystemTimeToDateTimeStr($tSYSTEMTIME, 1) & @CRLF)
    $tFILETIME = 0
    $tBG_JOB_TIMES = 0

    Return $aTimes
EndFunc   ;==>_BITS_BackgroundCopyJob_GetTimes

Unfortunately the timestamp is still in the year 1601. 😞

Link to comment
Share on other sites

  • Solution
Link to comment
Share on other sites

It happens to all of us 🤣

I'm getting some issue while creating the BackgroundCopyManager Instance. I get AutoIt stuck while creating "{4BD3E4E1-7BD4-4A2B-9964-496400DE5193}", _ ; BITS 10.1 instance.

BITS 10.3  and BITS 10.2 fails correctly. but BITS 10.1 make my code get stuck forever in the ObjCreateInterface. I'll check deeply later. It's just to to let you know.

 

Saludos

 

 

Link to comment
Share on other sites

7 minutes ago, Danyfirex said:

BITS 10.3  and BITS 10.2 fails correctly. but BITS 10.1 make my code get stuck forever in the ObjCreateInterface. I'll check deeply later. It's just to to let you know.

Interesting. If you find out more, please share your findings with me.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...