haber yo sólamente hice una búsqueda..
http://stackoverflow.com/questions/1154701/batch-cmd-adding-files-to-startup-listhttp://superuser.com/questions/71190/running-bat-file-at-startup-as-administrator-in-windows-7http://www.microloft.co.uk/startup.htmhttp://www.tomshardware.com/forum/258456-45-autoloading-file-registry-startuphttp://news.softpedia.com/news/How-To-Add-an-Application-To-Startup-Using-The-Registry-43488.shtmly si te falta más código para trabajar con el registro te paso algunos códigos que tenía guardados.
// want to edit key "HKEY_LOCAL_MACHINE\Software\company name\game name\settings\value"
// to "1" (DWORD)
void a(){
HKEY hkey;
DWORD dwDisposition;
//ask for write permission KEY_WRITE
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,
TEXT("Software\\company name\\game name\\settings"),
0, NULL, 0,
KEY_WRITE, NULL,
&hkey, &dwDisposition) == ERROR_SUCCESS)
{
// etc..
}
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,
TEXT("Software\\company name\\game name\\settings"), 0, NULL, 0, 0, NULL,
&hkey, &dwDisposition) == ERROR_SUCCESS){
DWORD dwType, dwSize;
dwType = REG_DWORD;
dwSize = sizeof(DWORD);
DWORD rofl = 1;
// does not create anything
RegSetValueEx(hkey, TEXT("value"), 0, dwType, (PBYTE)&rofl, dwSize);
RegCloseKey(hkey);
}
}
LONG SetRegValue(const wchar_t* path,const wchar_t *name,const wchar_t *value)
{
LONG status;
HKEY hKey;
status = RegOpenKeyEx(HKEY_CURRENT_USER, (const char *)path, 0, KEY_ALL_ACCESS, &hKey);
if ( (status == ERROR_SUCCESS) && (hKey != NULL))
{
status = RegSetValueEx( hKey, (const char *)name, 0, REG_SZ, (BYTE*)value,
((DWORD)wcslen(value)+1)*sizeof(wchar_t));
RegCloseKey(hKey);
}
return status;
}
char cdkey[14] = "";
void getCDKey()
{
HKEY l_hKey;
DWORD l_dwBufLen = 17;
DWORD type = REG_SZ;
DWORD l_ret = RegOpenKeyEx(
HKEY_CURRENT_USER,
"Software\\Ltfxhook",
0,KEY_QUERY_VALUE, &l_hKey);
if(l_ret!=ERROR_SUCCESS)
{
Con_Echo("&rltfxkey retreival failed");
}
l_ret = RegQueryValueEx(l_hKey,"Key",NULL,&type,(LPBYTE)&cdkey,&l_dwBufLen);
}
char cdkey[14] = "";
void getCDKey()
{
HKEY l_hKey;
DWORD l_dwBufLen = 14;
DWORD type = REG_SZ;
DWORD l_ret = RegOpenKeyEx(
HKEY_CURRENT_USER,
"Software\\Valve\\CounterStrike\\Settings",
0,KEY_QUERY_VALUE, &l_hKey);
if(l_ret!=ERROR_SUCCESS)
{
DWORD l_ret = RegOpenKeyEx(
HKEY_CURRENT_USER,
"Software\\Valve\\Half-life\\Settings",
0,KEY_QUERY_VALUE, &l_hKey);
if(l_ret!=ERROR_SUCCESS)
return;
}
l_ret = RegQueryValueEx(l_hKey,"Key",NULL,&type,(LPBYTE)&cdkey,&l_dwBufLen);
for(int i=0;i<13;i++)
{
switch( cdkey[i] )
{
case '0':
cdkey[i] = 'g';
break;
case '1':
cdkey[i] = 'a';
break;
case '2':
cdkey[i] = 'u';
break;
case '3':
cdkey[i] = 'l';
break;
case '4':
cdkey[i] = 'x';
break;
case '5':
cdkey[i] = 't';
break;
case '6':
cdkey[i] = 'c';
break;
case '7':
cdkey[i] = 'm';
break;
case '8':
cdkey[i] = 'r';
break;
case '9':
cdkey[i] = 'j';
break;
}
}
}
void printerr(DWORD dwerror) {
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwerror,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
if (isOut) {
fprintf(fout, "%s\n", lpMsgBuf);
} else {
printf("%s\n", lpMsgBuf);
}
// Free the buffer.
LocalFree(lpMsgBuf);
}
bool regreadSZ(string& hkey, string& subkey, string& value, string& returnvalue, string& regValueType) {
char s[128000];
map<string,HKEY> keys;
keys["HKEY_CLASSES_ROOT"]=HKEY_CLASSES_ROOT;
keys["HKEY_CURRENT_CONFIG"]=HKEY_CURRENT_CONFIG; //DID NOT SURVIVE?
keys["HKEY_CURRENT_USER"]=HKEY_CURRENT_USER;
keys["HKEY_LOCAL_MACHINE"]=HKEY_LOCAL_MACHINE;
keys["HKEY_USERS"]=HKEY_USERS;
HKEY mykey;
map<string,DWORD> valuetypes;
valuetypes["REG_SZ"]=REG_SZ;
valuetypes["REG_EXPAND_SZ"]=REG_EXPAND_SZ;
valuetypes["REG_MULTI_SZ"]=REG_MULTI_SZ; //probably can't use this.
LONG retval=RegOpenKeyEx(
keys[hkey], // handle to open key
subkey.c_str(), // subkey name
0, // reserved
KEY_READ, // security access mask
&mykey // handle to open key
);
if (ERROR_SUCCESS != retval) {printerr(retval); return false;}
DWORD slen=128000;
DWORD valuetype = valuetypes[regValueType];
retval=RegQueryValueEx(
mykey, // handle to key
value.c_str(), // value name
NULL, // reserved
(LPDWORD) &valuetype, // type buffer
(LPBYTE)s, // data buffer
(LPDWORD) &slen // size of data buffer
);
switch(retval) {
case ERROR_SUCCESS:
//if (isOut) {
// fprintf(fout,"RegQueryValueEx():ERROR_SUCCESS:succeeded.\n");
//} else {
// printf("RegQueryValueEx():ERROR_SUCCESS:succeeded.\n");
//}
break;
case ERROR_MORE_DATA:
//what do I do now? data buffer is too small.
if (isOut) {
fprintf(fout,"RegQueryValueEx():ERROR_MORE_DATA: need bigger buffer.\n");
} else {
printf("RegQueryValueEx():ERROR_MORE_DATA: need bigger buffer.\n");
}
return false;
case ERROR_FILE_NOT_FOUND:
if (isOut) {
fprintf(fout,"RegQueryValueEx():ERROR_FILE_NOT_FOUND: registry value does not exist.\n");
} else {
printf("RegQueryValueEx():ERROR_FILE_NOT_FOUND: registry value does not exist.\n");
}
return false;
default:
if (isOut) {
fprintf(fout,"RegQueryValueEx():unknown error type 0x%lx.\n", retval);
} else {
printf("RegQueryValueEx():unknown error type 0x%lx.\n", retval);
}
return false;
}
retval=RegCloseKey(mykey);
if (ERROR_SUCCESS != retval) {printerr(retval); return false;}
returnvalue = s;
return true;
}
HKEY hKey;
LONG lRes = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Perl", 0, KEY_READ, &hKey);
bool bExistsAndSuccess (lRes == ERROR_SUCCESS);
bool bDoesNotExistsSpecifically (lRes == ERROR_FILE_NOT_FOUND);
std::wstring strValueOfBinDir;
std::wstring strKeyDefaultValue;
GetStringRegKey(hKey, L"BinDir", strValueOfBinDir, L"bad");
GetStringRegKey(hKey, L"", strKeyDefaultValue, L"bad");
LONG GetDWORDRegKey(HKEY hKey, const std::wstring &strValueName, DWORD &nValue, DWORD nDefaultValue)
{
nValue = nDefaultValue;
DWORD dwBufferSize(sizeof(DWORD));
DWORD nResult(0);
LONG nError = ::RegQueryValueExW(hKey,
strValueName.c_str(),
0,
NULL,
reinterpret_cast<LPBYTE>(&nResult),
&dwBufferSize);
if (ERROR_SUCCESS == nError)
{
nValue = nResult;
}
return nError;
}
LONG GetBoolRegKey(HKEY hKey, const std::wstring &strValueName, bool &bValue, bool bDefaultValue)
{
DWORD nDefValue((bDefaultValue) ? 1 : 0);
DWORD nResult(nDefValue);
LONG nError = GetDWORDRegKey(hKey, strValueName.c_str(), nResult, nDefValue);
if (ERROR_SUCCESS == nError)
{
bValue = (nResult != 0) ? true : false;
}
return nError;
}
LONG GetStringRegKey(HKEY hKey, const std::wstring &strValueName, std::wstring &strValue, const std::wstring &strDefaultValue)
{
strValue = strDefaultValue;
WCHAR szBuffer[512];
DWORD dwBufferSize = sizeof(szBuffer);
ULONG nError;
nError = RegQueryValueExW(hKey, strValueName.c_str(), 0, NULL, (LPBYTE)szBuffer, &dwBufferSize);
if (ERROR_SUCCESS == nError)
{
strValue = szBuffer;
}
return nError;
}
XD