当前位置: 代码迷 >> .NET组件控件 >> win7 vs2010调用cocreateinstance 创造不了faxserver对象,结果总是为null
  详细解决方案

win7 vs2010调用cocreateinstance 创造不了faxserver对象,结果总是为null

热度:534   发布时间:2016-05-04 23:31:44.0
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下没必要这么做,这么做是给自己找麻烦
  相关解决方案