1*fc0bc008SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*fc0bc008SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*fc0bc008SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*fc0bc008SAndrew Rist  * distributed with this work for additional information
6*fc0bc008SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*fc0bc008SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*fc0bc008SAndrew Rist  * "License"); you may not use this file except in compliance
9*fc0bc008SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*fc0bc008SAndrew Rist  *
11*fc0bc008SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*fc0bc008SAndrew Rist  *
13*fc0bc008SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*fc0bc008SAndrew Rist  * software distributed under the License is distributed on an
15*fc0bc008SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*fc0bc008SAndrew Rist  * KIND, either express or implied.  See the License for the
17*fc0bc008SAndrew Rist  * specific language governing permissions and limitations
18*fc0bc008SAndrew Rist  * under the License.
19*fc0bc008SAndrew Rist  *
20*fc0bc008SAndrew Rist  *************************************************************/
21*fc0bc008SAndrew Rist 
22*fc0bc008SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir {
25cdf0e10cSrcweir 	HKEY	hkeyLogon;
26cdf0e10cSrcweir 	HKEY	hkeyWorkgroup;
27cdf0e10cSrcweir 	DWORD	dwResult = 0;
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 	if ( ERROR_SUCCESS  == RegOpenKeyEx(
31cdf0e10cSrcweir 		HKEY_LOCAL_MACHINE,
32cdf0e10cSrcweir 		TEXT("Network\\Logon"),
33cdf0e10cSrcweir 		0, KEY_READ, &hkeyLogon ) )
34cdf0e10cSrcweir 	{
35cdf0e10cSrcweir 		DWORD	dwLogon = 0;
36cdf0e10cSrcweir 		DWORD	dwLogonSize = sizeof(dwLogon);
37cdf0e10cSrcweir 		RegQueryValueEx( hkeyLogon, TEXT("LMLogon"), 0, NULL, (LPBYTE)&dwLogon, &dwLogonSize );
38cdf0e10cSrcweir 		RegCloseKey( hkeyLogon );
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 		if ( dwLogon )
41cdf0e10cSrcweir 		{
42cdf0e10cSrcweir 			HKEY	hkeyNetworkProvider;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 			if ( ERROR_SUCCESS  == RegOpenKeyEx(
45cdf0e10cSrcweir 				HKEY_LOCAL_MACHINE,
46cdf0e10cSrcweir 				TEXT("SYSTEM\\CurrentControlSet\\Services\\MSNP32\\NetworkProvider"),
47cdf0e10cSrcweir 				0, KEY_READ, &hkeyNetworkProvider ) )
48cdf0e10cSrcweir 			{
49cdf0e10cSrcweir 				DWORD	dwBufferSize = nSize;
50cdf0e10cSrcweir 				LONG	lResult = RegQueryValueEx( hkeyNetworkProvider, TEXT("AuthenticatingAgent"), 0, NULL, (LPBYTE)lpBuffer, &dwBufferSize );
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 				if ( ERROR_SUCCESS == lResult || ERROR_MORE_DATA == lResult )
53cdf0e10cSrcweir 					dwResult = dwBufferSize / sizeof(TCHAR);
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 				RegCloseKey( hkeyNetworkProvider );
56cdf0e10cSrcweir 			}
57cdf0e10cSrcweir 		}
58cdf0e10cSrcweir 	}
59cdf0e10cSrcweir 	else if ( ERROR_SUCCESS == RegOpenKeyEx(
60cdf0e10cSrcweir 		HKEY_LOCAL_MACHINE,
61cdf0e10cSrcweir 		TEXT("SYSTEM\\CurrentControlSet\\Services\\VxD\\VNETSUP"),
62cdf0e10cSrcweir 		0, KEY_READ, &hkeyWorkgroup ) )
63cdf0e10cSrcweir 	{
64cdf0e10cSrcweir 		DWORD	dwBufferSize = nSize;
65cdf0e10cSrcweir 		LONG	lResult = RegQueryValueEx( hkeyWorkgroup, TEXT("Workgroup"), 0, NULL, (LPBYTE)lpBuffer, &dwBufferSize );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 		if ( ERROR_SUCCESS == lResult || ERROR_MORE_DATA == lResult )
68cdf0e10cSrcweir 			dwResult = dwBufferSize / sizeof(TCHAR);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 		RegCloseKey( hkeyWorkgroup );
71cdf0e10cSrcweir 	}
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	return dwResult;
75cdf0e10cSrcweir }
76