Click here to Skip to main content
15,911,503 members
Home / Discussions / COM
   

COM

 
QuestionActiveX control and HTML Pin
FJK12-Nov-05 18:39
FJK12-Nov-05 18:39 
QuestionNew to COM. Help needed. Pin
Owner drawn10-Nov-05 23:49
Owner drawn10-Nov-05 23:49 
AnswerRe: New to COM. Help needed. Pin
Gizzo11-Nov-05 6:33
Gizzo11-Nov-05 6:33 
AnswerRe: New to COM. Help needed. Pin
Brian C Hart30-Dec-05 23:25
professionalBrian C Hart30-Dec-05 23:25 
Questioncreating a BSTR with embedded Nulls Pin
amitsax7610-Nov-05 22:31
amitsax7610-Nov-05 22:31 
AnswerRe: creating a BSTR with embedded Nulls Pin
Welf Wiest31-Jan-06 5:06
Welf Wiest31-Jan-06 5:06 
GeneralRe: creating a BSTR with embedded Nulls Pin
amitsax7631-Jan-06 16:09
amitsax7631-Jan-06 16:09 
GeneralRe: creating a BSTR with embedded Nulls Pin
Welf Wiest1-Feb-06 0:54
Welf Wiest1-Feb-06 0:54 
Hi Amit,
yes this sounds efficient.

For example I use this code sequence to convert an ANSI STL String to a BSTR in my STL to automation layer


_my_type& operator=(const std::string &Src)
{
DWORD dwLen = Src.length();
CComBSTR bstr(dwLen);
if(dwLen > 0)
if(!MultiByteToWideChar(CP_ACP, 0, Src.c_str(), dwLen, bstr, dwLen))
ThrowFromHRESULT(HRESULT_FROM_WIN32(GetLastError()));

m_vntValue = bstr;
_assign();
return *this;
}



//Simplified Version without STL / ATL
HRESULT toBSTR(const char *szString, BSTR *bstrResult)
{
HRESULT hr = S_OK;
BSTR bstr = 0;
if(bstrResult == 0)
return E_INVALIDARG;

DWORD dwLen = lstrlenA(szString);
bstr = SysAllocStringLen(0, dwLen);
if(bstr == 0)
hr = E_OUTOFMEMORY;
else if(dwLen > 0)
{
if(!MultiByteToWideChar(CP_ACP, 0, szString, dwLen, bstr, dwLen))
hr = HRESULT_FROM_WIN32(GetLastError());
}


if(SUCCEEDED(hr))
*bstrResult = bstr;
else if(bstr != 0)
SysFreeString(bstr);


return hr;
}





This Codes allocates the memory first and then initializes the string by MultiBytToWideChar


Welf
Questionhandling Variant data Pin
amitsax769-Nov-05 18:03
amitsax769-Nov-05 18:03 
QuestionTrouble to run DCOM - server from different network Pin
Bor_boss9-Nov-05 16:46
Bor_boss9-Nov-05 16:46 
QuestionHelp Needed in Extended MAPI. Pin
deepgeorge8-Nov-05 17:35
deepgeorge8-Nov-05 17:35 
QuestionCalling a C# COM Object from VC++ 6.0 Pin
E6AD8-Nov-05 17:33
E6AD8-Nov-05 17:33 
AnswerRe: Calling a C# COM Object from VC++ 6.0 Pin
douglasjordan10-Nov-05 2:06
douglasjordan10-Nov-05 2:06 
Questionhelp help help Pin
engriri20068-Nov-05 14:13
engriri20068-Nov-05 14:13 
AnswerRe: help help help Pin
douglasjordan8-Nov-05 17:29
douglasjordan8-Nov-05 17:29 
AnswerRe: help help help Pin
Brian C Hart30-Dec-05 23:26
professionalBrian C Hart30-Dec-05 23:26 
QuestionCan't bring to top a specific "Microsoft Word" window Pin
nadzzz8-Nov-05 4:50
nadzzz8-Nov-05 4:50 
AnswerRe: Additionnal Informations Pin
nadzzz8-Nov-05 5:06
nadzzz8-Nov-05 5:06 
Questionadd page in property sheet for property tab Pin
Maddie from Dartford7-Nov-05 17:18
Maddie from Dartford7-Nov-05 17:18 
QuestionDirectShow release of GraphBuilder Pin
douglasjordan7-Nov-05 12:17
douglasjordan7-Nov-05 12:17 
Question.NET to COM+ and vice versa Pin
Chals7-Nov-05 6:00
Chals7-Nov-05 6:00 
QuestionVS 2005 COM DLL issue Pin
pass_x0r7-Nov-05 2:12
pass_x0r7-Nov-05 2:12 
QuestionCOleDispatchDriver.InvokeHelper PROBLEM Pin
Ro_land7-Nov-05 0:16
Ro_land7-Nov-05 0:16 
AnswerRe: COleDispatchDriver.InvokeHelper PROBLEM Pin
Lim Bio Liong9-Nov-05 23:37
Lim Bio Liong9-Nov-05 23:37 
GeneralRe: COleDispatchDriver.InvokeHelper PROBLEM Pin
Ro_land13-Nov-05 9:51
Ro_land13-Nov-05 9:51 

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.