Click here to Skip to main content
16,012,508 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: confirmation please: a char is 8 bits??? Pin
Robert Palma Jr.10-Mar-03 11:36
Robert Palma Jr.10-Mar-03 11:36 
AnswerRe: confirmation please: a char is 8 bits??? Pin
RaajaOfSelf10-Mar-03 17:23
RaajaOfSelf10-Mar-03 17:23 
Questionstd::stack iterator ? Pin
Maximilien10-Mar-03 10:46
Maximilien10-Mar-03 10:46 
AnswerRe: std::stack iterator ? Pin
valikac10-Mar-03 11:02
valikac10-Mar-03 11:02 
AnswerRe: std::stack iterator ? Pin
Taka Muraoka10-Mar-03 16:10
Taka Muraoka10-Mar-03 16:10 
QuestionHow do I modify a BSTR type string? Pin
dazinith10-Mar-03 10:27
dazinith10-Mar-03 10:27 
AnswerRe: How do I modify a BSTR type string? Pin
Brian Shifrin10-Mar-03 12:53
Brian Shifrin10-Mar-03 12:53 
AnswerRe: How do I modify a BSTR type string? Pin
MAAK10-Mar-03 13:39
MAAK10-Mar-03 13:39 
I am not sure, but according to VC++ source codes, BSTR is actualy an LPWSTR which is by turn a pointer to WCHAR or wide charater type that's used in UNICODE. That means you may use wide charater functions to set its value.

For example, to set the BSTR a paramter that you have in your code we may do this:

int len = wcslen(a); //if lstrlen is workin as ANSI it may return unexpected results

//this is the only way to prevent memory exception without knowing the size of a[]
if(len >= wcslen(L"Testing")) //the 'L' is very important
   wcscpy(a, L"Testing");

This code is to change an existing BSTR variable but if you are making new one then SysAllocString() should be used.

if your string is ANSI then you must convert it first to UNICODE. If you are using VC++7 then the easiest way is to use CStringW, for e.g.:

char buff[] = "Test";
CStringW strw(buff);
wcscpy(a, strw);


Otherwise you should use MultiByteToWideChar() to convert.
GeneralList View question Pin
will138310-Mar-03 10:21
will138310-Mar-03 10:21 
GeneralRe: List View question Pin
dazinith10-Mar-03 10:35
dazinith10-Mar-03 10:35 
GeneralRe: List View question Pin
will138310-Mar-03 10:38
will138310-Mar-03 10:38 
GeneralRe: List View question Pin
will138310-Mar-03 10:44
will138310-Mar-03 10:44 
GeneralRe: List View question Pin
User 665810-Mar-03 11:08
User 665810-Mar-03 11:08 
GeneralNeed to catch Close message in Formview Pin
tjkrz10-Mar-03 10:01
tjkrz10-Mar-03 10:01 
GeneralRe: Need to catch Close message in Formview Pin
valikac10-Mar-03 11:04
valikac10-Mar-03 11:04 
GeneralRe: Need to catch Close message in Formview Pin
Nish Nishant10-Mar-03 11:20
sitebuilderNish Nishant10-Mar-03 11:20 
GeneralShellExecute advice.... Pin
JoeSox10-Mar-03 9:35
JoeSox10-Mar-03 9:35 
GeneralWriteFile never returns Pin
Brigg Thorp10-Mar-03 9:15
Brigg Thorp10-Mar-03 9:15 
GeneralRe: WriteFile never returns Pin
valikac10-Mar-03 11:06
valikac10-Mar-03 11:06 
GeneralRe: WriteFile never returns Pin
Brigg Thorp11-Mar-03 1:23
Brigg Thorp11-Mar-03 1:23 
GeneralRe: WriteFile never returns Pin
valikac11-Mar-03 4:40
valikac11-Mar-03 4:40 
GeneralESC Key on a CFormView Pin
netx200310-Mar-03 8:23
netx200310-Mar-03 8:23 
GeneralRe: ESC Key on a CFormView Pin
Mazdak10-Mar-03 8:25
Mazdak10-Mar-03 8:25 
GeneralRe: ESC Key on a CFormView Pin
netx200310-Mar-03 8:50
netx200310-Mar-03 8:50 
GeneralRe: ESC Key on a CFormView Pin
dazinith10-Mar-03 10:04
dazinith10-Mar-03 10:04 

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.