Solved

CString as paramter in OCX method

Posted on 2006-06-22
2
384 Views
Last Modified: 2010-04-17
Hi,
I am developing an OCX application.
I want to write a method using the class wizard. The method has a paramter of type CString, but the Class Wizard does not support the CString as a paramter type.

What shoud i use as a substitue.

Please help !!!
0
Comment
Question by:jhav1594
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 16966405
For COM methods, strings are passed as BSTR.
If you need to call such method having CString, use CString::AllocSysString method. Using API, BSTR can be created with SysAllocString method.
Inside of this function you can work with BSTR parameter using _bstr_t or CComBSTR wrappers.
0
 
LVL 5

Expert Comment

by:bastibartel
ID: 16966463
Simply use the class wizard to add a method with BSTR parameter.
The class wizard will do everything for you. - I mean, everything.



 
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

730 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