ClickOnce installs an Uninstall registry key in HKEY_CURRENT_USER which is accessible to your ClickOnce application.
The specific location is "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
You will have to search for the key with the DisplayName of your Application.
You can then wrap the normal uninstall action,
string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
Microsoft.Win32.RegistryKey uninstallKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(registryKey);
if (uninstallKey != null)
{
foreach (String a in uninstallKey.GetSubKeyNames())
{
Microsoft.Win32.RegistryKey subkey = uninstallKey.OpenSubKey(a, true);
// Found the Uninstall key for this app.
if (subkey.GetValue("DisplayName").Equals("AppDisplayName"))
{
string uninstallString = subkey.GetValue("UninstallString").ToString();
// Wrap uninstall string with my own command
// In this case a reg delete command to remove a reg key.
string newUninstallString = "cmd /c \"" + uninstallString +
" & reg delete HKEY_CURRENT_USER\\SOFTWARE\\CLASSES\\mykeyv" +
MYAPP_VERSION + " /f\"";
subkey.SetValue("UninstallString", newUninstallString);
subkey.Close();
}
}
}