带有UNICODE的Outlook COM API ......怎么样? [英] Outlook COM API with UNICODE... how?

查看:78
本文介绍了带有UNICODE的Outlook COM API ......怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们多年来一直在C ++应用程序中使用Outlook COMAPI ......它运行正常。现在我们必须扩展我们的应用程序以使用UNICODE ...但我找不到任何信息但是如何做到这一点(也许它很简单,没有明确提及)。

该应用程序的主要任务是1)创建一个"Outlook.Application"。对象,2)创建一个新的邮件项目,3)附加文件。

文件附加是用(伪)代码完成的:

    ;附件ats;

    ... //此处创建了附件对象

    _variant_t vtSource((LPCTSTR)szPathfile);

    _variant_t vtType((long)olByValue);

   附件(ats.Add(vtSource,vtType));

    at.SetDisplayName(szFilename);

   

问题是:如果szPathfile和szFilename应该从(char *) - type更改为(wchar_t *) - type,必须使用哪些API对象/函数?

We use the Outlook COMAPI in an C++ application since many years... and it works okay. NOW we have to expand our App for UNICODE usage... but I couldn't find any information yet how to do this (perhaps it is so simple that it isn't mentioned explicitly).
The main task of the App is 1) create an "Outlook.Application" object, 2) create a new mail item, 3) attach files to it.
The file attaching is done with the (pseudo) code:
    Attachments ats;
    ... // here the Attachments object is created
    _variant_t vtSource((LPCTSTR)szPathfile);
    _variant_t vtType((long)olByValue);
    Attachment at(ats.Add(vtSource, vtType));
    at.SetDisplayName(szFilename);
   
The question is: if szPathfile and szFilename should be changed from (char *)-type to (wchar_t *)-type, which API objects/functions have to be used?

推荐答案

所有IDispatch派生的对象(包括Outlook对象模型中的所有对象)都是本机Unicode;变体只能包含Unicode字符串。

All IDispatch-derived objects (that includes all objects in the Outlook Object Model) are native Unicode; variants can only contain Unicode strings.

_variant_t构造函数应该能够将wchar_t *或LPWSTR作为参数。

_variant_t constructor should be able to take wchar_t* or LPWSTR as a parameter.


这篇关于带有UNICODE的Outlook COM API ......怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆