/// <summary> /// Returns true if ChildSFH_NoCloseHandle value has changed else returns false /// </summary> /// <returns></returns> public static bool IsChanged(ChildSFH_NoCloseHandle hnd) { Int32 hndInt32 = SHInt32(hnd); //get the 32-bit value associated with hnd if (hndInt32 == ReturnValue) { return(true); } return(false); }
/// <summary> /// Creates and returns a new ChildSFH_NoCloseHandle /// </summary> /// <returns></returns> public static ChildSFH_NoCloseHandle NewChildSFH_NoCloseHandle() { String lpFileName = "D.txt"; DesiredAccess dwDesiredAccess = DesiredAccess.GENERIC_WRITE; ShareMode dwShareMode = ShareMode.FILE_SHARE_WRITE; IntPtr lpSecurityAttributes = IntPtr.Zero; CreationDisposition dwCreationDisposition = CreationDisposition.CREATE_ALWAYS; FlagsAndAttributes dwFlagsAndAttributes = FlagsAndAttributes.None; IntPtr hTemplateFile = IntPtr.Zero; //create the handle ChildSFH_NoCloseHandle hnd = ChildSFH_NoCloseHandle.CreateChildSafeFileHandle(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); return(hnd); }
/// <summary> /// Returns the Int32 value associated with a ChildSFH_NoCloseHandle /// </summary> /// <returns></returns> public static Int32 SHInt32(ChildSFH_NoCloseHandle hnd) { IntPtr hndIntPtr = hnd.DangerousGetHandle(); //get the IntPtr associated with hnd return(hndIntPtr.ToInt32()); //return the 32-bit value associated with hnd }