/// <summary> /// Gets the file name (path) for the given module handle in the given process. /// </summary> /// <param name="process">The process for the given module or null for the current process.</param> /// <remarks>External process handles must be opened with PROCESS_QUERY_INFORMATION|PROCESS_VM_READ</remarks> public static unsafe string GetModuleFileName(ModuleInstance module, SafeProcessHandle?process = null) { if (process == null) { return(PlatformInvoke.GrowableBufferInvoke( (ref ValueBuffer <char> buffer) => { fixed(char *b = buffer) { return Imports.GetModuleFileNameW(module, b, buffer.Length); } }, ReturnSizeSemantics.BufferTruncates | ReturnSizeSemantics.LastErrorInsufficientBuffer | ReturnSizeSemantics.SizeIncludesNullWhenTruncated)); } else { return(PlatformInvoke.GrowableBufferInvoke( (ref ValueBuffer <char> buffer) => { fixed(char *b = buffer) { return Imports.K32GetModuleFileNameExW(process, module, b, buffer.Length); } }, ReturnSizeSemantics.BufferTruncates)); } }
/// <summary> /// Get the given enivronment variable. Returns empty string if the variable isn't found. /// </summary> /// <exception cref="ArgumentNullException">Thrown if name is null.</exception> public static unsafe string GetEnvironmentVariable(string name) { if (name == null) { throw new ArgumentNullException(nameof(name)); } return(PlatformInvoke.GrowableBufferInvoke( (ref ValueBuffer <char> buffer) => { fixed(char *n = name) fixed(char *b = buffer) { return Imports.GetEnvironmentVariableW(n, b, buffer.Length); } }, detail: name, shouldThrow: (WindowsError error) => error != WindowsError.ERROR_ENVVAR_NOT_FOUND)); }
/// <summary> /// Disable form close button. /// </summary> /// <param name="frm">System.Windows.Forms.Form</param> public void DisableCloseButton(Form Form) { IntPtr hMenu = PlatformInvoke.GetSystemMenu(Form.Handle, false); if (hMenu != IntPtr.Zero) { int n = PlatformInvoke.GetMenuItemCount(hMenu); if (n > 0) { PlatformInvoke.RemoveMenu(hMenu, (uint)(n - 1), (uint)PlatformInvoke.RemoveMenuFlags.MF_BYPOSITION | (uint)PlatformInvoke.RemoveMenuFlags.MF_REMOVE); PlatformInvoke.RemoveMenu(hMenu, (uint)(n - 2), (uint)PlatformInvoke.RemoveMenuFlags.MF_BYPOSITION | (uint)PlatformInvoke.RemoveMenuFlags.MF_REMOVE); PlatformInvoke.DrawMenuBar(Form.Handle); } } }
/// <summary> /// Returns matrix multiplication of matrices dd1 and dd2 /// [Calculates the product of two matrices represented as ADDs.] /// Description [Calculates the product of two matrices, A and B, /// represented as ADDs. This procedure implements the quasiring multiplication /// algorithm. A is assumed to depend on variables x (rows) and z /// (columns). B is assumed to depend on variables z (rows) and y /// (columns). The product of A and B then depends on x (rows) and y /// (columns). Only the z variables have to be explicitly identified; /// they are the "summation" variables. Returns a pointer to the /// result if successful; NULL otherwise.] /// [ REFS: 'result', DEREFS: 'dd1, dd2' ] /// </summary> /// <param name="dd1"></param> /// <param name="dd2"></param> /// <param name="vars">variable are shared by both dd1, dd2. Normally dd1 row + column, dd2 only column</param> /// <param name="method"></param> /// <returns></returns> public static CUDDNode MatrixMultiply(CUDDNode dd1, CUDDNode dd2, CUDDVars vars, int method) { return(new CUDDNode(PlatformInvoke.DD_MatrixMultiply(manager, dd1.Ptr, dd2.Ptr, vars.GetArrayPointer(), vars.GetNumVars(), method))); }
/// <summary> /// Returns transpose of matrix dd /// [ REFS: 'result', DEREFS: 'dd' ] /// </summary> public static CUDDNode Transpose(CUDDNode dd, CUDDVars rVars, CUDDVars cVars) { return(new CUDDNode(PlatformInvoke.DD_Transpose(manager, dd.Ptr, rVars.GetArrayPointer(), cVars.GetArrayPointer(), rVars.GetNumVars()))); }
/// <summary> /// Generates 0-1 ADD for the function x = y /// where x, y are num_vars-bit numbers encoded by variables x_vars, y_vars /// [ REFS: 'result', DEREFS: 'none' ] /// </summary> public static CUDDNode Identity(CUDDVars rVars, CUDDVars cVars) { return(new CUDDNode(PlatformInvoke.DD_Identity(manager, rVars.GetArrayPointer(), cVars.GetArrayPointer(), rVars.GetNumVars()))); }
/// <summary> /// Get element in vector dd /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static double GetVectorElement(CUDDNode dd, CUDDVars vars, int index) { return(PlatformInvoke.DD_GetVectorElement(manager, dd.Ptr, vars.GetArrayPointer(), vars.GetNumVars(), index)); }
/// <summary> /// // sets element in 3d matrix dd /// [ REFS: 'result', DEREFS: 'dd' ] /// </summary> public static CUDDNode Set3DMatrixElement(CUDDNode dd, CUDDVars rVars, CUDDVars cVars, CUDDVars lVars, int rIndex, int cIndex, int lIndex, double value) { return(new CUDDNode(PlatformInvoke.DD_Set3DMatrixElement(manager, dd.Ptr, rVars.GetArrayPointer(), rVars.GetNumVars(), cVars.GetArrayPointer(), cVars.GetNumVars(), lVars.GetArrayPointer(), lVars.GetNumVars(), rIndex, cIndex, lIndex, value))); }
/// <summary> /// Set the value of i.th element in vector. i is allowed to be negative. -1 is the last element. /// Note that this is a function, not a procedure /// [ REFS: 'result', DEREFS: 'dd' ] /// </summary> public static CUDDNode SetVectorElement(CUDDNode dd, CUDDVars vars, int index, double value) { return(new CUDDNode(PlatformInvoke.DD_SetVectorElement(manager, dd.Ptr, vars.GetArrayPointer(), vars.GetNumVars(), index, value))); }
/// <summary> /// Convert ADD to 0-1 ADD based on the interval [lower, upper] /// [ REFS: 'result', DEREFS: dd ] /// </summary> public static CUDDNode Interval(CUDDNode dd, double lower, double upper) { return(new CUDDNode(PlatformInvoke.DD_Interval(manager, dd.Ptr, lower, upper))); }
/// <summary> /// Convert ADD to 0-1 ADD based on the interval [threshold, threshold] /// [ REFS: 'result', DEREFS: dd ] /// </summary> public static CUDDNode Equals(CUDDNode dd, double threshold) { return(new CUDDNode(PlatformInvoke.DD_Equals(manager, dd.Ptr, threshold))); }
/// <summary> /// Convert ADD to 0-1 ADD based on the interval (-inf, threshold) /// [ REFS: 'result', DEREFS: dd ] /// </summary> public static CUDDNode LessThan(CUDDNode dd, double threshold) { return(new CUDDNode(PlatformInvoke.DD_LessThan(manager, dd.Ptr, threshold))); }