COM,返回一个DATE信息
我需要从 COM 服务器返回日期信息。我在 IDL 中看到 DATE 类型,在 C/C++ 中被映射到 double 类型。当我返回日期时,我会在内部从 SYSTEMTIME 转换为 double 以便匹配所需的输出类型,如下所示:
... comIFaceMethod(DATE* result)
{
SYSTEMTIME computed;
::SystemTimeToVariantTime(&computed, result);
}
这是通过 COM 传输日期信息的正确方法吗?我问这个是因为这种方法有效,但有时我也会看到一些奇怪的结果,但不知道原因。我的最后一个选择是在 COM 中定义我自己的 SYSTEMTIME 结构来传输结果,但我更喜欢更好的解决方案...
在上面的示例中,我在其他地方计算“计算”,并且还验证 SystemTimeToVariantTime 转换的结果
I need to return from a COM server a date information. I saw the DATE type in IDL which in C/C++ was mapped to a double type. When I return the date I would convert internally from SYSTEMTIME to double in order to match the required output type like this:
... comIFaceMethod(DATE* result)
{
SYSTEMTIME computed;
::SystemTimeToVariantTime(&computed, result);
}
Is this the correct way of transfering a date information through COM ? I ask this because this kind of works but I also see some strange results sometimes and don't know the reason. My last alternative would be to define my own SYSTEMTIME struct in COM to transfer results but I would prefer a better solution...
In the example above I compute "computed" some place else and I also validate result from SystemTimeToVariantTime conversion
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该代码示例展示了通过 COM 传输日期信息的正确方法。
“我问这个是因为这种方法有效,但有时我也会看到一些奇怪的结果” - 现在它有效了。
The code sample showed a correct way of transferring date information through COM.
"I ask this because this kind of works but I also see some strange results sometimes" - it works now.