Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How do I write large uint to a registry dword value?

How do I write large uint to a registry dword value?

Scheduled Pinned Locked Moved C#
helpquestionwindows-admin
3 Posts 2 Posters 0 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mike Poz
    wrote on last edited by
    #1

    This is what I'm trying to do: Target value is 0xffffff9d, which translates to 4294967197 decimal, which is why it needs to be an unsigned int. Unfortunately whenver I attempt to do this, it spawns an overflow exception. Two lines of code that matter: RegistryKey TargetKeyNode = Registry.LocalMachine.OpenSubKey(TargetPath, true); TargetKeyNode.SetValue(TargetKeyName, TargetValue, RegistryValueKind.DWord); As a brute force method, I've tried creating the target key as a dword with a zero value and then stuffing in the needed value using RegistryValueKind.Unknown, but that simply changes the key type to a string. I also tried setting the value this way &Hffffff9dI (along with every possible variation of that) as was suggested for someone else on another website but I get an error "The name &Hffffff9dI does not exist in the current context" on build. Can anyone please help me with this? Thanks in advance for any help.

    Mike Poz

    G 1 Reply Last reply
    0
    • M Mike Poz

      This is what I'm trying to do: Target value is 0xffffff9d, which translates to 4294967197 decimal, which is why it needs to be an unsigned int. Unfortunately whenver I attempt to do this, it spawns an overflow exception. Two lines of code that matter: RegistryKey TargetKeyNode = Registry.LocalMachine.OpenSubKey(TargetPath, true); TargetKeyNode.SetValue(TargetKeyName, TargetValue, RegistryValueKind.DWord); As a brute force method, I've tried creating the target key as a dword with a zero value and then stuffing in the needed value using RegistryValueKind.Unknown, but that simply changes the key type to a string. I also tried setting the value this way &Hffffff9dI (along with every possible variation of that) as was suggested for someone else on another website but I get an error "The name &Hffffff9dI does not exist in the current context" on build. Can anyone please help me with this? Thanks in advance for any help.

      Mike Poz

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      You can cast the uint value to int, without losing data. The int value will be negative, but having the same bit pattern.

      --- b { font-weight: normal; }

      M 1 Reply Last reply
      0
      • G Guffa

        You can cast the uint value to int, without losing data. The int value will be negative, but having the same bit pattern.

        --- b { font-weight: normal; }

        M Offline
        M Offline
        Mike Poz
        wrote on last edited by
        #3

        Thank you very much, that worked exactly as you said. Never though of the old "wrap around" trick. Thanks again! :-D:cool:

        Mike Poz

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups