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