Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6575593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:24:22+00:00 2026-05-25T15:24:22+00:00

as far as I know strings (REG_SZ) created in the windows registry must be

  • 0

as far as I know strings (REG_SZ) created in the windows registry must be terminated with a 0-Byte.
But what happens if you want to create programatically a registry value with no content?

a) always terminate with 0-Byte (doesn’t matter if the registry value has content or not)

b) terminate only with 0-Byte if there is a content

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:24:22+00:00Added an answer on May 25, 2026 at 3:24 pm

    You must always terminate the value with a null character. If there is no content, then the value will be that one null character and nothing else.

    Note that a character is either one or two bytes long, depending on whether you are using the ANSI or Unicode APIs.

    Update: The documentation for RegSetValueEx states regarding its last parameter:

    The size of the information pointed to by the lpData parameter, in
    bytes. If the data is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ,
    cbData must include the size of the terminating null character or
    characters.

    The registry value types reference also says:

    String Values

    If data has the REG_SZ, REG_MULTI_SZ, or REG_EXPAND_SZ type, the
    string may not have been stored with the proper terminating null
    characters. Therefore, when reading a string from the registry, you
    must ensure that the string is properly terminated before using it;
    otherwise, it may overwrite a buffer. (Note that REG_MULTI_SZ strings
    should have two terminating null characters.)

    When writing a string to the registry, you must specify the length of
    the string, including the terminating null character (\0). A common
    error is to use the strlen function to determine the length of the
    string, but to forget that strlen returns only the number of
    characters in the string, not including the terminating null.
    Therefore, the length of the string should be calculated as follows:
    strlen( string ) + 1

    Now all this is not as clear as it could be, but it is well known that a null terminator in Unicode strings is actually two bytes (as is every other Unicode character in the BMP).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As far as I know arrays are allocated statically but strings are dynamic as
As far as know, I must be careful with PHP, and I think Javascript.
As far as I know, only the convenience methods return created objects with an
I have created two enums and I know they are not the same but
As far as I know, strings are immutable in Delphi. I kind of understand
I know other questions have been asked on this but none so far have
As far as I know, foreign keys (FK) are used to aid the programmer
As far as I know, Flash has to pass info off to another external
As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...)
As far as i know it is not possible to do the following in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.