public CaptureManager() { try { do { #if DEBUG mILogPrintOutControl = new CaptureManagerLibrary.CoLogPrintOut() as CaptureManagerLibrary.ILogPrintOutControl; if (mILogPrintOutControl == null) { break; } mILogPrintOutControl.addPrintOutDestination( //(int)CaptureManagerLibrary.LogLevel.INFO_LEVEL, (int)CaptureManagerLibrary.LogLevel.ERROR_LEVEL, getFullFilePath("Log.txt")); mILogPrintOutControl.addPrintOutDestination( (int)CaptureManagerLibrary.LogLevel.INFO_LEVEL, getFullFilePath("Log.txt")); #endif mICaptureManagerControl = new CaptureManagerLibrary.CoCaptureManager(); if (mICaptureManagerControl == null) { break; } } while (false); } catch (Exception exc) { LogManager.getInstance().write(exc.Message); throw exc; } }
public CaptureManager(string aFileName) { try { string lFullFilePath = aFileName; if (!File.Exists(lFullFilePath)) { lFullFilePath = getFullFilePath(aFileName); if (!File.Exists(lFullFilePath)) { throw new Exception("File " + aFileName + " is not accessseble!!!"); } } do { var lDLLModuleAddr = Win32NativeMethods.LoadLibrary(lFullFilePath); if (lDLLModuleAddr == null) { break; } var lEnterProcAddr = Win32NativeMethods.GetProcAddress(lDLLModuleAddr, "DllGetClassObject"); if (lEnterProcAddr == null) { break; } var lGetClassObject = Marshal.GetDelegateForFunctionPointer(lEnterProcAddr, typeof(Win32NativeMethods.DllGetClassObjectDelegate)) as Win32NativeMethods.DllGetClassObjectDelegate; if (lGetClassObject == null) { break; } var CLSID_CoLogPrintOut = new Guid("4563EE3E-DA1E-4911-9F40-88A284E2DD69"); var CLSID_CoCaptureManager = new Guid("D5F07FB8-CE60-4017-B215-95C8A0DDF42A"); object lUnknown; IClassFactory lFactory; lGetClassObject( CLSID_CoLogPrintOut, typeof(IClassFactory).GUID, out lUnknown); lFactory = lUnknown as IClassFactory; if (lFactory == null) { break; } lFactory.CreateInstance( null, typeof(CaptureManagerLibrary.ILogPrintOutControl).GUID, out lUnknown); lFactory.LockServer(true); #if DEBUG mILogPrintOutControl = lUnknown as CaptureManagerLibrary.ILogPrintOutControl; if (mILogPrintOutControl == null) { break; } mILogPrintOutControl.addPrintOutDestination( (int)CaptureManagerLibrary.LogLevel.INFO_LEVEL, //(int)CaptureManagerLibrary.LogLevel.ERROR_LEVEL, getFullFilePath("Log.txt")); mILogPrintOutControl.addPrintOutDestination( (int)CaptureManagerLibrary.LogLevel.ERROR_LEVEL, getFullFilePath("Log.txt")); #endif lGetClassObject( CLSID_CoCaptureManager, typeof(IClassFactory).GUID, out lUnknown); lFactory = lUnknown as IClassFactory; if (lFactory == null) { break; } lFactory.CreateInstance( null, typeof(CaptureManagerLibrary.ICaptureManagerControl).GUID, out lUnknown); lFactory.LockServer(true); mICaptureManagerControl = lUnknown as CaptureManagerLibrary.ICaptureManagerControl; if (mICaptureManagerControl == null) { break; } } while (false); } catch (Exception exc) { LogManager.getInstance().write(exc.Message); throw exc; } }