LARGE_INTEGER arithmetic...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is some code of mine for seeing if a printer job, jobs[0], is more than 5 minutes old

FILETIME syst, jobt
LARGE_INTEGER syst2, jobt2, dt

GetSystemTimeAsFileTime(&syst)
SystemTimeToFileTime(&jobs[0].Submitted, &jobt)
syst2.HighPart = syst.dwHighDateTime
syst2.LowPart = syst.dwLowDateTime
jobt2.HighPart = jobt.dwHighDateTime
jobt2.LowPart = jobt.dwLowDateTime

dt.QuadPart = syst2.QuadPart - jobt2.QuadPart

if (dt.QuadPart > (5 * 600000000)) // 5 minutes in hundreds of nanosecond
return = true
else return = false

Is this the correct way of the doing the LARGE_INTEGER arithmetic? Or am I overlooking something? Thanks in advance!
 
I should have mentioned that the code works for 1 and 2 minutes in place of the 5 in the 'if' statement, but for some reason does not work for the 5. Regardless of how hold the job is, it returns true if I put a 5 in there, but not for a 2 or a 1.
 
Need said:
Here is some code of mine for seeing if a printer job, jobs[0], is
more than 5 minutes old:

FILETIME syst, jobt;
LARGE_INTEGER syst2, jobt2, dt;

GetSystemTimeAsFileTime(&syst);
SystemTimeToFileTime(&jobs[0].Submitted, &jobt);
syst2.HighPart = syst.dwHighDateTime;
syst2.LowPart = syst.dwLowDateTime;
jobt2.HighPart = jobt.dwHighDateTime;
jobt2.LowPart = jobt.dwLowDateTime;

dt.QuadPart = syst2.QuadPart - jobt2.QuadPart;

if (dt.QuadPart > (5 * 600000000)) // 5 minutes in hundreds of

write this as 5*600000000I64 so that it's done as a 64-bit multiply.

The problem you're having is that you're overrunning a 32-bit signed integer
..

-cd
 
Back
Top