Windows 注册表中的大括号是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4309766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:41:47  来源:igfitidea点击:

What do curly braces in the Windows registry mean?

windowsregistrycurly-braces

提问by Hyman

I've been wondering this for a while and can't seem to get answer.

我一直在想这个问题,似乎无法得到答案。

In Windows (maybe other places too), what do the curly braces mean? I'm guessing it has to do with hex but not sure.

在 Windows 中(也可能是其他地方),大括号是什么意思?我猜它与十六进制有关但不确定。

Any help would be appreciated.

任何帮助,将不胜感激。

*UPDATE

*更新

I'm sorry I wasn't as specific as I should have been. I was talking about in the registry, but I've also seen it in folder paths.

对不起,我没有像我应该的那样具体。我在注册表中讨论过,但我也在文件夹路径中看到过它。

回答by paxdiablo

You mean curly braces as in {}? They're just characters and you can pretty well assign any meaning you want to them, although they're more useful in "balancing" situations, the same as [], <>and ().

你的意思是大括号{}? 它们只是字符,您可以很好地为它们分配任何含义,尽管它们在“平衡”情况下更有用,与[],<>和相同()

Examples are:

例子是:

  • block delineation in certain programming languages:
    if (true) { do something }
  • array initialisers in certain programming languages:
    int x[] = { 1, 2, 3 };
  • formatted printing where they're replaced in a format string with actual arguments, something like:
    format ("My name is {1:s}{0:s}", "Diablo", "Pax");
  • Limiting the characters used in environment variable names in certain shells:
    echo ${name}Diablo
  • surrounding character for GUIDs:
    {3F2504E0-4F89-11D3-9A0C-0305E82C3301}
  • 某些编程语言中的块描述:
    if (true) { do something }
  • 某些编程语言中的数组初始值设定项:
    int x[] = { 1, 2, 3 };
  • 格式化打印,将它们替换为带有实际参数的格式字符串,例如:
    format ("My name is {1:s}{0:s}", "Diablo", "Pax");
  • 限制某些 shell 中环境变量名称中使用的字符:
    echo ${name}Diablo
  • GUID 的周围字符:
    {3F2504E0-4F89-11D3-9A0C-0305E82C3301}

There are no doubt dozens of other uses in other scenarios as well, those were just the ones that came immediately to mind.

毫无疑问,其他场景中还有数十种其他用途,这些只是我立即想到的那些。



Since you seem to be specifically asking about GUIDs (based on your comment), you can start here.

由于您似乎专门询问了 GUID(根据您的评论),您可以从这里开始。

回答by tchrist

  • Repetition in regular expressions: /a{3,5}/.

  • Anonymous hash composers in Perl: my $rec = { };. Also for dictionaries in Python.

  • Data assignments of structures or arrays in languages like C or Java: String data[] = { "TGF-βs", "XPTTD", "CIMPR", "CFU-F", "Qiagen", "BrdU-positive", "TSFLLRVYFQPGPPATAAPVPSPT", "Amersham", "DAPI-stained" };

  • Perl dereferencing operators: ${ $array_of_refs[17} }.

  • Hash subscripting in Perl: $ENV{USER}

  • Filename globbing in the shell: % echo {this,that,those,these}_{here,there,everywhere}produces this_here this_there this_everywhere that_here that_there that_everywhere those_here those_there those_everywhere these_here these_there these_everywhere

  • Hiding a semicolon in plain sight, since a CTRL-{is a ;. That's because the CONTROL-operation is an xorwith an @. \cCis @^C== chr(3), so \c{is @^{== chr(59) eq ";".

  • Balanced pick-your-own-quotes operators to avoid escaping slashes, like print if m{^/usr/local/bin}

  • History substitution disambiguating: “ !{v}docwould expand unambiguously to vi wumpus.mandoc

  • Unambiguous octal and hex escapes in strings, like "10\o{377}01"and "The \x{bee} character is TAMIL DIGIT EIGHT".

  • A symbol used in mathematics and music.

  • The name of particularly little-known variable in Perl: perl -le '$} = "eskimo"; print $}'prints eskimo!

  • 正则表达式中的重复:/a{3,5}/.

  • Perl 中的匿名哈希作曲家:my $rec = { };. 也适用于 Python 中的字典。

  • C 或 Java 等语言中结构或数组的数据分配: String data[] = { "TGF-βs", "XPTTD", "CIMPR", "CFU-F", "Qiagen", "BrdU-positive", "TSFLLRVYFQPGPPATAAPVPSPT", "Amersham", "DAPI-stained" };

  • Perl 解引用运算符:${ $array_of_refs[17} }.

  • Perl 中的哈希下标: $ENV{USER}

  • shell 中的文件名通配: % echo {this,that,those,these}_{here,there,everywhere}产生this_here this_there this_everywhere that_here that_there that_everywhere those_here those_there those_everywhere these_here these_there these_everywhere

  • 隐藏分号,因为 aCTRL-{是 a ;。那是因为该CONTROL-操作是xor带有@. \cC@^C== chr(3),所以\c{@^{== chr(59) eq ";"

  • 平衡的pick-your-own-quotes操作符以避免转义斜杠,比如 print if m{^/usr/local/bin}

  • 历史替换消歧:“!{v}doc将明确地扩展为vi wumpus.mandoc

  • 字符串中明确的八进制和十六进制转义,例如"10\o{377}01""The \x{bee} character is TAMIL DIGIT EIGHT"

  • 数学和音乐中使用的符号。

  • Perl 中特别鲜为人知的变量名称:perl -le '$} = "eskimo"; print $}'打印eskimo!

回答by dValue

Depends on the usage.

取决于使用情况。

In C# {0}is a placeholder; it gets replaced with the value that follows the quoted text, i.e.:

在 C# 中{0}是一个占位符;它被引用的文本后面的值替换,即:

Console.WriteLine("Radius = {0}, PI = {1}", radius, PI);

Note that the first place holder is always a 0, the next usage is 1, etc...

请注意,第一个占位符始终为 0,下一个用法为 1,依此类推...

回答by What's in a Google Search

The symbols { }, are used in computer programs for showing that things written between them should be considered together. Certainly this is the current dictionary definition.

符号 { } 在计算机程序中用于表示应该一起考虑写在它们之间的东西。当然,这是当前的字典定义

And as such probably represents the most authoritative overalldefinition you're likely to get, though the other answers have dealt with more specific use cases.

因此,尽管其他答案涉及更具体的用例,但它可能代表了您可能获得的最权威的总体定义。

回答by Maxpm

In programming, curly braces are used for a lot of different things. Different languages use them in completely different contexts.

在编程中,花括号用于许多不同的事情。不同的语言在完全不同的上下文中使用它们。

If you're talking about program flow in C++, I like to think of them as tiers that progressively get more specific. Example:

如果您在谈论 C++ 中的程序流,我喜欢将它们视为逐渐变得更加具体的层。例子:

string myName = "Max";

if (myName[0] == 'M') // If the first letter of myName is M...
{
    cout << "The first letter is M." << endl;

    if (myName.length() == 3) // If myName is three characters long...
    {
        cout << "myName is three chars long." << endl;

        if(myName[2] == 'x') // If the third letter is x...
        {
             cout << "The third letter is x." << endl;
        }
    }
}

They're also used in array assignment in C++, like so:

它们也用于 C++ 中的数组赋值,如下所示:

int myArray[5] = {1, 2, 3, 4, 5};

int myArray[5] = {1, 2, 3, 4, 5};

There are other uses, but these two are probably the most common.

还有其他用途,但这两种可能是最常见的。