/// <summary> /// Returns true if SH subclass (SFH_NoCloseHandle) value has changed else returns false /// </summary> /// <returns></returns> public static bool IsChanged(SFH_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 SFH_NoCloseHandle /// </summary> /// <returns></returns> public static SFH_NoCloseHandle NewSFH_NoCloseHandle() { String lpFileName = "C.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 SFH_NoCloseHandle hnd = SFH_NoCloseHandle.CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); return(hnd); }
/// <summary> /// Returns the Int32 value associated with a SFH_NoCloseHandle /// </summary> /// <returns></returns> public static Int32 SHInt32(SFH_NoCloseHandle hnd) { IntPtr hndIntPtr = hnd.DangerousGetHandle(); //get the IntPtr associated with hnd return(hndIntPtr.ToInt32()); //return the 32-bit value associated with hnd }