Solved

COM question

Posted on 2004-04-21
5
233 Views
Last Modified: 2013-11-25
I am writing a COM component. I declared my method as following:
HRESULT __stdcall PACK([in]TCHAR *src, [in]int srclen, [out, retval]TCHAR *retval);
After compiling and registered the COM, I checked the component using OLE/COM object viewer, and I saw the following:
HRESULT PACK([in] short* src, [in] int srclen, [out, retval] short* retval);
Why is my TCHAR being converted to "short", but not char or wchar?? I think this messed up my string manipulation in the code. I want the src and retval to be "char" just like in regular C++.
0
Comment
Question by:kc2592
  • 2
5 Comments
 

Author Comment

by:kc2592
ID: 10895481
Please Help!!
0
 

Author Comment

by:kc2592
ID: 10934497
Please HELP!!
0
 
LVL 9

Accepted Solution

by:
_ys_ earned 100 total points
ID: 11067458
TCHAR [and even char] are not valid COM types. Please use BSTR for string variables instead.

You will have to use SysAllocString and SysFreeString to manage their memory - (oleauto.h)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now