merge the formfield patch from ooo-build
[ooovba.git] / sal / systools / win32 / uwinapi / GetUserDomain_WINDOWS.cpp
blob4a7a2206699b57ebe2012e5e8fb3606c0d2a10ce
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: GetUserDomain_WINDOWS.cpp,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 HKEY hkeyLogon;
33 HKEY hkeyWorkgroup;
34 DWORD dwResult = 0;
37 if ( ERROR_SUCCESS == RegOpenKeyEx(
38 HKEY_LOCAL_MACHINE,
39 TEXT("Network\\Logon"),
40 0, KEY_READ, &hkeyLogon ) )
42 DWORD dwLogon = 0;
43 DWORD dwLogonSize = sizeof(dwLogon);
44 RegQueryValueEx( hkeyLogon, TEXT("LMLogon"), 0, NULL, (LPBYTE)&dwLogon, &dwLogonSize );
45 RegCloseKey( hkeyLogon );
47 if ( dwLogon )
49 HKEY hkeyNetworkProvider;
51 if ( ERROR_SUCCESS == RegOpenKeyEx(
52 HKEY_LOCAL_MACHINE,
53 TEXT("SYSTEM\\CurrentControlSet\\Services\\MSNP32\\NetworkProvider"),
54 0, KEY_READ, &hkeyNetworkProvider ) )
56 DWORD dwBufferSize = nSize;
57 LONG lResult = RegQueryValueEx( hkeyNetworkProvider, TEXT("AuthenticatingAgent"), 0, NULL, (LPBYTE)lpBuffer, &dwBufferSize );
59 if ( ERROR_SUCCESS == lResult || ERROR_MORE_DATA == lResult )
60 dwResult = dwBufferSize / sizeof(TCHAR);
62 RegCloseKey( hkeyNetworkProvider );
66 else if ( ERROR_SUCCESS == RegOpenKeyEx(
67 HKEY_LOCAL_MACHINE,
68 TEXT("SYSTEM\\CurrentControlSet\\Services\\VxD\\VNETSUP"),
69 0, KEY_READ, &hkeyWorkgroup ) )
71 DWORD dwBufferSize = nSize;
72 LONG lResult = RegQueryValueEx( hkeyWorkgroup, TEXT("Workgroup"), 0, NULL, (LPBYTE)lpBuffer, &dwBufferSize );
74 if ( ERROR_SUCCESS == lResult || ERROR_MORE_DATA == lResult )
75 dwResult = dwBufferSize / sizeof(TCHAR);
77 RegCloseKey( hkeyWorkgroup );
81 return dwResult;