-
大小: 3KB文件类型: .cpp金币: 1下载: 0 次发布日期: 2021-05-10
- 语言: C/C++
- 标签: IAccessible MSAA DirectUI
资源简介
代码提供了IAccessible接口示例,获取DirectUI窗口信息
代码片段和文件信息
/*有些窗口为Dectui制作,使用SPY获取不到窗口句柄,解决办法使用MSAA中的IAccessible接口获取*/
#include
#include se.h>
CComModule _Module;
#include
#include
#include
#include
//系统API相关头文件
#include
#include
#include
#include “Shlwapi.h“
#include
#pragma comment(lib“shlwapi.lib“)
#pragma comment(lib“oleacc.lib“)
#include
using namespace std;
//名称
HRESULT PrintName(IAccessible* pAcc long childId)
{
if (pAcc == NULL)
{
return E_INVALIDARG;
}
BSTR bstrName;
VARIANT varChild;
varChild.vt = VT_I4;
varChild.lVal = childId;
HRESULT hr = pAcc->get_accName(varChild &bstrName);
printf(“Name: %S “ bstrName);
//printf(“Value: %S “ bstrName);
SysFreeString(bstrName);
return hr;
}
/*角色*/
HRESULT PrintRole(IAccessible* pAcc long childId)
{
DWORD roleId;
if (pAcc == NULL)
{
return E_INVALIDARG;
}
VARIANT varChild;
BSTR bstrName;
varChild.vt = VT_I4;
varChild.lVal = childId;
VARIANT varResult;
HRESULT hr = pAcc->get_accRole(varChild &varResult);
pAcc->get_accValue(varChild &bstrName);
printf(“value: %S “ bstrName);
if ((hr == S_OK) && (varResult.vt == VT_I4))
{
roleId = varResult.lVal;
UINT roleLength;
LPTSTR lpszRoleString;
roleLength = GetRoleText(roleId NULL 0);
lpszRoleString = (LPTSTR)malloc((roleLength + 1) * sizeof(TCHAR));
if (lpszRoleString != NULL)
{
GetRoleText(roleId lpszRoleString roleLength + 1);
#ifdef UNICODE
printf(“Role: %S\n“ lpszRoleString);
#else
printf(“Role: %s\n“ lpszRoleString);
#endif
free(lpszRoleString);
}
else
- 上一篇:C++扫雷游戏最全源代码
- 下一篇:C++实现数据库DBMS建表插入删除属性功能
评论
共有 条评论