Solved

URGENT: ATL component to convert string

Posted on 2001-06-21
5
223 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordpress limitations 4 115
countEvens challenge 2 100
Question to Pivot table 1 53
Message not shown 5 50
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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…

770 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