读书人

win7 vs2010调用cocreateinstance 创造

发布时间: 2013-06-19 10:26:41 作者: rapoo

win7 vs2010调用cocreateinstance 创建不了faxserver对象,结果总是为null
[DllImport("ole32.dll", EntryPoint = "CoCreateInstance", CallingConvention = CallingConvention.StdCall)]
static extern UInt32 CoCreateInstance([In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid,
IntPtr pUnkOuter, UInt32 dwClsContext, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid,
[MarshalAs(UnmanagedType.IUnknown)] out object rReturnedComObject);
[DllImport("ole32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int CoInitialize(IntPtr pvReserved);


CoInitialize(IntPtr.Zero);
Guid vGuidIme = new Guid("2BF34C1A-8CAC-419F-8547-32FDF6505DB8");

UInt32 vError;
uint CLSCTX_SERVER = 0x4;
Guid vGuidLanguage = new Guid("CDA8ACB0-8CF5-4F6C-9BA2-5931D40C8CAE");
object vPPV;
vError = CoCreateInstance(vGuidLanguage, IntPtr.Zero, (uint)0x4, vGuidLanguage, out vPPV);

vPPV总是为NULL,操作系统安装了传真服务组件,项目里引用了fxcomex.dll组件,
现在需要通过CoCreateInstance方法创建FaxServer对象, Windows?7 Visual?Studio?2010 faxserver fxcomex.dll vs2010
[解决办法]
组件没有注册,你这种方式是最原始的C++调用com组件的方式,.net下没必要这么做,这么做是给自己找麻烦

读书人网 >.NET

热点推荐