using Microsoft . Win32;
using System . Runtime . InteropServices;
[ DllImport ( "shell32.dll" , CharSet = CharSet . Auto, SetLastError = true)]
internal static extern void SHChangeNotify( uint wEventId , uint uFlags ,
IntPtr dwItem1, IntPtr dwItem2);
private const uint SHCNE_ASSOCCHANGED = 0x08000000 ;
private const uint SHCNF_IDLIST = 0x0000 ;
private const uint SHCNF_FLUSH = 0x1000 ;
private void UnregistryShell()
{
registryShell = false ;
bool changeRegistry = false ;
RegistryKey vRegistryKey = Registry . ClassesRoot . OpenSubKey( ".xxx" );
if (vRegistryKey != null )
{
changeRegistry = true ;
vRegistryKey . Close();
Registry . ClassesRoot . DeleteSubKeyTree( ".xxx" );
}
vRegistryKey = Registry . ClassesRoot . OpenSubKey( "xxx Document" );
if (vRegistryKey != null )
{
changeRegistry = true ;
vRegistryKey . Close();
Registry . ClassesRoot . DeleteSubKeyTree( "xxx Document" );
}
if (changeRegistry)
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSH,
IntPtr . Zero, IntPtr . Zero);
}
private bool IsRegistryShell()
{
RegistryKey vRegistryKey = Registry . ClassesRoot . OpenSubKey( ".xxx" );
if (vRegistryKey == null ) return false ;
vRegistryKey = Registry . ClassesRoot . OpenSubKey(
@"xxx Document\shell\open\command" );
if (vRegistryKey == null) return false ;
if (vRegistryKey . GetValue( "" ) . ToString() . ToLower() !=
Application . ExecutablePath . ToLower() + " \"%1\"" ) return false ;
return true ;
}
//
private void Form1_Load( object sender , EventArgs e)
{
string [] vCommands = Environment . GetCommandLineArgs();
if (vCommands . Length > 1 )
{
OpenDocument(vCommands[ 1 ]);
}
}