Solved

URGENT: ATL component to convert string

Posted on 2001-06-21
5
213 Views
Last Modified: 2013-11-25
I want to make an ATL component in Visual C++ (No MFC).
I want to make a function that converts a string, example:




HRESULT ConvertString( string  strSomething);
strSomething is an input / output parameter!!

2 questions:

- What type can I use for strSomething?
- What actions do I have to do to add the method to my component and export it?
(should I add it to the interface AND to the class or is there some kind of wizard? )

Thanks in advance!!!
0
Comment
Question by:MelissaC
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:migel
ID: 6213860
Hi!
1. COM interfaces use BSTR strings (UNICODE wide char strings),

2. You MUST define new interface (let it be : IStringConverter)
3. To do this you just in the ATL project
right click on the project name in the workspace class tab.
and choose New ATL object.
ATL "wizard" will apear - here you must set name for your interface and coClass.
4. after wizard finish you will see your new interface in the class tab
5. RightClick on the interface and choose Add method
6 in the appeared dialog type method name :
ConvertString
and its parameters:
[in, out, retval] BSTR bstrString;
click ok.
0
 
LVL 2

Expert Comment

by:tdubroff
ID: 6214430
I don't think you want retval in the attribute list.  If you do use retval in the attribute list, then I think your VB code would look like this:

' assume obj is an IStringConverter
dim str as String
str = "abl;kjadsf"
str = obj.ConvertString(str)  ' this line doesn't quite make sense

If you get rid of the retval, then the VB code would be:

dim str as String
str = "abl;kjadsf"
obj.ConvertString(str)
0
 
LVL 12

Accepted Solution

by:
migel earned 200 total points
ID: 6276373
Hey!
anybody here?
none???
so I lock this Q.
0
 
LVL 2

Expert Comment

by:tdubroff
ID: 6276397
Your lock is not an answer!  Kindly remove it.
0
 
LVL 12

Expert Comment

by:migel
ID: 6276524
But My previous comment is ansver.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
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…

862 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

24 Experts available now in Live!

Get 1:1 Help Now