Read/Write windows registry [SOLVED]
-
On 26/05/2016 at 07:45, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 17
Platform: Windows ;
Language(s) : C++ ;---------
Hi, is there anything already available in the SDK, that allows one to read/write windows registry values?
If not, is there a preferred way of doing so? -
On 26/05/2016 at 09:30, xxxxxxxx wrote:
I don' think there's anything for this in the SDK.
The typical C++ code for this is:
RegOpenKeyEx(), RegGetValue(), RegSetKeyValue(), and don't forget to RegCloseKey()But please don't do this in plugins for sale!!!!
I need to format my HD at least 4 times a year because of people dumping tons of garbage in my registry.Create a folder in your plugin's folder structure to hold any persistent data. So it get's deleted automatically if the user deletes your plugin.
Please...Don't do it.-ScottA
-
On 26/05/2016 at 10:16, xxxxxxxx wrote:
In the SDK, you have:
ReadRegInfo() and WriteRegInfo()
SetWorldContainer() and GetWorldContainer()These might be more useful alternatives to using the Windows registry.
-
On 26/05/2016 at 11:25, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I don' think there's anything for this in the SDK.The typical C++ code for this is: RegOpenKeyEx(), RegGetValue(), RegSetKeyValue(), and don't forget to RegCloseKey()But please don't do this in plugins for sale!!!!I need to format my HD at least 4 times a year because of people dumping tons of garbage in my registry.Create a folder in your plugin's folder structure to hold any persistent data. So it get's deleted automatically if the user deletes your plugin.Please...Don't do it.-ScottA
Don't worry, it's not used for my plugins! I strongly stick to Maxons guidelines.
It's need to detect an external aplication and optionally set its parameters.
If you're interested, here's the first prototype I came up with:
inline std::string QueryRegistryValue(HKEY hKey, const LPCWSTR subKey, const char* keyName) { HKEY hKeyResult; WCHAR buffer[512]; DWORD buffer_size = SIZEOF(buffer); if (RegOpenKeyExW(hKey, reinterpret_cast<LPCWSTR>(subKey), 0, KEY_READ, &hKeyResult;) == ERROR_SUCCESS) { if (RegQueryValueExA(hKeyResult, keyName, nullptr, nullptr, reinterpret_cast<LPBYTE>(buffer), &buffer;_size) == ERROR_SUCCESS) { RegCloseKey(hKeyResult); return std::string(reinterpret_cast<char*>(buffer)); } RegCloseKey(hKeyResult); } return std::string(); }