Monitor Install/Uninstall of Fonts on Windows
I'm kind of shooting in the dark here - searches don't seem to be productive on this. I want to create a .NET program to monitor the install and uninstall of fonts. If something is installed or uninstalled, I want to run a program to do something.
I thought maybe a Windows Service, but haven't gotten very far with figuring out how to monitor fonts. Is this the right way and if so, what am I overlooking? If not开发者_StackOverflow社区, is there a different way to do this?
You could monitor the registry for font changes. Looking at the process monitor I see it stores the information here on windows 7.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
you can create a hook for the WM_FONTCHANGE windows message.
check this article Using Window Messages to Implement Global System Hooks in C#
I don't know that much about Fonts so I might be mistaken but I think that they're all installed in %windir%\Fonts.
If that is the case you should be able to set up a FileSystemWatcher in your service to watch that directory for any changes.
精彩评论