Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2004

Tip: Looking for answers? Try searching our database.

LARGE_INTEGER arithmetic...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Need Helps - 28 May 2004 21:21 GMT
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!
Need Helps - 28 May 2004 21:36 GMT
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.
Carl Daniel [VC++ MVP] - 29 May 2004 00:24 GMT
> Here is some code of mine for seeing if a printer job, jobs[0], is
> more than 5 minutes old:
[quoted text clipped - 12 lines]
>
> 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
Need Helps - 29 May 2004 19:41 GMT
THANK YOU very much.  That should complete my first Win32 project.  =)

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.