mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 01:23:37 +00:00
advapi32/service: Forward GetServiceDisplayNameA to GetServiceDisplayNameW.
This commit is contained in:
parent
23d61ac866
commit
95d2f04611
|
@ -2266,45 +2266,50 @@ BOOL WINAPI QueryServiceLockStatusW( SC_HANDLE hSCManager,
|
|||
BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
|
||||
LPSTR lpDisplayName, LPDWORD lpcchBuffer)
|
||||
{
|
||||
struct sc_manager *hscm;
|
||||
DWORD type, size;
|
||||
LONG ret;
|
||||
LPWSTR lpServiceNameW, lpDisplayNameW = NULL;
|
||||
DWORD size, sizeW, GLE;
|
||||
BOOL ret;
|
||||
|
||||
TRACE("%p %s %p %p\n", hSCManager,
|
||||
debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer);
|
||||
|
||||
hscm = sc_handle_get_handle_data(hSCManager, SC_HTYPE_MANAGER);
|
||||
if (!hscm)
|
||||
lpServiceNameW = SERV_dup(lpServiceName);
|
||||
lpDisplayNameW = HeapAlloc(GetProcessHeap(), 0, *lpcchBuffer * sizeof(WCHAR));
|
||||
|
||||
size = sizeW = *lpcchBuffer;
|
||||
ret = GetServiceDisplayNameW(hSCManager, lpServiceNameW,
|
||||
lpDisplayName ? lpDisplayNameW : NULL,
|
||||
&sizeW);
|
||||
/* Last error will be set by GetServiceDisplayNameW and must be preserved */
|
||||
GLE = GetLastError();
|
||||
|
||||
if (!lpDisplayName && lpcchBuffer && !ret && (GLE == ERROR_INSUFFICIENT_BUFFER))
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
/* Request for buffersize.
|
||||
*
|
||||
* Only set the size for ERROR_INSUFFICIENT_BUFFER
|
||||
*/
|
||||
size = sizeW * 2;
|
||||
}
|
||||
else if (lpDisplayName && lpcchBuffer && !ret)
|
||||
{
|
||||
/* Request for displayname.
|
||||
*
|
||||
* size only has to be set if this fails
|
||||
*/
|
||||
size = sizeW * 2;
|
||||
}
|
||||
|
||||
if (!lpServiceName)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_ADDRESS);
|
||||
return FALSE;
|
||||
}
|
||||
WideCharToMultiByte(CP_ACP, 0, lpDisplayNameW, (sizeW + 1), lpDisplayName,
|
||||
*lpcchBuffer, NULL, NULL );
|
||||
|
||||
size = *lpcchBuffer;
|
||||
ret = RegGetValueA(hscm->hkey, lpServiceName, "DisplayName", RRF_RT_REG_SZ, &type, lpDisplayName, &size);
|
||||
if (!ret && !lpDisplayName && size)
|
||||
ret = ERROR_MORE_DATA;
|
||||
*lpcchBuffer = size;
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (lpDisplayName && *lpcchBuffer) *lpDisplayName = 0;
|
||||
HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
|
||||
SERV_free(lpServiceNameW);
|
||||
|
||||
if (ret == ERROR_MORE_DATA)
|
||||
{
|
||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||
*lpcchBuffer = size - 1;
|
||||
}
|
||||
else
|
||||
SetLastError(ret);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
SetLastError(GLE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
@ -459,24 +459,19 @@ static void test_get_displayname(void)
|
|||
SetLastError(0xdeadbeef);
|
||||
displaysize = (tempsize / 2) + 1;
|
||||
ret = GetServiceDisplayNameA(scm_handle, spooler, displayname, &displaysize);
|
||||
todo_wine
|
||||
{
|
||||
ok(ret, "Expected success\n");
|
||||
ok(displaysize == ((tempsize / 2) + 1), "Expected no change for the needed buffer size\n");
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
}
|
||||
|
||||
/* Now with the original returned size */
|
||||
SetLastError(0xdeadbeef);
|
||||
displaysize = tempsize;
|
||||
ret = GetServiceDisplayNameA(scm_handle, spooler, displayname, &displaysize);
|
||||
todo_wine
|
||||
ok(ret, "Expected success\n");
|
||||
ok(displaysize == tempsize, "Expected no change for the needed buffer size\n");
|
||||
todo_wine
|
||||
ok(GetLastError() == ERROR_SUCCESS /* W2K3 */ ||
|
||||
GetLastError() == ERROR_IO_PENDING /* W2K */ ||
|
||||
GetLastError() == 0xdeadbeef /* NT4, XP, Vista */,
|
||||
|
@ -493,7 +488,6 @@ static void test_get_displayname(void)
|
|||
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
|
||||
/* Test that shows that if the buffersize is enough, it's not changed */
|
||||
ok(displaysize == tempsize * 2, "Expected no change for the needed buffer size\n");
|
||||
todo_wine
|
||||
ok(lstrlen(displayname) == tempsize/2,
|
||||
"Expected the buffer to be twice the length of the string\n") ;
|
||||
|
||||
|
@ -538,9 +532,9 @@ static void test_get_displayname(void)
|
|||
ok(displaysize == tempsizeW, "Expected the needed buffersize\n");
|
||||
ok(lstrlenW(displaynameW) == displaysize,
|
||||
"Expected the buffer to be the length of the string\n") ;
|
||||
}
|
||||
ok(tempsize / 2 == tempsizeW,
|
||||
"Expected the needed buffersize (in bytes) to be the same for the A and W call\n");
|
||||
}
|
||||
|
||||
CloseServiceHandle(scm_handle);
|
||||
|
||||
|
|
Loading…
Reference in a new issue