Click here to Skip to main content
16,016,306 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Views derived from CWnd Pin
Joaquín M López Muñoz23-May-02 19:56
Joaquín M López Muñoz23-May-02 19:56 
GeneralRe: Views derived from CWnd Pin
Nish Nishant23-May-02 20:42
sitebuilderNish Nishant23-May-02 20:42 
GeneralCreateThread Vs CreateProcess Pin
23-May-02 19:50
suss23-May-02 19:50 
GeneralRe: CreateThread Vs CreateProcess Pin
Joaquín M López Muñoz23-May-02 19:53
Joaquín M López Muñoz23-May-02 19:53 
GeneralActiveX ATL Pin
Sameer Maggon23-May-02 19:07
Sameer Maggon23-May-02 19:07 
GeneralRe: ActiveX ATL Pin
Paul M Watt23-May-02 19:50
mentorPaul M Watt23-May-02 19:50 
GeneralRe: ActiveX ATL Pin
Sameer Maggon23-May-02 20:43
Sameer Maggon23-May-02 20:43 
GeneralRe: ActiveX ATL Pin
Paul M Watt23-May-02 21:14
mentorPaul M Watt23-May-02 21:14 
You cannot use the LPSTR datatype if you want your COM objects to be portable outside of C++. You will need to use the BSTR datatype.

Here is a little bit of information about BSTRs.

They are UNICODE strings, so you will have to use the ATL conversion macros to convert between your ansi single character string and the wide char UNICODE string in ATL. Lookup A2W in MSDN and you will find some info about it.

A BSTR is special in the fact that it contains the size of the BSTR encoded in its format. When you deal with a BSTR you are given a pointer to the string portion of the BSTR. However, the 4 bytes preceding that pointer contain the size of the BSTR.
example:

pointer
|
size | string data wide chars
4 bytes V 12 bytes, as the size fild indicates
[12] [\0H\0e\0l\0l\0o\0\0]

You can also use the CComBSTR class in ATL to manage your BSTR variables for you, it simplifies things a lot.

You will also want to become familiar with the ::SysAllocString and ::SysFreeString functions. These are the functions that you will use to allocate a new BSTR.

good luck


Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!

GeneralRe: ActiveX ATL Pin
Sameer Maggon23-May-02 21:18
Sameer Maggon23-May-02 21:18 
GeneralPrinting from multiple views Pin
slackboy23-May-02 18:30
slackboy23-May-02 18:30 
GeneralRe: Printing from multiple views Pin
Jonathan Craig24-May-02 3:31
Jonathan Craig24-May-02 3:31 
GeneralRe: Printing from multiple views Pin
slackboy25-May-02 19:50
slackboy25-May-02 19:50 
QuestionHow to add a shortcut to the toolbar of IE? Pin
George Ma23-May-02 16:44
George Ma23-May-02 16:44 
AnswerA sample ... Pin
Karavaev Denis23-May-02 19:24
Karavaev Denis23-May-02 19:24 
GeneralRe: A sample ... Pin
23-May-02 19:58
suss23-May-02 19:58 
Questionhow to send a virtual key in a service Pin
23-May-02 16:19
suss23-May-02 16:19 
GeneralCustom Buttons Using CDialogBar, CButton, and CControlBar :: MFC Pin
valikac23-May-02 13:22
valikac23-May-02 13:22 
GeneralRe: Custom Buttons Using CDialogBar, CButton, and CControlBar :: MFC Pin
valikac23-May-02 19:29
valikac23-May-02 19:29 
GeneralPrinting C/C++ source code in color Pin
SAK23-May-02 12:38
SAK23-May-02 12:38 
GeneralRe: Printing C/C++ source code in color Pin
Martin Ziacek23-May-02 19:34
Martin Ziacek23-May-02 19:34 
GeneralFile->Open Pin
Stew23-May-02 12:03
Stew23-May-02 12:03 
GeneralRe: File->Open Pin
Stew23-May-02 12:29
Stew23-May-02 12:29 
GeneralPrinting Question Pin
Stew23-May-02 10:31
Stew23-May-02 10:31 
GeneralRe: Printing Question Pin
Stew23-May-02 11:18
Stew23-May-02 11:18 
GeneralRe: Printing Question Pin
Jonathan Craig23-May-02 11:18
Jonathan Craig23-May-02 11:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.