I've seen few examples that work for me. So I wanted to ask a new question. I am specifically trying to use the AccessibleObjectFromWindow method from oleacc.dll.
I have a version of a function, written by someone else, in Access VBA that I am trying to port to C#.
the code in question is:
public static bool GetReferenceToApplication(long hWndXL, out object oApplication)
{
oApplication = null;
long hWinDesk = (long)FindWindowEx(new IntPtr(hWndXL), new IntPtr(0), "XLDESK", string.Empty);
long hWin7 = (long)FindWindowEx(new IntPtr(hWinDesk), new IntPtr(0), "EXCEL7", string.Empty);
Guid guid = new Guid("00020400-0000-0000-C000-000000000046");
object obj = null;
if (AccessibleObjectFromWindow(new IntPtr(hWin7), Convert.ToUInt32("&HFFFFFFF0", 16), ref guid, ref obj) == RETURN_OK)
{
oApplication = obj;
return true;
}
else return false;
}
Convert.ToUInt32("&HFFFFFFF0", 16) does not work. I know I am doing something wrong here, I do not know what exactly that is. In VBA, I think the ampersand denotes a long. But, I'm not too familiar with this sort of thing yet. Any help would be appreciated. I get an exception now matter which way I try to convert this value to a uint.