CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2002
    Posts
    1,435

    Millisecond resolution in date/time COM property

    I have a COM Automation object based on the MFC CCmdTarget class and one of its properties is a date/time stamp. Internally, the application acquires date and time via the SYSTEMTIME structure and a call to ::GetSystemlTime(). The SYSTEMTIME structure has a field for milliseconds and calls to ::GetSystemTime() always fill in this field.

    However, the standard method of accessing a date/time (at least 10 years ago when this server was created) is via the VARIANT VT_DATE type which I understand is equivalent to the DATE type and apparently the DATE / VT_DATE type does not have millisecond resolution. So, whenever a COM client accesses the date and time from my server, the milliseconds field is truncated to 0. This has been acceptable until recently when it was determined that a particular client application would benefit greatly from having millisecond resolution.

    This client application is written in C# and it is able to access my property via the C# object DateTime, The DateTime object has millisecond resolution but, again, when it accesses my property the milliseconds are truncated.

    My question is this: Is there some way I can modify my old MFC CmdTarget-based object to return a date/time with millisecond resolution? I don't really want to use a work-around, such as creating a new property or method that returns something like a string formatted to include milliseconds.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Millisecond resolution in date/time COM property

    I guess you should pass the whole SYSTEMTIME structure via VARIANT.
    See:
    Using User Defined Types in COM & ATL
    HOWTO: Use structs in Automation-compatible interface
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured