Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

COM question

Posted on 2004-04-21
5
262 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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