Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. FILETIME? DosDateTimeToFileTime() ?

FILETIME? DosDateTimeToFileTime() ?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomtoolshelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amit Dey
    wrote on last edited by
    #1

    How do I create a new FILETIME for given date and time? // pszDateTime like 12/3/2003 19:32 int day,month,year,hour,min = 0; sscanf(pszDateTime,"%d/%d/%d %d:%d",&day,&month,&year,&hour,&min); DOSTIME time; DOSDATE date; date.day = day; date.month = month; date.year = year - 1980; time.hour = hour; time.min = min; time.sec = 0; FILETIME fTime; if(**DosDateTimeToFileTime**(*(WORD*)&date,*(WORD*)&time,&fTime)==0) return -1; Problem is DosDateTimeToFileTime() always fails. I want a FILETIME that I could compare with using CompareFileTime(). TIA. :)

    Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
    Writing Word addins Office addin

    M 1 Reply Last reply
    0
    • A Amit Dey

      How do I create a new FILETIME for given date and time? // pszDateTime like 12/3/2003 19:32 int day,month,year,hour,min = 0; sscanf(pszDateTime,"%d/%d/%d %d:%d",&day,&month,&year,&hour,&min); DOSTIME time; DOSDATE date; date.day = day; date.month = month; date.year = year - 1980; time.hour = hour; time.min = min; time.sec = 0; FILETIME fTime; if(**DosDateTimeToFileTime**(*(WORD*)&date,*(WORD*)&time,&fTime)==0) return -1; Problem is DosDateTimeToFileTime() always fails. I want a FILETIME that I could compare with using CompareFileTime(). TIA. :)

      Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
      Writing Word addins Office addin

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Without knowing what DOSDATE/DOSTIME are I can't say. But since you have the month/day/year/hour/minute already separated, just fill in a SYSTEMTIME and call SystemTimeToFileTime(). --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber Actual sign at the laundromat I go to: "No tinting or dying."

      A 1 Reply Last reply
      0
      • M Michael Dunn

        Without knowing what DOSDATE/DOSTIME are I can't say. But since you have the month/day/year/hour/minute already separated, just fill in a SYSTEMTIME and call SystemTimeToFileTime(). --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber Actual sign at the laundromat I go to: "No tinting or dying."

        A Offline
        A Offline
        Amit Dey
        wrote on last edited by
        #3

        Mike,A big hello.:) sorry I missed that part. DOSDATE and DOSTIME structs looks like: typedef struct DOSDATE { WORD day; WORD month; WORD year; }DOSDATE; typedef struct DOSTIME { WORD hour; WORD min; WORD sec; }DOSTIME; But I cann't seem to get it right.:confused:

        Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
        Writing Word addins Office addin

        M 1 Reply Last reply
        0
        • A Amit Dey

          Mike,A big hello.:) sorry I missed that part. DOSDATE and DOSTIME structs looks like: typedef struct DOSDATE { WORD day; WORD month; WORD year; }DOSDATE; typedef struct DOSTIME { WORD hour; WORD min; WORD sec; }DOSTIME; But I cann't seem to get it right.:confused:

          Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
          Writing Word addins Office addin

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          Well, casting a DOSDATE to a WORD won't do you any good, since a DOSDATE is not a WORD, nor is it packed into a WORD as described in the docs for DosDateTimeToFileTime(). You'll need to pack them yourself, or do some trickery with the structs, maybe this (note: untested):

          typedef struct DOSDATE
          {
          unsigned day : 5;
          unsigned month : 4;
          unsigned year : 7;
          } DOSDATE;

          typedef struct DOSTIME
          {
          unsigned hour : 5;
          unsigned min : 6;
          unsigned sec : 5;
          } DOSTIME;

          --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber If my rhyme was a drug, I'd sell it by the gram.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups