1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| bool SetRunAppWithExtension(const char *szAppName,
const char *szLibApp,
const char *szCommandLine,
const char *szExtName)
{
HKEY hKey=NULL;
long ret;
// Creation de la racine szAppName
if(RegCreateKey(HKEY_CLASSES_ROOT, szAppName, &hKey)!=ERROR_SUCCESS) return false;
if(RegSetValue(hKey, "", REG_SZ,szLibApp, NULL)!=ERROR_SUCCESS)
{
RegCloseKey(hKey);
return false;
}
RegCloseKey(hKey);
// création de l'entrée pour l'extension szExtname associée à szAppName
if((ret=RegCreateKey(HKEY_CLASSES_ROOT, szExtName,&hKey))==ERROR_SUCCESS)
ret=RegSetValue(hKey, "", REG_SZ, szAppName,NULL);
else
{
RegCloseKey(hKey);
return false;
}
RegCloseKey(hKey);
// fixe la ligne de commande pour szAppName
if((ret = RegCreateKey(HKEY_CLASSES_ROOT, szAppName,&hKey))==ERROR_SUCCESS)
ret = RegSetValue(hKey, "shell\\open\\command", REG_SZ, szCommandLine,
MAX_PATH);
if(ret==ERROR_SUCCESS) RegCloseKey(hKey);
return (ret==ERROR_SUCCESS);
} |
Partager