Click here to Skip to main content
16,011,578 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionconvert CString to a _bstr_t - how to? Pin
ns19-Sep-02 1:00
ns19-Sep-02 1:00 
AnswerRe: convert CString to a _bstr_t - how to? Pin
dabs19-Sep-02 1:25
dabs19-Sep-02 1:25 
GeneralRe: convert CString to a _bstr_t - how to? Pin
ns19-Sep-02 1:31
ns19-Sep-02 1:31 
GeneralRe: convert CString to a _bstr_t - how to? Pin
ns19-Sep-02 1:32
ns19-Sep-02 1:32 
GeneralRe: convert CString to a _bstr_t - how to? Pin
dabs19-Sep-02 1:39
dabs19-Sep-02 1:39 
AnswerRe: convert CString to a _bstr_t - how to? Pin
Trollslayer19-Sep-02 1:42
mentorTrollslayer19-Sep-02 1:42 
GeneralRe: convert CString to a _bstr_t - how to? Pin
ns19-Sep-02 1:53
ns19-Sep-02 1:53 
GeneralRe: convert CString to a _bstr_t - how to? Pin
dabs19-Sep-02 1:58
dabs19-Sep-02 1:58 
This will work but your program will leak memory. ::SysAllocString allocates a BSTR and you are assigning it to a _bstr_t. _bstr_t does not take ownership of the BSTR however so you would have to release it using ::SysFreeString( ).

Yet another way would be to use the USES_CONVERSION macros defined in atlconv.h - your code would then look like:

USES_CONVERSION;

_bstr_t b_databaseName = T2W( dataBaseName );



Hope this helps,
- d a b s -



Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
GeneralRe: convert CString to a _bstr_t - how to? Pin
ns19-Sep-02 2:13
ns19-Sep-02 2:13 
GeneralRe: convert CString to a _bstr_t - how to? Pin
dabs19-Sep-02 2:17
dabs19-Sep-02 2:17 
Generalaaargh!! Pin
ns19-Sep-02 2:32
ns19-Sep-02 2:32 
GeneralI think I might have got it.... Pin
ns19-Sep-02 3:04
ns19-Sep-02 3:04 
GeneralRe: convert CString to a _bstr_t - how to? Pin
ns19-Sep-02 7:32
ns19-Sep-02 7:32 
Generalhandle Pin
Anonymous19-Sep-02 0:33
Anonymous19-Sep-02 0:33 
GeneralRe: handle Pin
super19-Sep-02 1:08
professionalsuper19-Sep-02 1:08 
GeneralRe: handle Pin
dabs19-Sep-02 1:33
dabs19-Sep-02 1:33 
Generalcopy to clipboard Pin
Safder18-Sep-02 23:30
Safder18-Sep-02 23:30 
GeneralPlatform question Pin
Anonymous18-Sep-02 23:24
Anonymous18-Sep-02 23:24 
GeneralRe: Platform question Pin
Lakitu18-Sep-02 23:36
Lakitu18-Sep-02 23:36 
GeneralRe: Platform question Pin
Anonymous18-Sep-02 23:49
Anonymous18-Sep-02 23:49 
GeneralRe: Platform question Pin
Stephane Rodriguez.18-Sep-02 23:59
Stephane Rodriguez.18-Sep-02 23:59 
GeneralRe: Platform question Pin
Anonymous19-Sep-02 0:04
Anonymous19-Sep-02 0:04 
GeneralRe: Platform question Pin
Stephane Rodriguez.19-Sep-02 0:22
Stephane Rodriguez.19-Sep-02 0:22 
GeneralRe: Platform question Pin
Steve S19-Sep-02 6:31
Steve S19-Sep-02 6:31 
GeneralRe: Platform question Pin
Atlantys19-Sep-02 10:31
Atlantys19-Sep-02 10:31 

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.