# Convert long int to filetime?

I have used GetSystemTime, SystemTimeToFileTime and systemint = (systemfiletime.dwHighDateTime << 32) +  systemfiletime.dwLowDateTime;
Now I want to subtract sevendays and then convert it to FILETIME again. How do I do that??
###### Who is Participating?

Commented:
You can subtract 7 days by converting 7 days to 100s of nanoseconds.   A nanosecond is 1/100,000th of a second, so a 100 nanoseconds is 1/1000th of a second.  I'll call 1/1000th of a second a filetime unit. Thus 7 days is

7days * 24Hours/day * 60 Minutes/Hour * 60 seconds/minute * 1000 filetimeunits/second

so the amount you want to subtract is 7*24*60*60*1000.

continues
0

Commented:
Then to convert it back to a file time, use
FILETIME FT;

FT.dwLowDateTime = (DWORD) systemint & 0xFFFFFFFF;
FT.dwHighDataTime = (DWORD) ((systemint >> 32) & 0xFFFFFFFF);
0

Author Commented:
What does (systemint >> 32 ) mean?
Every byte above 32 bytes?

Thanks!
0

Commented:
No, shift the 64 bit value in systemtime to the "right"  (shift toward low bits) by 32 bits.  Thus the high 32 bits become the low 32 bits and the previous low 32 bits are lost.
0

Author Commented:
Hmm I dont get the right year back ... can it be beacuae I have:
long int systemint; ?? What should it be (I want a 64 bit integer)
0

Author Commented:
In other words I need a LARGE_INTEGER...
0

Commented:
What compiler are you using?

Try "__int64".   That is what VC uses.
0

Author Commented:
Borland C++ 5.02, well it seem that I have to convert LARGE_INTEGER to FILETIME , it says so in the help file. Im sorry for not knowing that until now :-\

Â·Copy the resulting FILETIME structure to a LARGE_INTEGER structure.
Â·Use normal 64-bit arithmetic on the LARGE_INTEGER value.

0

Commented:
a regular 64 bit integer would be more direct.

LARGE_INTEGER is a union of a 64-bit integer and 2 32-bit integers.  you would use it like.

LARGE_INTEGER LI;

LL.LowPart = FT.dwLowDateTime;
LL.HighPart = FT.dwHighDateTime;
FT.dwLowDateTime = LL.LowPart;
FT.dwHighDateTime = LL.HighPart;

0

Author Commented:
Yes thought so too ... but it says:
'LowPart' is not a member of '_LARGE_INTEGER' and
'HighPart' is not a member of '_LARGE_INTEGER'

Do I have to make my own data type LARGE_INTEGER or? It finds QuadPart but not LowPart and HighPart ... :(

why doesnt things work the way I want it :P

Thanks!
0

Commented:
The LARGE_INTEGER union uses an embedded annonymous structure.  It appears like that may cause a problem just like you are having with other compilers.  (I'm not sure if that is considered legal or illegal by the C++ standard.)  They seem to have a sort of patch where they give the large integer's strucuture the nane "u", so try placing a "u." before the lowpart and highpart.
0

Author Commented:
Yes that worked , but it seems like I dont have acces to QuadPart at the same time as u.LowPart and u.HighPart ... ill try to get it to work!

Thanks alot!
0

Commented:
what do you mean by I dont have acces to "QuadPart at the same time as u.LowPart and u.HighPart"
0

Author Commented:
I got it to work ... I had declared an integer that was to smal to hold the information :-\.

I have an other error that reminds on this one with, if you want you can check my other question.

Where did you get the information about the u.LowPart ?
0

Commented:
What other question?  what is its ID?   (right above the question box there is a line that will end with Q.XXXXXX.   The XXXXX number identifies the question)

The "u" is undocumented.  I looked for the structure definition in the windows include files.  It was there.  The structure appears in multiple forms using conditional compilation (#ifdef's).  I just guessed that the form with the "u" was being used.
0

Author Commented:
Ok thanks!

This is the question that I cant get to work ... I would be very pleased if you could help me there.

It's about how to start a function after the main window has been setup and is visible.
ID: Q.10179191
0

Commented:
I don't think I can help there.  I don't know OWL.   I would avoid using timers as Alex suggests, though.  You don't know how long to wait.   Your best bet is to take action the first time the window is painted.
0

Author Commented:
Oki.

The problem is that I cant find that action :-l ... i'll have to look some more ... cause there have to be one.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.