Groups | Blog | Home
all groups > c# > january 2004 >

c# : How to pass ByRef parameter to COM dll interface ?


Nicholas Paldino [.NET/C# MVP]
1/8/2004 9:56:16 AM
pecker,

Because they are declared as variants, you have to store your values as
type object first, and then pass them by ref. You will have to do this:

// The values. <value> are the values you want to pass.
object vDate = <value>, vCount = <value>, vMoney = <value>, vMyDetail =
<value>;

// Call the method.
myObject.Hulian_Acount_all(vIndex, ref vDate, ref vCount, ref vMoney, ref
vMyDetail, vTimeStamp, vSPID, vType, vResult, vSenderID, vYourcount,
vYourMoney, vDetail_result, vSucess_count, vSucess_money, vFail_count,
vFail_money, vYour_records);

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

[quoted text, click to view]

pecker
1/8/2004 10:51:29 PM
I have a com dll interface:
Public Function Hulian_Acount_all(ByVal vIndex As Variant, _
ByRef vDate As Variant, _
ByRef vCount As Variant, _
ByRef vMoney As Variant, _
ByRef vMyDetail As Variant, _
ByVal vTimeStamp As Variant, _
ByVal vSPID As Variant, _
ByVal vType As Variant, _
ByVal vResult As Variant, _
ByVal vSenderID As Variant, _
ByVal vYourCount As Variant, _
ByVal vYourMoney As Variant, _
ByVal vDetail_result As Variant, _
ByVal vSucess_count As Variant, _
ByVal vSucess_money As Variant, _
ByVal vFail_count As Variant, _
ByVal vFail_money As Variant, _
ByVal vYour_records As Variant)
I use it in C# like this:
obj.Hulian_Acount_all
(3,"","","","",TimeStamp,"","",Result,SenderID,TotalCount,TotalFee,"","","",
"","","") ;

But the compiler shows out the error: "cannot convert the string to ref
object"

How can I pass the 2 ~ 5 ByRef parameters to the dll in C# ? Thanks a lot!

pecker
1/8/2004 11:25:07 PM
Thank you very much! I've resolved the problem with your help!

"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> дÈëÏûÏ¢
ÐÂÎÅ:#QkZiff1DHA.3224@tk2msftngp13.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button