private bool SetAccessibleOption(Object Struct, Int32 StructSize, AccessType AccessType, WinIniFlags IniFlag) { bool ReturnValue; // The return value of this method. // Allocate enough memory to create an unmanaged version // of the data structure. IntPtr DataPtr = Marshal.AllocHGlobal(StructSize); // Point to the managed data stucture using the unmanaged // memory pointer. Marshal.StructureToPtr(Struct, DataPtr, true); // Return true if the SystemParametersInfo() function call // successfully modifies the Windows Accessibility features // using the data in the data structure. ReturnValue = Accessible.SystemParametersInfo( AccessType, Convert.ToUInt32(StructSize), DataPtr, IniFlag); // Deallocate the memory we previously allocated. Marshal.FreeHGlobal(DataPtr); // Return the data. return(ReturnValue); }
private Object GetAccessibleOption(Object Struct, Int32 StructSize, AccessType AccessType, WinIniFlags IniFlag) { Object ReturnValue; // The return data. // Allocate enough memory to create an unmanaged version // of the data structure. IntPtr DataPtr = Marshal.AllocHGlobal(StructSize); // Point to the managed data stucture using the unmanaged // memory pointer. Marshal.StructureToPtr(Struct, DataPtr, true); // Call the SystemParametersInfo() function using the // unmanaged data structure pointer. Accessible.SystemParametersInfo(AccessType, Convert.ToUInt32(StructSize), DataPtr, IniFlag); // Move the data retrieved from the umnanaged environment to // the managed data structure and return this data structure // as an object. ReturnValue = Marshal.PtrToStructure(DataPtr, Struct.GetType()); // Deallocate the memory we previously allocated. Marshal.FreeHGlobal(DataPtr); // Return the data. return(ReturnValue); }
public static extern bool SystemParametersInfo(AccessType uiAction, UInt32 uiParam, IntPtr pvParam, WinIniFlags fWinIni);