about parameter of BSTR
-
I am a beginer of learning programming by ATL ,I have writen a interface as below: HRESULT GetBSTR1([out,retval]BSTR* bstrInfo) { CComBSTR b(L"hello,you have called GetBSTR1"); *bstrInfo=b.Copy(); return S_OK; } HRESULT GetBSTR2([out]BSTR* bstrInfo) { CComBSTR b(L"hello,you have called GetBSTR2"); *bstrInfo=b.Copy(); return S_OK; } and VB Client Codes as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str1 = a.GetBSTR1 MsgBox (str1) a.GetBSTR2(str2) MsgBox (str2) End Sub problem is str1 is OK,but str2 is empty,why?
-
I am a beginer of learning programming by ATL ,I have writen a interface as below: HRESULT GetBSTR1([out,retval]BSTR* bstrInfo) { CComBSTR b(L"hello,you have called GetBSTR1"); *bstrInfo=b.Copy(); return S_OK; } HRESULT GetBSTR2([out]BSTR* bstrInfo) { CComBSTR b(L"hello,you have called GetBSTR2"); *bstrInfo=b.Copy(); return S_OK; } and VB Client Codes as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str1 = a.GetBSTR1 MsgBox (str1) a.GetBSTR2(str2) MsgBox (str2) End Sub problem is str1 is OK,but str2 is empty,why?
-
thanks a lot. a.GetBSTR2(str2) is error but a.GetBSTR2 str2 Is OK,why? could you tell me the reason?
I also have a problem about BSTR Parameter,codes as below: HRESULT GetBSTR3([out]BSTR* bufName1,[out,retval]BSTR* bufName2) { USES_CONVERSION; CComBSTR b(L"hello,you have called GetBSTR3"); *bufName1=b.Copy(); TCHAR buf[]=TEXT("it is return value"); *bufName2=T2BSTR(buf); } VB Client as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str2 = a.GetBSTR3(str1) MsgBox (str1) MsgBox (str2) End Sub running these codes, runtime error if I write codes as below: str2 = a.GetBSTR3 str1 compile error how can I do it?
-
I also have a problem about BSTR Parameter,codes as below: HRESULT GetBSTR3([out]BSTR* bufName1,[out,retval]BSTR* bufName2) { USES_CONVERSION; CComBSTR b(L"hello,you have called GetBSTR3"); *bufName1=b.Copy(); TCHAR buf[]=TEXT("it is return value"); *bufName2=T2BSTR(buf); } VB Client as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str2 = a.GetBSTR3(str1) MsgBox (str1) MsgBox (str2) End Sub running these codes, runtime error if I write codes as below: str2 = a.GetBSTR3 str1 compile error how can I do it?
Listen Borther Instead of using this yingkou wrote: str2 = a.GetBSTR3 str1 use this
str2 = a.GetBSTR3(str1)
"I Think this Will Help" Alok Gupta
visit me at http://www.thisisalok.tk -
Listen Borther Instead of using this yingkou wrote: str2 = a.GetBSTR3 str1 use this
str2 = a.GetBSTR3(str1)
"I Think this Will Help" Alok Gupta
visit me at http://www.thisisalok.tk -
I also have a problem about BSTR Parameter,codes as below: HRESULT GetBSTR3([out]BSTR* bufName1,[out,retval]BSTR* bufName2) { USES_CONVERSION; CComBSTR b(L"hello,you have called GetBSTR3"); *bufName1=b.Copy(); TCHAR buf[]=TEXT("it is return value"); *bufName2=T2BSTR(buf); } VB Client as below: Private Sub Command1_Click() Dim a As New ATLTESTLib.TestOne Dim str1, str2 As String str2 = a.GetBSTR3(str1) MsgBox (str1) MsgBox (str2) End Sub running these codes, runtime error if I write codes as below: str2 = a.GetBSTR3 str1 compile error how can I do it?
Q: a.GetBSTR2(str2) is error but a.GetBSTR2 str2 Is OK,why? could you tell me the reason? A: This is a VB syntax requirement. Look at "Call Statement" in MSDN. Q: runtime error Dim str1, str2 As String str2 = a.GetBSTR3(str1) A: Variable "str1" is a Variant type here, because VB treats the Dim statement as: Dim str1 As Variant, str2 As String You should specify the type for each variable. With best wishes, Vita
-
Q: a.GetBSTR2(str2) is error but a.GetBSTR2 str2 Is OK,why? could you tell me the reason? A: This is a VB syntax requirement. Look at "Call Statement" in MSDN. Q: runtime error Dim str1, str2 As String str2 = a.GetBSTR3(str1) A: Variable "str1" is a Variant type here, because VB treats the Dim statement as: Dim str1 As Variant, str2 As String You should specify the type for each variable. With best wishes, Vita