Added GetCurrentHwProfileA.
[wine.git] / dlls / advapi32 / advapi.c
blob5496205e78e29beb609b975bd825393de39062fd
1 /*
2 * Win32 advapi functions
4 * Copyright 1995 Sven Verdoolaege
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <errno.h>
25 #include <stdio.h>
26 #include <unistd.h>
27 #include <string.h>
28 #include <pwd.h>
30 #include "winbase.h"
31 #include "windef.h"
32 #include "winnls.h"
33 #include "winerror.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
39 /******************************************************************************
40 * GetUserNameA [ADVAPI32.@]
42 * NOTE: lpSize returns the total length of the username, including the
43 * terminating null character.
45 BOOL WINAPI
46 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
48 size_t len;
49 char *name;
51 struct passwd *pwd = getpwuid( getuid() );
52 if (!pwd)
54 ERR("Username lookup failed: %s\n", strerror(errno));
55 return 0;
58 name = pwd->pw_name;
60 /* We need to include the null character when determining the size of the buffer. */
61 len = strlen(name) + 1;
62 if (len > *lpSize)
64 SetLastError(ERROR_MORE_DATA);
65 *lpSize = len;
66 return 0;
69 *lpSize = len;
70 strcpy(lpszName, name);
71 return 1;
74 /******************************************************************************
75 * GetUserNameW [ADVAPI32.@]
77 * PARAMS
78 * lpszName []
79 * lpSize []
81 BOOL WINAPI
82 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
84 LPSTR name = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpSize );
85 DWORD size = *lpSize;
86 BOOL res = GetUserNameA(name,lpSize);
88 /* FIXME: should set lpSize in WCHARs */
89 if (size && !MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, size ))
90 lpszName[size-1] = 0;
91 HeapFree( GetProcessHeap(), 0, name );
92 return res;
95 /******************************************************************************
96 * GetCurrentHwProfileA [ADVAPI32.@]
98 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA info)
100 FIXME("Mostly Stub\n");
101 info->dwDockInfo = DOCKINFO_DOCKED;
102 strcpy(info->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
103 strcpy(info->szHwProfileName,"Wine Profile");
104 return 1;
107 /******************************************************************************
108 * AbortSystemShutdownA [ADVAPI32.@]
110 * PARAMS
111 * lpMachineName
113 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
115 TRACE("stub %s (harmless)\n", lpMachineName);
116 return TRUE;
119 /******************************************************************************
120 * AbortSystemShutdownW [ADVAPI32.@]
122 * PARAMS
123 * lpMachineName
125 BOOL WINAPI AbortSystemShutdownW( LPCWSTR lpMachineName )
127 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
128 return TRUE;