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