By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,704 Members | 1,391 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,704 IT Pros & Developers. It's quick & easy.

Convert time to FILETIME

P: 34
hi,

wel I have these vars:

double day,month,year,hour,minute,second,millisecond;

I want to convert this data to a filetime structure, I don't want of course to convert them manually


please help
May 21 '08 #1
Share this Question
Share on Google+
2 Replies


100+
P: 424
I think an int would be more appropriate... To copy those variables into a struct, you can use this syntax:
Expand|Select|Wrap|Line Numbers
  1. struct FileTime
  2. {
  3.     int day;
  4.     int hour;
  5.     // etc
  6.     FileTime(const int& d, const int& h);
  7. };
  8.  
  9. FileTime::FileTime(const int& d, const int& h)
  10.     : day(d), hour(h)
  11. { }
  12.  
  13. int main()
  14. {
  15.     int day = 1, hour = 23;
  16.     FileTime ft(day, hour);
  17.     cout << "The day is " << ft.day << endl;
  18. }
  19.  
In C, structs can't have constructors. In that case you could define a function which takes your variables and a (pointer to a) struct, and sets the struct variables accordingly.
May 21 '08 #2

P: 34
Thx,

In fact, I don't want to define a new FileTime structure, I'd like to use the C predefined FILETIME structure.
May 23 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.