Click here to Skip to main content
15,885,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Append BStr Pin
Mogaambo12-May-09 22:26
Mogaambo12-May-09 22:26 
GeneralRe: Append BStr Pin
CPallini12-May-09 22:33
mveCPallini12-May-09 22:33 
GeneralRe: Append BStr Pin
Mogaambo12-May-09 22:36
Mogaambo12-May-09 22:36 
GeneralRe: Append BStr Pin
CPallini12-May-09 23:14
mveCPallini12-May-09 23:14 
GeneralRe: Append BStr Pin
Mogaambo12-May-09 23:54
Mogaambo12-May-09 23:54 
GeneralRe: Append BStr Pin
CPallini13-May-09 0:06
mveCPallini13-May-09 0:06 
GeneralRe: Append BStr Pin
Mogaambo13-May-09 0:19
Mogaambo13-May-09 0:19 
GeneralRe: Append BStr [modified] Pin
CPallini13-May-09 0:39
mveCPallini13-May-09 0:39 
Mogaambo wrote:
1. BSTR * pdst

why pointer here.

BSTR is itself a pointer.



Because the function will internally change the value of the original pointer, i.e. pdst is a INOUT parameter (this way you state clearly that the function may alter the original dst string).



Mogaambo wrote:

2. What code you have write for StringAppend function ?


Something like
HRESULT StringAppend(BSTR * pdest, const BSTR src)
{
 if (pdest == NULL) return E_FAIL;
 long destLen=::SysStringLen(*pdest);
 long srcLen=::SysStringLen(src);

 BSTR tmp = ::SysAllocStringLen(NULL,destLen+srcLen);
 if( tmp == NULL) return E_FAIL;
 wcscpy(tmp, *pdest);
 wcscat(tmp, src);
 ::SysFreeString(*pdest);
 
 pdest = &tmp;
 *pdest = tmp;
 return S_OK;
} 


Beware: I didn't check this code (moreover I've used just the very basic E_FAIL failure
return value, a good function should be more informative on failure.

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

modified on Wednesday, May 13, 2009 8:02 AM

GeneralRe: Append BStr Pin
Mogaambo13-May-09 0:53
Mogaambo13-May-09 0:53 
GeneralRe: Append BStr Pin
CPallini13-May-09 1:33
mveCPallini13-May-09 1:33 
GeneralRe: Append BStr Pin
CPallini13-May-09 2:08
mveCPallini13-May-09 2:08 
GeneralRe: Append BStr Pin
Mogaambo13-May-09 2:37
Mogaambo13-May-09 2:37 
QuestionRe: Append BStr Pin
CPallini13-May-09 2:43
mveCPallini13-May-09 2:43 
AnswerRe: Append BStr Pin
«_Superman_»12-May-09 21:52
professional«_Superman_»12-May-09 21:52 
AnswerRe: Append BStr Pin
KarstenK12-May-09 22:25
mveKarstenK12-May-09 22:25 
GeneralRe: Append BStr Pin
Mogaambo12-May-09 22:28
Mogaambo12-May-09 22:28 
GeneralRe: Append BStr Pin
Rajesh R Subramanian12-May-09 22:37
professionalRajesh R Subramanian12-May-09 22:37 
GeneralRe: Append BStr Pin
KarstenK12-May-09 22:41
mveKarstenK12-May-09 22:41 
GeneralRe: Append BStr Pin
Mogaambo12-May-09 22:51
Mogaambo12-May-09 22:51 
AnswerRe: Append BStr [modified] Pin
Madhu Nair12-May-09 22:55
Madhu Nair12-May-09 22:55 
GeneralRe: Append BStr Pin
Mogaambo12-May-09 23:51
Mogaambo12-May-09 23:51 
GeneralRe: Append BStr Pin
KarstenK12-May-09 23:47
mveKarstenK12-May-09 23:47 
GeneralRe: Append BStr Pin
Mogaambo13-May-09 1:20
Mogaambo13-May-09 1:20 
GeneralRe: Append BStr Pin
KarstenK13-May-09 1:59
mveKarstenK13-May-09 1:59 
Questionhi plz help me Pin
priyakp12-May-09 21:01
priyakp12-May-09 21:01 

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.