Click here to Skip to main content
15,888,461 members
Home / Discussions / COM
   

COM

 
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 
GeneralRe: pass character string to COM Pin
MKUser2-Jul-08 22:58
MKUser2-Jul-08 22:58 
GeneralRe: pass character string to COM Pin
Vi22-Jul-08 22:08
Vi22-Jul-08 22:08 
GeneralRe: pass character string to COM Pin
MKUser2-Jul-08 23:02
MKUser2-Jul-08 23:02 
GeneralRe: pass character string to COM Pin
Vi22-Jul-08 17:38
Vi22-Jul-08 17:38 
GeneralRe: pass character string to COM Pin
CPallini1-Jul-08 22:08
mveCPallini1-Jul-08 22:08 
GeneralRe: pass character string to COM Pin
CPallini1-Jul-08 3:25
mveCPallini1-Jul-08 3:25 
QuestionHow to add another activex control to web page dynamically. Pin
vies0028-Jun-08 22:28
vies0028-Jun-08 22:28 
AnswerRe: How to add another activex control to web page dynamically. Pin
pascal9181-Mar-10 16:48
pascal9181-Mar-10 16:48 
QuestionDefine a enum type variable on the Interface (ATL project) ? Pin
iman_kh27-Jun-08 10:31
iman_kh27-Jun-08 10:31 
AnswerRe: Define a enum type variable on the Interface (ATL project) ? Pin
Stephen Hewitt1-Jul-08 15:03
Stephen Hewitt1-Jul-08 15:03 
AnswerRe: Define a enum type variable on the Interface (ATL project) ? Pin
Vi21-Jul-08 17:33
Vi21-Jul-08 17:33 
QuestionPassing an array from an ActiveX class Pin
Hampus@foi26-Jun-08 2:55
Hampus@foi26-Jun-08 2:55 
AnswerRe: Passing an array from an ActiveX class Pin
KarstenK26-Jun-08 3:22
mveKarstenK26-Jun-08 3:22 
GeneralRe: Passing an array from an ActiveX class Pin
Hampus@foi26-Jun-08 3:39
Hampus@foi26-Jun-08 3:39 
AnswerRe: Passing an array from an ActiveX class Pin
Lim Bio Liong26-Jun-08 7:21
Lim Bio Liong26-Jun-08 7:21 
GeneralRe: Passing an array from an ActiveX class Pin
Hampus@foi26-Jun-08 20:40
Hampus@foi26-Jun-08 20:40 

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.