Posts

Showing posts from August, 2024

Set a property to read-only or browsable to false custom attribute at runtime using System.Reflection

We had a problem recently where we wanted to set certain properties in a C# .NET class to read-only at runtime depending on the overarching product accessing the library so that it could be displayed in a property grid. Our new product XIA Configuration Express would have certain features that would be unavailable due to the nature of the product compared to the main XIA Configuration Server product. Custom attributes are designed to be assigned in the source code and not modified later so this requires some additional work with reflection to access the fields of the attribute or to add a new attribute to the collection if it doesn't already exist. NOTE:  This changes the read-only attribute for the class not an instance of the class so if you cannot have the property being read-only for a single instance of the class and not of another instance of the class.    /// <summary>     /// Sets the readonly attribute value for the specified property.     /// </summary>  

Restore the My Computer (This PC) icon to the Desktop on Windows 11

Image
If you're looking for a quick way to restore the "My Computer" icon to the desktop on Windows 11 you can simply... Click start, then type Desk.cpl ,5 This will open the classic Desktop Icon Settings dialog and you can just tick "Computer" and click OK.

SOLVED: View Windows HTML Help (CHM) files on a high resolution high DPI monitor with scaling enabled is impossible to see

Image
When you try to view a Windows HTML Help (CHM) file on a high resolution high DPI monitor with scaling enabled you'll find it very difficult to view with the icons too small. CHM files are somewhat dated however are still widely used. PowerShell Fix $windowsDirectory = [System.Environment]::ExpandEnvironmentVariables("%WINDIR%"); Copy-Item -Path "$windowsDirectory\hh.exe" -Destination "$windowsDirectory\hhcompat.exe"; Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" -Name "$windowsDirectory\hhcompat.exe" -Value "~ DPIUNAWARE"; Set-ItemProperty -Path "HKCU:\SOFTWARE\Classes\Applications\hhs.exe\shell\open\command" -Name "(default)" -Value "`"C:\Windows\hhcompat.exe`" `"%1`""; Manual Fix Instructions To resolve this you can change the compatibility settings, however these are unavailable on the built-in hh.exe file. So you need