Convert time to FILETIME

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nabil035
    New Member
    • Mar 2008
    • 34

    #1

    Convert time to FILETIME

    hi,

    wel I have these vars:

    double day,month,year, hour,minute,sec ond,millisecond ;

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


    please help
  • arnaudk
    Contributor
    • Sep 2007
    • 425

    #2
    I think an int would be more appropriate... To copy those variables into a struct, you can use this syntax:
    [code=cpp]
    struct FileTime
    {
    int day;
    int hour;
    // etc
    FileTime(const int& d, const int& h);
    };

    FileTime::FileT ime(const int& d, const int& h)
    : day(d), hour(h)
    { }

    int main()
    {
    int day = 1, hour = 23;
    FileTime ft(day, hour);
    cout << "The day is " << ft.day << endl;
    }
    [/code]

    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.

    Comment

    • nabil035
      New Member
      • Mar 2008
      • 34

      #3
      Thx,

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

      Comment

      Working...