@ -40,31 +40,34 @@ bool RegisterApp (const char *appName, const char *appDescription, const char *i
{
// Create the app key
HKEY hKey ;
if ( RegCreateKey ( HKEY_CLASSES_ROOT , appName, & hKey ) = = ERROR_SUCCESS )
if ( RegCreateKey ( HKEY_CLASSES_ROOT , nlUtf8ToTStr( appName) , & hKey ) = = ERROR_SUCCESS )
{
// Set the description
RegSetValue ( hKey , " " , REG_SZ , appDescription , strlen ( appDescription ) ) ;
tstring tAppDescription = utf8ToTStr ( appDescription ) ;
RegSetValue ( hKey , _T ( " " ) , REG_SZ , tAppDescription . c_str ( ) , ( tAppDescription . size ( ) + 1 ) * sizeof ( TCHAR ) ) ;
// Create the icon
HKEY hKey2 ;
if ( RegCreateKey ( hKey , " DefaultIcon " , & hKey2 ) = = ERROR_SUCCESS )
if ( RegCreateKey ( hKey , _T ( " DefaultIcon " ) , & hKey2 ) = = ERROR_SUCCESS )
{
// Set the description
char tmp [ 512 ] ;
smprintf ( tmp , 512 , " %s,%d " , icon , iconIndex ) ;
RegSetValue ( hKey2 , " " , REG_SZ , tmp , strlen ( tmp ) ) ;
tstring ttmp = utf8ToTStr ( tmp ) ;
RegSetValue ( hKey2 , _T ( " " ) , REG_SZ , ttmp . c_str ( ) , ( ttmp . size ( ) + 1 ) * sizeof ( TCHAR ) ) ;
}
// Create the shell/open/command
if ( RegCreateKey ( hKey , " shell " , & hKey ) = = ERROR_SUCCESS )
if ( RegCreateKey ( hKey , _T ( " shell " ) , & hKey ) = = ERROR_SUCCESS )
{
if ( RegCreateKey ( hKey , " open " , & hKey ) = = ERROR_SUCCESS )
if ( RegCreateKey ( hKey , _T ( " open " ) , & hKey ) = = ERROR_SUCCESS )
{
if ( RegCreateKey ( hKey , " command " , & hKey ) = = ERROR_SUCCESS )
if ( RegCreateKey ( hKey , _T ( " command " ) , & hKey ) = = ERROR_SUCCESS )
{
// Set the description
string tmp = string ( icon ) + " \" %1 \" " ;
RegSetValue ( hKey , " " , REG_SZ , tmp . c_str ( ) , tmp . size ( ) ) ;
tstring ttmp = utf8ToTStr ( tmp ) ;
RegSetValue ( hKey , _T ( " " ) , REG_SZ , ttmp . c_str ( ) , ( ttmp . size ( ) + 1 ) * sizeof ( TCHAR ) ) ;
}
}
}
@ -78,7 +81,7 @@ bool RegisterApp (const char *appName, const char *appDescription, const char *i
bool UnregisterApp ( const char * appName )
{
// Delete the app key
deleteKey ( HKEY_CLASSES_ROOT , appName) ;
deleteKey ( HKEY_CLASSES_ROOT , nlUtf8ToTStr( appName) ) ;
return true ;
}
@ -87,12 +90,12 @@ bool UnregisterAppCommand (const char *appName, const char *command)
{
// Create the app key
HKEY hKey ;
if ( RegOpenKey ( HKEY_CLASSES_ROOT , appName, & hKey ) = = ERROR_SUCCESS )
if ( RegOpenKey ( HKEY_CLASSES_ROOT , nlUtf8ToTStr( appName) , & hKey ) = = ERROR_SUCCESS )
{
// Create the icon
char tmp [ 512 ] ;
smprintf ( tmp , 512 , " shell \\ %s " , command ) ;
deleteKey ( hKey , tmp) ;
deleteKey ( hKey , nlUtf8ToTStr( tmp) ) ;
return true ;
}
return false ;
@ -103,15 +106,16 @@ bool RegisterAppCommand (const char *appName, const char *command, const char *a
{
// Create the app key
HKEY hKey ;
if ( RegCreateKey ( HKEY_CLASSES_ROOT , appName, & hKey ) = = ERROR_SUCCESS )
if ( RegCreateKey ( HKEY_CLASSES_ROOT , nlUtf8ToTStr( appName) , & hKey ) = = ERROR_SUCCESS )
{
// Create the icon
char tmp [ 512 ] ;
smprintf ( tmp , 512 , " shell \\ %s \\ command " , command ) ;
if ( RegCreateKey ( hKey , tmp, & hKey ) = = ERROR_SUCCESS )
if ( RegCreateKey ( hKey , nlUtf8ToTStr( tmp) , & hKey ) = = ERROR_SUCCESS )
{
// Set the description
RegSetValue ( hKey , " " , REG_SZ , app , strlen ( app ) ) ;
tstring tapp = utf8ToTStr ( app ) ;
RegSetValue ( hKey , _T ( " " ) , REG_SZ , tapp . c_str ( ) , ( tapp . size ( ) + 1 ) * sizeof ( TCHAR ) ) ;
}
return true ;
}
@ -123,12 +127,12 @@ bool UnregisterDDECommand (const char *appName, const char *command)
{
// Create the app key
HKEY hKey ;
if ( RegOpenKey ( HKEY_CLASSES_ROOT , appName, & hKey ) = = ERROR_SUCCESS )
if ( RegOpenKey ( HKEY_CLASSES_ROOT , nlUtf8ToTStr( appName) , & hKey ) = = ERROR_SUCCESS )
{
// Create the icon
char tmp [ 512 ] ;
smprintf ( tmp , 512 , " shell \\ %s \\ ddeexec " , command ) ;
deleteKey ( hKey , tmp) ;
deleteKey ( hKey , nlUtf8ToTStr( tmp) ) ;
}
return false ;
}
@ -138,22 +142,24 @@ bool RegisterDDECommand (const char *appName, const char *command, const char *d
{
// Create the app key
HKEY hKey ;
if ( RegCreateKey ( HKEY_CLASSES_ROOT , appName, & hKey ) = = ERROR_SUCCESS )
if ( RegCreateKey ( HKEY_CLASSES_ROOT , nlUtf8ToTStr( appName) , & hKey ) = = ERROR_SUCCESS )
{
// Create the icon
char tmp [ 512 ] ;
smprintf ( tmp , 512 , " shell \\ %s \\ ddeexec " , command ) ;
if ( RegCreateKey ( hKey , tmp, & hKey ) = = ERROR_SUCCESS )
if ( RegCreateKey ( hKey , nlUtf8ToTStr( tmp) , & hKey ) = = ERROR_SUCCESS )
{
// Set the description
RegSetValue ( hKey , " " , REG_SZ , ddeCommand , strlen ( ddeCommand ) ) ;
tstring tddeCommand = utf8ToTStr ( ddeCommand ) ;
RegSetValue ( hKey , _T ( " " ) , REG_SZ , tddeCommand . c_str ( ) , ( tddeCommand . size ( ) + 1 ) * sizeof ( TCHAR ) ) ;
HKEY hKey2 ;
if ( RegCreateKey ( hKey , " application " , & hKey2 ) = = ERROR_SUCCESS )
if ( RegCreateKey ( hKey , _T ( " application " ) , & hKey2 ) = = ERROR_SUCCESS )
{
RegSetValue ( hKey2 , " " , REG_SZ , application , strlen ( application ) ) ;
if ( RegCreateKey ( hKey , " topic " , & hKey2 ) = = ERROR_SUCCESS )
tstring tapplication = utf8ToTStr ( application ) ;
RegSetValue ( hKey2 , _T ( " " ) , REG_SZ , tapplication . c_str ( ) , ( tapplication . size ( ) + 1 ) * sizeof ( TCHAR ) ) ;
if ( RegCreateKey ( hKey , _T ( " topic " ) , & hKey2 ) = = ERROR_SUCCESS )
{
RegSetValue ( hKey2 , " " , REG_SZ , " system " , strlen ( " system " ) ) ;
RegSetValue ( hKey2 , _T ( " " ) , REG_SZ , _T ( " system " ) , ( strlen ( " system " ) + 1 ) * sizeof ( TCHAR ) ) ;
return true ;
}
}
@ -168,13 +174,14 @@ bool RegisterShellFileExt (const char *ext, const char *appName)
// Remove key in explorer registry if exist
HKEY hKey ;
string key = " Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Explorer \\ FileExts \\ " + string ( ext ) ;
deleteKey ( HKEY_CURRENT_USER , key . c_str ( ) ) ;
deleteKey ( HKEY_CURRENT_USER , nlUtf8ToTStr ( key ) ) ;
// Create the app key
if ( RegCreateKey ( HKEY_CLASSES_ROOT , ext, & hKey ) = = ERROR_SUCCESS )
if ( RegCreateKey ( HKEY_CLASSES_ROOT , nlUtf8ToTStr( ext) , & hKey ) = = ERROR_SUCCESS )
{
// Set the description
RegSetValue ( hKey , " " , REG_SZ , appName , strlen ( appName ) ) ;
tstring tAppName = utf8ToTStr ( appName ) ;
RegSetValue ( hKey , _T ( " " ) , REG_SZ , tAppName . c_str ( ) , ( tAppName . size ( ) + 1 ) * sizeof ( TCHAR ) ) ;
return true ;
}
return false ;
@ -184,7 +191,7 @@ bool RegisterShellFileExt (const char *ext, const char *appName)
bool UnregisterShellFileExt ( const char * ext )
{
// Delete the app key
if ( RegDeleteKey ( HKEY_CLASSES_ROOT , ext) = = ERROR_SUCCESS )
if ( RegDeleteKey ( HKEY_CLASSES_ROOT , nlUtf8ToTStr( ext) ) = = ERROR_SUCCESS )
{
return true ;
}