Click here to Skip to main content
15,918,808 members
Home / Discussions / C#
   

C#

 
GeneralRe: StackFrame Pin
leppie23-May-04 2:22
leppie23-May-04 2:22 
GeneralRe: StackFrame Pin
TuringTest123-May-04 10:47
TuringTest123-May-04 10:47 
GeneralRe: StackFrame Pin
Heath Stewart23-May-04 3:53
protectorHeath Stewart23-May-04 3:53 
GeneralFile size Pin
PaleyX22-May-04 8:31
PaleyX22-May-04 8:31 
GeneralRe: File size Pin
MyBlindy22-May-04 8:53
MyBlindy22-May-04 8:53 
GeneralRe: File size Pin
PaleyX22-May-04 13:31
PaleyX22-May-04 13:31 
GeneralRe: File size Pin
Member 93002222-May-04 8:59
Member 93002222-May-04 8:59 
GeneralRCW question when returning a string Pin
Nish Nishant22-May-04 3:33
sitebuilderNish Nishant22-May-04 3:33 
Hi guys

Here is my problem without further ado :-

Let's say I have a COM method as follows -

HRESULT GetHerName([in] LONG id, 
  [out,retval] BSTR* namestr);

And I've implemented it as -

STDMETHODIMP MyClassHere::GetHerName(LONG id, BSTR* namestr)
{
  wchar_t str[100];
  //...
  *namestr = SysAllocString(str);
  return S_OK;
}

Now C# sees this method as -

string GetHerName(int)

and I can use it from C# as :-

string s1 = obj.GetHerName(22);
string s2 = obj.GetHerName(14);
//...

Now my problem is as follows - I have allocated a new BSTR using SysAllocString in my COM method, but this BSTR gets copied into a new String object by the RCW layer. All that's nice for me - but the original BSTR now leaks.

When I originally designed my COM method, my idea would probably have been that the client should free the BSTR using SysFreeString after using it.

But now I do not have such an option.

Anyone knows if RCW handles this for me in some way? Or will memory keep leaking every time GetHerName is called?


Now with my own blog - void Nish(char* szBlog);

My MVP tips, tricks and essays web site - www.voidnish.com
GeneralRe: RCW question when returning a string Pin
Heath Stewart22-May-04 3:49
protectorHeath Stewart22-May-04 3:49 
GeneralRe: RCW question when returning a string Pin
Nish Nishant22-May-04 3:58
sitebuilderNish Nishant22-May-04 3:58 
GeneralRe: RCW question when returning a string Pin
Heath Stewart22-May-04 4:07
protectorHeath Stewart22-May-04 4:07 
GeneralRe: RCW question when returning a string Pin
Nish Nishant22-May-04 4:17
sitebuilderNish Nishant22-May-04 4:17 
GeneralRe: RCW question when returning a string Pin
Heath Stewart22-May-04 4:18
protectorHeath Stewart22-May-04 4:18 
Generallistbox control in C# Pin
HowRU21-May-04 22:22
HowRU21-May-04 22:22 
GeneralRe: listbox control in C# Pin
Heath Stewart22-May-04 4:52
protectorHeath Stewart22-May-04 4:52 
GeneralPassing a Class to an Unmanaged function as parameter Pin
shajuMathew21-May-04 20:49
shajuMathew21-May-04 20:49 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
Heath Stewart22-May-04 4:17
protectorHeath Stewart22-May-04 4:17 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
shajuMathew26-May-04 1:32
shajuMathew26-May-04 1:32 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
Heath Stewart26-May-04 3:23
protectorHeath Stewart26-May-04 3:23 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
Member 93002222-May-04 9:18
Member 93002222-May-04 9:18 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
shajuMathew26-May-04 1:35
shajuMathew26-May-04 1:35 
QuestionHow to use a DirectShow filter in C# ? Pin
ro_angel_bv21-May-04 20:11
ro_angel_bv21-May-04 20:11 
AnswerRe: How to use a DirectShow filter in C# ? Pin
Heath Stewart22-May-04 4:00
protectorHeath Stewart22-May-04 4:00 
GeneralRe: How to use a DirectShow filter in C# ? Pin
ro_angel_bv22-May-04 9:21
ro_angel_bv22-May-04 9:21 
GeneralRe: How to use a DirectShow filter in C# ? Pin
Heath Stewart23-May-04 3:31
protectorHeath Stewart23-May-04 3:31 

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.