- remove unneeded cast in GetClipboardData

- use WideCharToMultiByte instead of RtlUnicodeStringToAnsiString
- fix memory leak in GetClipboardFormatNameA
- ReactOS now passes all user32_winetest.exe clipboard test (previously 2 failures)

svn path=/trunk/; revision=33610
This commit is contained in:
Johannes Anderwald 2008-05-20 13:42:17 +00:00
parent 7347f5ab15
commit 0b0ec52a01

View file

@ -93,7 +93,7 @@ GetClipboardData(UINT uFormat)
hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, size); hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, size);
pGlobal = GlobalLock(hGlobal); pGlobal = GlobalLock(hGlobal);
size = (DWORD)NtUserGetClipboardData(uFormat, (DWORD)pGlobal); size = (DWORD)NtUserGetClipboardData(uFormat, pGlobal);
GlobalUnlock(hGlobal); GlobalUnlock(hGlobal);
} }
@ -114,12 +114,7 @@ GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
{ {
LPWSTR lpBuffer; LPWSTR lpBuffer;
UNICODE_STRING FormatName; UNICODE_STRING FormatName;
ANSI_STRING FormatNameA;
INT Length; INT Length;
ANSI_STRING ClassName;
ClassName.MaximumLength = cchMaxCount;
ClassName.Buffer = lpszFormatName;
lpBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, cchMaxCount * sizeof(WCHAR)); lpBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, cchMaxCount * sizeof(WCHAR));
if (!lpBuffer) if (!lpBuffer)
@ -137,16 +132,16 @@ GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
if (Length != 0) if (Length != 0)
{ {
FormatNameA.Length = 0; if (!WideCharToMultiByte(CP_ACP, 0, lpBuffer, Length, lpszFormatName, cchMaxCount, NULL, NULL))
FormatNameA.MaximumLength = cchMaxCount; {
FormatNameA.Buffer = lpszFormatName; /* clear result string */
lpszFormatName[0] = '\0';
RtlUnicodeStringToAnsiString(&FormatNameA, &FormatName, FALSE); Length = 0;
}
return FormatNameA.Length;
} }
return 0; RtlFreeHeap(RtlGetProcessHeap(), 0, lpBuffer);
return Length;
} }
/* /*