Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di Ifrit
    Registrato dal
    Oct 2005
    Messaggi
    116

    [C] Registry Functions, conoscete guide in italiano?

    Salve a tutti

    Ehm... come da titolo...

    Gia tempo fa avevo chiesto dritte su come scrivere/leggere/creare/eleminare file nel reg di sistema di windows, ai tempi mi fu linkato questo:

    Link

    Ora apparte il mio enorme problema con la lingua inglese... nonostante avendo traduttore e vocabolario alla mano non riesco a capire molte cose.... pertanto per evitare di imbrattare il forum di richieste di help/spiegazioni su argomenti mirati, qualcuno potrebbe linkarmi qualche guida in italiano su questo argomento??

    Vi ringrazio in anticipo, ciao
    codice:
     $(".canaglia").show()

  2. #2
    Lo so' che magari non hai tempo, ma ti consiglio di approfondire le tue conoscenze di lingua inglese; vale lo sforzo.

  3. #3
    ho creato una classe in c++ che semplifica molto le cose!
    il suo utilizzo è molto semplice
    codice:
    RegistryClass reg;
    reg.CreateKey(HKEY_LOCAL_MACHINE, "\Software\Esempio");
    ecco il file:
    codice:
    //Registry class
    #include <winreg.h>
    #include <iostream>
    #include "stdafx.h"
    
    /*
    ****************************************
    Classe creaata da 
    *** Paolo Infante ***
    L'uso di questa classe nelle vostre applicazioni e' garantito per fini personali e commerciali.
    La distribuzione del sorgente di questa classe (o la vendita) sono ASSOLUTAMENTE proibiti se non consentiti da Paolo Infante, e sono punibili a norma della legge sul Copyright.
    
    L'autore,
    Paolo Infante.
    ****************************************
    */
    
    class RegistryClass
    {
    public:
    	bool CreateKey(HKEY BaseKey, const char * SubKeyName, LPWORD dwOptions = REG_OPTION_NON_VOLATILE)
    	{
    		HKEY point_out;
    		DWORD result;
    		LONG ret_var = RegCreateKeyEx(BaseKey, SubKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &point_out, &result);
    		if (ret_var==ERROR_SUCCESS)
    			return true;
    		if (ret_var!=0)
    			return false;
    		return true;
    	}
    	
    	bool DeleteKey(HKEY BaseKey, const char * SubKeyName)
    	{
    		LONG ret_val = RegDeleteKey(BaseKey, SubKeyName);
    		if (ret_val==ERROR_SUCCESS)
    			return true;
    		if (ret_val != 0)
    			return false;
    		return false;
    	}
    	bool DeleteValue(HKEY BaseKey, const char * SubKeyName, const char * ValueName)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val_2 = RegDeleteValue(result, ValueName);
    		if (ret_val_2==ERROR_SUCCESS)
    			return true;
    		if (ret_val_2!=0)
    			return false;
    		return false;
    	}
    	bool QueryValue(HKEY BaseKey, const char * SubKeyName, const char * ValueName, LPDWORD outValueType, LPBYTE out_data, LPDWORD size_out_data)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val2 = RegQueryValueEx(result, ValueName, 0, outValueType, out_data, size_out_data);
    		if (ret_val2==ERROR_SUCCESS)
    			return true;
    		if (ret_val2!=0)
    			return false;
    		return false;
    	}
    	bool SetValue(HKEY BaseKey, const char * SubKeyName, const char * ValueName, DWORD ValueType, const BYTE * in_data)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val2 = RegSetValueEx(result, ValueName, 0, ValueType, in_data, sizeof(in_data));
    		if (ret_val==ERROR_SUCCESS)
    			return true;
    		if (ret_val!=0)
    			return false;
    		return false;
    	}
    	bool CreateKey_S(HKEY BaseKey, std::string SubKeyName, LPWORD dwOptions = REG_OPTION_NON_VOLATILE)
    	{
    		HKEY point_out;
    		DWORD result;
    		LONG ret_var = RegCreateKeyEx(BaseKey, SubKeyName.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &point_out, &result);
    		if (ret_var==ERROR_SUCCESS)
    			return true;
    		if (ret_var!=0)
    			return false;
    		return false;
    	}
    	
    	bool DeleteKey_S(HKEY BaseKey, std::string SubKeyName)
    	{
    		LONG ret_val = RegDeleteKey(BaseKey, SubKeyName.c_str());
    		if (ret_val==ERROR_SUCCESS)
    			return true;
    		if (ret_val != 0)
    			return false;
    		return false;
    	}
    	bool DeleteValue_S(HKEY BaseKey, std::string SubKeyName, std::string ValueName)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName.c_str(), 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val_2 = RegDeleteValue(result, ValueName.c_str());
    		if (ret_val_2==ERROR_SUCCESS)
    			return true;
    		if (ret_val_2!=0)
    			return false;
    		return false;
    	}
    	bool QueryValue_S(HKEY BaseKey, std::string SubKeyName, std::string ValueName, LPDWORD outValueType, LPBYTE out_data, LPDWORD size_out_data)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName.c_str(), 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val2 = RegQueryValueEx(result, ValueName.c_str(), 0, outValueType, out_data, size_out_data);
    		if (ret_val2==ERROR_SUCCESS)
    			return true;
    		if (ret_val2!=0)
    			return false;
    		return false;
    	}
    	bool SetValue_S(HKEY BaseKey, std::string SubKeyName, std::string ValueName, DWORD ValueType, const BYTE * in_data)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName.c_str(), 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val2 = RegSetValueEx(result, ValueName.c_str(), 0, ValueType, in_data, sizeof(in_data));
    		if (ret_val==ERROR_SUCCESS)
    			return true;
    		if (ret_val!=0)
    			return false;
    		return false;
    	}
    	bool QueryString(HKEY BaseKey, const char * SubKeyName, const char * ValueName, LPSTR OutValue)	
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		DWORD dummy;
    		LONG ret_val2 = RegQueryValueEx(result, ValueName, 0, NULL, (LPBYTE)OutValue, &dummy);
    		if (ret_val2==ERROR_SUCCESS)
    			return true;
    		if (ret_val2!=0)
    			return false;
    		return false;
    	}
    	std::string QueryString_S(HKEY BaseKey, std::string SubKeyName, std::string ValueName)	
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName.c_str(), 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return "";
    		DWORD dummy;
    		std::string box_s;
    		char OutValue[10000];
    		LONG ret_val2 = RegQueryValueEx(result, ValueName.c_str(), 0, NULL, (LPBYTE)(LPSTR)OutValue, &dummy);
    		box_s = std::string(OutValue);
    		if (ret_val2==ERROR_SUCCESS)
    			return box_s;
    		if (ret_val2!=0)
    			return "";
    		return "";
    	}
    	bool SetString(HKEY BaseKey, const char * SubKeyName, const char * ValueName, LPSTR ValueString)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val2 = RegSetValueEx(result, ValueName, 0, REG_SZ, (BYTE*)ValueString, sizeof(ValueString)+1);
    		if (ret_val==ERROR_SUCCESS)
    			return true;
    		if (ret_val!=0)
    			return false;
    		return false;
    	}
    	bool SetString_S(HKEY BaseKey, std::string SubKeyName, std::string ValueName, std::string ValueString)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName.c_str(), 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		char dummyval[10000];
    		strcpy(dummyval, ValueString.c_str());
    		LONG ret_val2 = RegSetValueEx(result, ValueName.c_str(), 0, REG_SZ, (BYTE*)dummyval, sizeof(dummyval));
    		if (ret_val==ERROR_SUCCESS)
    			return true;
    		if (ret_val!=0)
    			return false;
    		return false;
    	}
    };
    ciao

  4. #4
    Utente di HTML.it L'avatar di Ifrit
    Registrato dal
    Oct 2005
    Messaggi
    116
    the programmer@ Ti ringrazio molto per il tuo lavoro, ma io il C++ non l'ho mai toccato, difatti non so ancora cosa sia una programmazione a oggetti... o cosa sia una classe...

    In qualsiasi caso vorrei capirle queste cose...

    Grazie ancora ^^ ciao
    codice:
     $(".canaglia").show()

  5. #5
    ok allora ti do la stessa classe un po' riadattata (molto)...
    questa classe è stata fatta in c++ proprio pechè questo linguaggio consentiva di facilitare molto le operazioni, ma anche in c dovrebbe facilitarti le cose.
    codice:
    //Registry class
    #include <winreg.h>
    
    //****************************************
    //Funzioni create da
    //*** Paolo Infante ***
    //L'uso di queste funzioni nelle vostre applicazioni e' garantito per fini personali e commerciali.
    //La distribuzione del sorgente di questa classe (o la vendita) sono ASSOLUTAMENTE proibiti //se non consentiti da Paolo Infante, e sono punibili a norma della legge sul Copyright.
    //
    //L'autore,
    //Paolo Infante.
    //****************************************
    
    	bool CreateKey(HKEY BaseKey, const char * SubKeyName, LPWORD dwOptions = REG_OPTION_NON_VOLATILE)
    	{
    		HKEY point_out;
    		DWORD result;
    		LONG ret_var = RegCreateKeyEx(BaseKey, SubKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &point_out, &result);
    		if (ret_var==ERROR_SUCCESS)
    			return true;
    		if (ret_var!=0)
    			return false;
    		return true;
    	}
    	
    	bool DeleteKey(HKEY BaseKey, const char * SubKeyName)
    	{
    		LONG ret_val = RegDeleteKey(BaseKey, SubKeyName);
    		if (ret_val==ERROR_SUCCESS)
    			return true;
    		if (ret_val != 0)
    			return false;
    		return false;
    	}
    	bool DeleteValue(HKEY BaseKey, const char * SubKeyName, const char * ValueName)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val_2 = RegDeleteValue(result, ValueName);
    		if (ret_val_2==ERROR_SUCCESS)
    			return true;
    		if (ret_val_2!=0)
    			return false;
    		return false;
    	}
    	bool QueryValue(HKEY BaseKey, const char * SubKeyName, const char * ValueName, LPDWORD outValueType, LPBYTE out_data, LPDWORD size_out_data)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val2 = RegQueryValueEx(result, ValueName, 0, outValueType, out_data, size_out_data);
    		if (ret_val2==ERROR_SUCCESS)
    			return true;
    		if (ret_val2!=0)
    			return false;
    		return false;
    	}
    	bool SetValue(HKEY BaseKey, const char * SubKeyName, const char * ValueName, DWORD ValueType, const BYTE * in_data)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val2 = RegSetValueEx(result, ValueName, 0, ValueType, in_data, sizeof(in_data));
    		if (ret_val==ERROR_SUCCESS)
    			return true;
    		if (ret_val!=0)
    			return false;
    		return false;
    	}
    	bool QueryString(HKEY BaseKey, const char * SubKeyName, const char * ValueName, LPSTR OutValue)	
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		DWORD dummy;
    		LONG ret_val2 = RegQueryValueEx(result, ValueName, 0, NULL, (LPBYTE)OutValue, &dummy);
    		if (ret_val2==ERROR_SUCCESS)
    			return true;
    		if (ret_val2!=0)
    			return false;
    		return false;
    	}
    	bool SetString(HKEY BaseKey, const char * SubKeyName, const char * ValueName, LPSTR ValueString)
    	{
    		HKEY result;
    		LONG ret_val = RegOpenKeyEx(BaseKey, SubKeyName, 0, KEY_ALL_ACCESS, &result);
    		if (ret_val != ERROR_SUCCESS)
    			return false;
    		LONG ret_val2 = RegSetValueEx(result, ValueName, 0, REG_SZ, (BYTE*)ValueString, sizeof(ValueString)+1);
    		if (ret_val==ERROR_SUCCESS)
    			return true;
    		if (ret_val!=0)
    			return false;
    		return false;
    	}
    non l'ho testata però dovrebbe funzionare. basta che la aggiungi ad un progetto C e poi ne richiami le varie funzioni.

    questo diciamo è un'indice delle funzioni racchiuse in questo file:
    codice:
    bool SetString(HKEY BaseKey, const char * SubKeyName, const char * ValueName, LPSTR ValueString)
    bool QueryString(HKEY BaseKey, const char * SubKeyName, const char * ValueName, LPSTR OutValue)	
    bool SetValue(HKEY BaseKey, const char * SubKeyName, const char * ValueName, DWORD ValueType, const BYTE * in_data)
    bool QueryValue(HKEY BaseKey, const char * SubKeyName, const char * ValueName, LPDWORD outValueType, LPBYTE out_data, LPDWORD size_out_data)
    bool DeleteValue(HKEY BaseKey, const char * SubKeyName, const char * ValueName)
    bool DeleteKey(HKEY BaseKey, const char * SubKeyName)
    bool CreateKey(HKEY BaseKey, const char * SubKeyName, LPWORD dwOptions = REG_OPTION_NON_VOLATILE)
    un'esempio:
    codice:
    #include <stdio.h>
    #include "RegClass.h"
    
    int main(void)
    {
    DeleteKey(HKEY_LOCAL_MACHINE, "\Software\Pippo");
    return 0;
    }
    ciao!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.