Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Read/Write windows registry [SOLVED]

    SDK Help
    0
    4
    389
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            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();   
            }   
              
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post