我有一个ATL COM服务器,该接口的方法是如何将C#中的SAFEARRAY传递给COM?
CVivsBasic::UpdateSwitchPlan(BSTR plan_name, SAFEARRAY* plan)
而且IDL这个功能看起来像
typedef struct
{
LONG time_to_play;
BSTR ecportid;
} SwitchPlanItem;
HRESULT UpdateSwitchPlan([in] BSTR plan_name, [in] SAFEARRAY(SwitchPlanItem) plan) ;
我想从C#调用它是这样的:
internal void UpdateSwitch(string plan_name, string ecportid)
{
SwitchPlanItem sp1;
sp1.time_to_play = 33;
sp1.ecportid = ecportid;
SwitchPlanItem sp2;
sp2.time_to_play = 33;
sp2.ecportid = ecportid;
SwitchPlanItem[] sps = { sp1, sp2 };
sdk.UpdateSwitchPlan(plan_name, sps);
}
但它崩溃了。从C#到COM传递SAFEARRAY的正确方法是什么?
我有同样的问题。有没有办法做到这一点 ?文章从本地客户的角度提到了一些东西...... – Ghita 2011-08-30 17:19:40