oleacc: Add GetProcessHandleFromHwnd implementation.

This commit is contained in:
Piotr Caban 2014-05-03 14:27:35 +02:00 committed by Alexandre Julliard
parent 8192f54998
commit d8467aee74
3 changed files with 40 additions and 0 deletions

View File

@ -332,6 +332,18 @@ void WINAPI GetOleaccVersionInfo(DWORD* pVersion, DWORD* pBuild)
*pBuild = MAKELONG(0,0);
}
HANDLE WINAPI GetProcessHandleFromHwnd(HWND hwnd)
{
DWORD proc_id;
TRACE("%p\n", hwnd);
if(!GetWindowThreadProcessId(hwnd, &proc_id))
return NULL;
return OpenProcess(PROCESS_DUP_HANDLE | PROCESS_VM_OPERATION |
PROCESS_VM_READ | PROCESS_VM_WRITE | SYNCHRONIZE, TRUE, proc_id);
}
UINT WINAPI GetRoleTextW(DWORD role, LPWSTR lpRole, UINT rolemax)
{
INT ret;

View File

@ -9,6 +9,7 @@
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()
@ stdcall GetOleaccVersionInfo(ptr ptr)
@ stdcall GetProcessHandleFromHwnd(ptr)
@ stdcall GetRoleTextA(long ptr long)
@ stdcall GetRoleTextW(long ptr long)
@ stub GetStateTextA

View File

@ -279,6 +279,32 @@ static void test_AccessibleObjectFromWindow(void)
DestroyWindow(hwnd);
}
static void test_GetProcessHandleFromHwnd(void)
{
HANDLE (WINAPI *pGetProcessHandleFromHwnd)(HWND);
HANDLE proc;
HWND hwnd;
pGetProcessHandleFromHwnd = (void*)GetProcAddress(
GetModuleHandleA("oleacc.dll"), "GetProcessHandleFromHwnd");
if(!pGetProcessHandleFromHwnd) {
win_skip("GetProcessHandleFromHwnd not available\n");
return;
}
proc = pGetProcessHandleFromHwnd(NULL);
ok(!proc, "proc = %p\n", proc);
hwnd = CreateWindowA("static", "", 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
ok(hwnd != NULL, "CreateWindow failed\n");
proc = pGetProcessHandleFromHwnd(hwnd);
ok(proc != NULL, "proc == NULL\n");
CloseHandle(proc);
DestroyWindow(hwnd);
}
static void test_default_client_accessible_object(void)
{
static const WCHAR testW[] = {'t','e','s','t',' ','t',' ','&','j','u','n','k',0};
@ -417,6 +443,7 @@ START_TEST(main)
test_getroletext();
test_LresultFromObject(argv[0]);
test_AccessibleObjectFromWindow();
test_GetProcessHandleFromHwnd();
test_default_client_accessible_object();
unregister_window_class();