Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CString as paramter in OCX method

Posted on 2006-06-22
2
Medium Priority
?
412 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
[X]
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
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

610 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