Beginner's COM question (easy) 
Author Message
 Beginner's COM question (easy)

Is it standard to use Unicode characters in all COM interfaces? In other
words, should I always use "wchar_t" in place of "char" ? If so, then I
assume that COM development should NOT proceed using the Windows generic
text mapping types found in "tchar.h", such as _TCHAR, LPCTSTR and so forth.
Is that correct? If so, then this also means that I should always use
Unicode based functions for text manipulation. By the way, does it matter if
I use "wchar_t" directly or is OLECHAR and its cousins like LPOLESTR more
appropriate (I believe so). Thanks in advance.


Tue, 22 Jan 2002 03:00:00 GMT  
 Beginner's COM question (easy)

Quote:
>Is it standard to use Unicode characters in all COM interfaces?

Yes, all COM string interfaces use BSTRs which are Unicode strings.

Quote:
>In other
>words, should I always use "wchar_t" in place of "char" ?

Not necessarily.

Remember that Win9x only has very basic Unicode support (you can
convert to and from a multi-byte string), so if you are creating an
object that works on any platform, it may still be best to write your
code internally using normal "char" - i.e. Windows multi-byte
character set, and perform conversions to/from BSTRs at your interface
boundaries.

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Wed, 23 Jan 2002 03:00:00 GMT  
 Beginner's COM question (easy)
I have to admit, that although I'm a very experienced developer, it's a pain

#defined types around. It's pathetic quite frankly and I'm sure many others
agree. I'm fairly new to COM and I have several books on the subject
including one from a veteran developer on the VC++ COM development team. He
says that strings in particular should be handled in Unicode via wchar_t
even on Win95 (even though it doesn't handle Unicode natively like NT). He
doesn't say you necessarily have to use BSTR which I believe is targetted
for IDispatch interfaces only (not mandatory but a matter of convention -
most dispatches seem to be dual anyway so it's probably the choice for
most). This abysmal array of different types including variants (which I
find ugly beyond belief) should be scrapped altogether. A new release of COM
should be impelemented with a cleaner and more standarzied approach to
handling types (backwards compatibility, forget it - those who have old
applications to maintain can continue to use the older version of COM).


Quote:
> >Is it standard to use Unicode characters in all COM interfaces?

> Yes, all COM string interfaces use BSTRs which are Unicode strings.

> >In other
> >words, should I always use "wchar_t" in place of "char" ?

> Not necessarily.

> Remember that Win9x only has very basic Unicode support (you can
> convert to and from a multi-byte string), so if you are creating an
> object that works on any platform, it may still be best to write your
> code internally using normal "char" - i.e. Windows multi-byte
> character set, and perform conversions to/from BSTRs at your interface
> boundaries.

> Dave
> ----
> My address is altered to discourage junk mail.
> Please post responses to the newsgroup thread,
> there's no need for follow-up email copies.



Wed, 23 Jan 2002 03:00:00 GMT  
 Beginner's COM question (easy)

Quote:
>I have to admit, that although I'm a very experienced developer, it's a pain
>in the

>#defined types around.

John,

I can only sympathise with you. I find COM hard work too. The basic's
are straightforward and quite elegant, but as soon as you start doing
anything real it can quickly become very messy, and the number of
interfaces that you have to understand and implement in some form or
another, can be bewildering.

All I can say is persevere, take it a small step at a time.

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Thu, 24 Jan 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Beginner's COM question (easy)

2. EASY EASY BEGINNER ??

3. Very easy beginners question

4. Beginner: CFile, a really easy(?) question

5. EASY Beginner question

6. This is a biztalk question but probably an easy question for you C# guru's

7. Real Fast 'n' Easy Question --

8. Easy Question for ppl with ATL/COM experience..

9. Easy question for COM veterans

10. COM question / beginner

11. A few beginner questions on arguments to COM Interface functions

12. beginner COM/ActiveX question...

 

 
Powered by phpBB® Forum Software