yoogi Temat założony przez niniejszego użytkownika  | 
» 2012-09-13 18:46:23 Znalazłem ścieżkę :) HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Shared Tools/MSConfig/startupreg/NAZWAAPLIKACJI #edit Po całym dniu zmarnowanym nad szukaniem błędu, razem z admixiorem, za co jestem mu bardzo wdzięczny :) ja stwierdzam, że nie wiem co jest przyczyną. Być może klucz jest otwarty w innej aplikacji i żadna inna nie ma do tego klucza dostępu, lub też co na początku brałem pod uwagę UNICODE, lub literówka, albo po prostu błąd w kodzie. Jeżeli ktoś jest na tyle dobry aby pobrać wartość z klucza  HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Shared Tools/MSConfig/startupreg/NAZWAAPLIKACJI  i wartość "command", gdzie "NAZWAAPLIKACJI" to losowy klucz który znajduje się w kluczu "startupreg". Funkcje typu RegOpenKey czy RegQueryValue, cały czas zwracają 2 lub 6 -> błędna ścieżka. GetLastError zwraca 26. Zamieszczam klase którą napisałem dawno dawno temu, a nawet jeszcze dawniej :) #ifndef Registry_h #define Registry_h
  #include <Windows.h> #include <string>
  class Registry { public:     Registry();     Registry( HKEY phkey, LPCSTR ppath );     Registry( HKEY phkey, LPCSTR ppath, LPCSTR pname, std::string value );     Registry( HKEY phkey, LPCSTR ppath, LPCSTR pname, int value );     ~Registry();          int CreateKey( LPCSTR pname );     int OpenKey( HKEY phkey, LPCSTR ppath );     int CreateStringValue( LPCSTR pname, const char * value );     std::string GetStringValue( LPCSTR pname );     int DeleteValue( LPCSTR pname );     int DeleteKey( LPCSTR pname );     int GetIntValue( LPCSTR pname );     int CreateIntValue( LPCSTR pname, int pvalue ); private:     HKEY hkSoftware;     LONG result;          HKEY hkTest;     DWORD dwDisp; };
  #endif
  #include "Registry.h"
  #include <iostream>
  Registry::~Registry() { }
  Registry::Registry() { }
  Registry::Registry( HKEY phkey, LPCSTR ppath ) {     result = RegOpenKeyEx( phkey, ppath, 0, KEY_ALL_ACCESS, & hkSoftware ); }
  Registry::Registry( HKEY phkey, LPCSTR ppath, LPCSTR pname, std::string value ) {     result = RegOpenKeyEx( phkey, ppath, 0, KEY_ALL_ACCESS, & hkSoftware );     result = RegSetValueEx( hkSoftware, pname, 0, REG_SZ,( LPBYTE ) value.c_str(), lstrlen( value.c_str() ) + 1 ); }
  Registry::Registry( HKEY phkey, LPCSTR ppath, LPCSTR pname, int value ) {     result = RegOpenKeyEx( phkey, ppath, 0, KEY_ALL_ACCESS, & hkSoftware );     result = RegSetValueEx( hkSoftware, pname, 0, REG_DWORD,( LPBYTE ) & value, sizeof( DWORD ) ); }
  int Registry::OpenKey( HKEY phkey, LPCSTR ppath ) {     result = RegOpenKeyEx( phkey, ppath, 0, KEY_ALL_ACCESS, & hkSoftware );     return result; }
  int Registry::CreateKey( LPCSTR pname ) {     result = RegCreateKeyEx( hkSoftware, pname, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, & hkTest, & dwDisp );     return result; }
  int Registry::CreateStringValue( LPCSTR pname, const char * value ) {     result = RegSetValueEx( hkTest, pname, 0, REG_SZ,( LPBYTE ) value, lstrlen( value ) + 1 );     return result; }
  std::string Registry::GetStringValue( LPCSTR pname ) {     const int bufSize = 1024;     char buf[ bufSize ];     DWORD dwBufSize = bufSize - 1;     DWORD dwRegsz = REG_SZ;     result = RegQueryValueEx( hkTest, pname, NULL, & dwRegsz,( LPBYTE ) buf, & dwBufSize );     std::cout << result << std::endl;     if( result == ERROR_SUCCESS ) {         buf[ bufSize - 1 ] = 0;     }     return buf; }
  int Registry::DeleteValue( LPCSTR pname ) {     return result = RegDeleteValue( hkTest, pname ); }
  int Registry::DeleteKey( LPCSTR pname ) {     return result = RegDeleteKey( hkSoftware, pname ); }
  int Registry::GetIntValue( LPCSTR pname ) {     DWORD dd;     DWORD dwBufSize = 20;     DWORD dwRegsz = REG_DWORD;     result = RegQueryValueEx( hkTest, pname, NULL, & dwRegsz,( LPBYTE ) & dd, & dwBufSize );     if( result == ERROR_SUCCESS )          return dd;      }
  int Registry::CreateIntValue( LPCSTR pname, int pvalue ) {     return result = RegSetValueEx( hkTest, pname, 0, REG_DWORD,( LPBYTE ) & pvalue, sizeof( DWORD ) ); }
  Ciekaw jestem co z tego wyniknie :) i co jest przyczyną niepożądanego działania aplikacji :)  |