【发布时间】:2012-03-11 02:07:20
【问题描述】:
我有一个 UInt32 值,我想使用 InterOpServices 传递给外部 dll。
非托管代码的原型是:
[DllImport("svr.dll")]
public static extern UInt32 CreateTag (
[MarshalAs(UnmanagedType.LPStr)] String Name,
Object Value,
UInt16 InitialQuality,
bool IsWritable);
调用代码是:
int myValue = Convert.ToInt32(item); //How to marshal as I8 type
tagNumber = (UInt32)svr_DLL.CreateTag(
DeviceName + "." + el.tagName,
myValue, // <-- this argument
192,
Convert.ToBoolean(el.tagEditable));
我想将对象值“myValue”作为 I8 类型传递给对象。
如何做到这一点?
【问题讨论】:
标签: c# pinvoke marshalling interopservices