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 34 35 36 37 38 39 40
| #include <Windows.h>
#include <stdio.h>
int main(int argc, char **argv)
{
HKEY hKey;
char *path;
char *path_exec;
path = malloc(600 * sizeof(*path));
path_exec = malloc(256 * sizeof(*path_exec));
path = getenv("path");
path_exec = ";C:\\test";
path = strcat(path, path_exec);
printf("Path = %s\n", path);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", 0, KEY_ALL_ACCESS, &hKey ) == ERROR_SUCCESS )
{
printf("Reussi \n");
/*****Ouverture a réussi *****/
if( RegSetValueEx(hKey,"path", 0, REG_SZ, path, lstrlen(path)) == ERROR_SUCCESS )
{
/*****Modification réussi, Fermeture de la clé*****/
RegCloseKey( hKey );
}
}
else
{
printf("DOWN\n");
}
getchar();
free(path);
free(path_exec);
return (EXIT_SUCCESS);
} |
Partager