Click here to Skip to main content
16,006,845 members
Home / Discussions / C#
   

C#

 
QuestionOutlook sync component? Pin
cmkWildsky28-Sep-04 11:53
cmkWildsky28-Sep-04 11:53 
AnswerRe: Outlook sync component? Pin
Heath Stewart28-Sep-04 13:12
protectorHeath Stewart28-Sep-04 13:12 
GeneralC# COM object to TLB generation problem Pin
Werdna28-Sep-04 10:35
Werdna28-Sep-04 10:35 
GeneralRe: C# COM object to TLB generation problem Pin
Heath Stewart28-Sep-04 15:41
protectorHeath Stewart28-Sep-04 15:41 
GeneralRe: C# COM object to TLB generation problem Pin
Werdna28-Sep-04 16:00
Werdna28-Sep-04 16:00 
GeneralRe: C# COM object to TLB generation problem Pin
Heath Stewart28-Sep-04 18:34
protectorHeath Stewart28-Sep-04 18:34 
GeneralRe: C# COM object to TLB generation problem Pin
Werdna29-Sep-04 4:33
Werdna29-Sep-04 4:33 
GeneralRe: C# COM object to TLB generation problem Pin
Heath Stewart29-Sep-04 5:51
protectorHeath Stewart29-Sep-04 5:51 
It's an [out, retval]. Most often, you don't allocate these as the caller. Merely declare a variable and pass the address of the variable. Also, if you read the documentation for the CComBSTR class, you'll see the following remarks:

Memory Leak Issues


Passing the address of an initialized CComBSTR to a function as an [out] parameter causes a memory leak.

In the example below, the string allocated to hold the string "Initialized" is leaked when the function OutString replaces the string.

CComBSTR bstrLeak(L"Initialized");
HRESULT hr = OutString(&bstrLeak);

To avoid the leak, call the Empty method on existing CComBSTR objects before passing the address as an [out] parameter.

Note that the same code would not cause a leak if the function's parameter was [in, out].
So, as you see - don't initialize it. You also don't need to mess with m_str. Since the CComBSTR contains only one member - m_str - passing the address of the CComBSTR instance is passing the address of the m_str (because of the way the class/struct is aligned).

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles]
GeneralRe: C# COM object to TLB generation problem Pin
Werdna29-Sep-04 6:17
Werdna29-Sep-04 6:17 
GeneralToolBar That Doesn't Move Pin
MarkMokris28-Sep-04 10:04
MarkMokris28-Sep-04 10:04 
GeneralRe: ToolBar That Doesn't Move Pin
Brian Nottingham28-Sep-04 10:28
Brian Nottingham28-Sep-04 10:28 
GeneralRe: ToolBar That Doesn't Move Pin
MarkMokris28-Sep-04 10:44
MarkMokris28-Sep-04 10:44 
General"Independent Display" Pin
monkeymonkey00728-Sep-04 7:11
monkeymonkey00728-Sep-04 7:11 
GeneralRe: "Independent Display" Pin
Christian Graus28-Sep-04 11:50
protectorChristian Graus28-Sep-04 11:50 
GeneralA C# / SQL Query Problem Pin
cemlouis28-Sep-04 6:51
cemlouis28-Sep-04 6:51 
GeneralRe: A C# / SQL Query Problem Pin
Christian Graus28-Sep-04 11:51
protectorChristian Graus28-Sep-04 11:51 
GeneralRe: A C# / SQL Query Problem Pin
Colin Angus Mackay28-Sep-04 12:19
Colin Angus Mackay28-Sep-04 12:19 
GeneralRe: A C# / SQL Query Problem Pin
cemlouis28-Sep-04 14:01
cemlouis28-Sep-04 14:01 
GeneralKeep a Form on Top Pin
MarkMokris28-Sep-04 6:22
MarkMokris28-Sep-04 6:22 
GeneralRe: Keep a Form on Top Pin
Nnamdi Onyeyiri28-Sep-04 6:33
Nnamdi Onyeyiri28-Sep-04 6:33 
GeneralRe: Keep a Form on Top Pin
Anonymous28-Sep-04 6:40
Anonymous28-Sep-04 6:40 
Generaluploading to images to remote server Pin
butchzn28-Sep-04 4:12
butchzn28-Sep-04 4:12 
GeneralRe: uploading to images to remote server Pin
Heath Stewart28-Sep-04 5:14
protectorHeath Stewart28-Sep-04 5:14 
GeneralInverse colour in GDI+ Pin
benjymous28-Sep-04 3:48
benjymous28-Sep-04 3:48 
GeneralRe: Inverse colour in GDI+ Pin
Heath Stewart28-Sep-04 7:02
protectorHeath Stewart28-Sep-04 7:02 

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.