Click here to Skip to main content
15,910,603 members
Home / Discussions / COM
   

COM

 
AnswerRe: CoCreateInstance Pin
alchong8-Oct-08 12:45
alchong8-Oct-08 12:45 
QuestionWould COM still be recognized? Pin
Vitaly Tomilov3-Jul-08 13:00
Vitaly Tomilov3-Jul-08 13:00 
AnswerRe: Would COM still be recognized? Pin
Vitaly Tomilov3-Jul-08 23:16
Vitaly Tomilov3-Jul-08 23:16 
AnswerRe: Would COM still be recognized? Pin
dementia12314-Jul-08 4:32
dementia12314-Jul-08 4:32 
GeneralRe: Would COM still be recognized? Pin
Vitaly Tomilov15-Jul-08 22:45
Vitaly Tomilov15-Jul-08 22:45 
QuestionConvert Visual Studio 2005 ATL project into VC 6.0 Pin
dolly3-Jul-08 1:51
dolly3-Jul-08 1:51 
QuestionVC# for MTA COM component development Pin
scody2-Jul-08 23:36
scody2-Jul-08 23:36 
AnswerRe: VC# for MTA COM component development Pin
Ju@ncho4-Jul-08 3:19
Ju@ncho4-Jul-08 3:19 
Questionpass character string to COM Pin
MKUser29-Jun-08 21:34
MKUser29-Jun-08 21:34 
AnswerRe: pass character string to COM Pin
Vi229-Jun-08 21:54
Vi229-Jun-08 21:54 
GeneralRe: pass character string to COM Pin
MKUser29-Jun-08 22:50
MKUser29-Jun-08 22:50 
GeneralRe: pass character string to COM Pin
Vi229-Jun-08 23:14
Vi229-Jun-08 23:14 
GeneralRe: pass character string to COM Pin
MKUser29-Jun-08 23:45
MKUser29-Jun-08 23:45 
GeneralRe: pass character string to COM Pin
Vi230-Jun-08 21:04
Vi230-Jun-08 21:04 
GeneralRe: pass character string to COM Pin
MKUser1-Jul-08 3:20
MKUser1-Jul-08 3:20 
GeneralRe: pass character string to COM Pin
Vi21-Jul-08 17:40
Vi21-Jul-08 17:40 
GeneralRe: pass character string to COM Pin
MKUser1-Jul-08 18:42
MKUser1-Jul-08 18:42 
GeneralRe: pass character string to COM Pin
MKUser1-Jul-08 21:22
MKUser1-Jul-08 21:22 
GeneralRe: pass character string to COM Pin
CPallini1-Jul-08 22:05
mveCPallini1-Jul-08 22:05 
GeneralRe: pass character string to COM Pin
MKUser1-Jul-08 23:19
MKUser1-Jul-08 23:19 
QuestionRe: pass character string to COM Pin
CPallini1-Jul-08 23:33
mveCPallini1-Jul-08 23:33 
AnswerRe: pass character string to COM Pin
MKUser2-Jul-08 19:53
MKUser2-Jul-08 19:53 
GeneralRe: pass character string to COM Pin
CPallini2-Jul-08 21:18
mveCPallini2-Jul-08 21:18 
GeneralRe: pass character string to COM Pin
MKUser2-Jul-08 21:56
MKUser2-Jul-08 21:56 
I'm doing following

HRESULT functionname(BSTR * OutArray)
{
// suppose there is some ansi array which contains some data
// length is int type which keeps size of this ansi array
wchar_t* wstr = (wchar_t*)calloc(sizeof(WCHAR),length+1);
MultiByteToWideChar(CP_ACP, 0, ansiarray, length, wstr, length) ;
free(ansiarray);
ansiarray= NULL;
*OutArray = SysAllocString( wstr);//(BSTR)wstr;
memset(wstr,65,sizeof(WCHAR) * length+1);
free(wstr);
wstr = NULL;
}

When i use this dll
BSTR st;
st = functionname();
After this statement st contains some garbage data.

While when i debug the code in tli file, it returns valid data

inline _bstr_t IExportComDll::functionname( )
{
BSTR _result = 0;
HRESULT _hr = raw_functionname(&_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _bstr_t(_result, false);
//here _result contains valid data which is returned by COM function
//HRESULT functionname(BSTR * OutArray)

}

Now please tell me where i'm wrong. Please correct my mistake

Manoj Kumar Chauhan

GeneralRe: pass character string to COM Pin
CPallini2-Jul-08 22:08
mveCPallini2-Jul-08 22:08 

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.