C++ 如何初始化Iaccessible接口的accloation()方法中的参数?

C++ 如何初始化Iaccessible接口的accloation()方法中的参数?,c++,com,C++,Com,我尝试使用Iaccessible接口的accLocation方法检索元素的屏幕位置,但无法启动该方法的参数 IAccessible *plocation; long *x; long *y; long *width; long *height; VARIANT varChild; varChild.vt = VT_I4; varChild.iVal = CHILDID_SELF; hr = pIaccessible->GetIAccessible(&plocation); hr

我尝试使用Iaccessible接口的accLocation方法检索元素的屏幕位置,但无法启动该方法的参数

IAccessible *plocation;
long *x;
long *y;
long *width;
long *height;

VARIANT varChild;
varChild.vt = VT_I4;
varChild.iVal = CHILDID_SELF;

hr = pIaccessible->GetIAccessible(&plocation);
hr = plocation->accLocation(x, y, width, height, varChild);
但当我运行它时,错误消息如下所示:

    uninitialized local variable 'x'used,
    uninitialized local variable 'y'used,
    uninitialized local variable 'width'used,
    uninitialized local variable 'height'used

我有一种感觉,你需要使用:

long x;
long y;
long width;
long height;

...

// Pass the addresses of objects where the values can be stored.
hr = plocation->accLocation(&x, &y, &width, &height, varChild);

您将作为参数提供给plocation->accLocation未初始化指针。如果它们是输出参数,则应该预先在堆或堆栈上分配它们。