Share via

C# - Get workgroup name

Anonymous
2024-07-11T15:24:19+00:00

Using Visual Studio 2010.

I tried both of these on Windows XP:

string workgroupName = Environment.GetEnvironmentVariable("UserDomainName");

string workgroupName = (string)Registry.GetValue(key1, "Workgroup", null);

The first gives me the computer name.

The second is blank.

Please suggest a solution that will work on all versions of Windows.

Windows for home | Previous Windows versions | Apps

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-07-11T20:11:34+00:00

    Using Visual Studio 2010.

    I tried both of these on Windows XP:

    string workgroupName = Environment.GetEnvironmentVariable("UserDomainName");

    string workgroupName = (string)Registry.GetValue(key1, "Workgroup", null);

    The first gives me the computer name.

    The second is blank.

    Please suggest a solution that will work on all versions of Windows.

    Your question is outside the scope of this Community.

    And the Visual Studio forums have migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

    Visual Studio on Q&A

    https://docs.microsoft.com/en-us/answers/products/vs

    Was this answer helpful?

    0 comments No comments