Pregunta: | 1590 - AGREGAR AL REGISTRO DE WINDOWS |
Autor: | Paul Mancheno |
por favor, como hago para que un programa hecho en c, se anexe al registro de windows, en una rama específica gracias |
Respuesta: | Italo Muñoz |
Al contrario de la respuesta de Jorge Garay yo te respondo en C :) Mi documentacion dice lo sgte acerca de la funcion GetProfileString : "The GetProfileString function retrieves the string associated with the specified key in the given section of the WIN.INI file. This function is provided for compatibility with 16-bit Windows-based applications. Win32-based applications should store initialization information in the registry." -- traduccion : esta obsoleta. Trabajar con el registro de windows se parece a operar con archivos, pues hay que abrir y cerrar "handle". Ejemplo : Lo sgte ejecutara un programa cada vez que se inicie Windows (Agregar un "valor de la cadena" en LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run) /* si hay algun problema de prototipo o algo asi incluye winreg.h */ LONG status; HKEY hKey; char programa[]={"c:\\archiv~1\\program.exe"}; status = RegOpenKeyEx(KEY_LOCAL_MACHINE, /* HKEY_LOCAL_MACHINE valor predefinido */ "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0,/*reservado debe ser cero*/ KEY_WRITE, /* combina KEY_SET_VALUE y KEY_CREATE_SUB_KEY */ &hKey); if(status != ERROR_SUCCESS) return ERROR; RegSetValueEx(hKey,"nombre del valor", 0 /*reservado debe ser cero*/, REG_SZ,/* indica string terminado en NULL */ programa, /* contenido del valor */ lstrlen(programa)+ 1 /* +1 incluir caracter NULL si se indica REG_SZ*/ ); RegCloseKey(hKey); Por favor cuentame como te fue. Te puedo ayudar con otro tipo |
Respuesta: | Jorge Garay |
lo que se "anexa" no es el programa, sino valores de configuracion que éste necesita usar. Por ejemplo las preferencias del usuario, el tamaño de la ventana principal, etc. podes usar las sig. funciones: CWinApp::GetProfileString CWinApp::WriteProfileString |