I have a laptop that runs Windows 7, but may eventually move to Windows 10. I would like to have my own utility that detects when the laptop is docked or undocked, then change the power profile settings. I already have it set to do what I want when it's powered by the battery versus AC in the standard power Windows profiles, but I want a different power plan when the laptop is on the docking station than when it's just plugged into the AC adapter and not on the docking station.
So far, I have a working program that starts up with only a little icon in the system tray, and it will make the changes I want when it's docked versus undocked, BUT the way I'm determining the laptop is docked is by looking for the specific hardcoded monitor name I have connected to my docking station (e.g. "Samsung U32D970Q") via EnumDisplayDevices calls whenever WM_DEVICECHANGE happens.
The main problem is if I ever change the monitor, then the program will stop working. I could pass a parameter to the program on startup with the name of the monitor to look for, but I'm trying to find out if there is a better way. Am I being silly doing it this way?
Is there some Windows 7+ feature where the OS can tell that a laptop is on a docking station or not?