如何将 VBA long &HFFFFFFF0 转换为 uint 以便在 C# 中使用?

How do I convert the VBA long &HFFFFFFF0 to a uint for use in C#?

我见过几个对我有用的例子。所以我想问一个新问题。我特别尝试使用 oleacc.dll.

中的 AccessibleObjectFromWindow 方法

我在 Access VBA 中有一个由其他人编写的函数版本,我正在尝试将其移植到 C#。

有问题的代码是:

    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) 不起作用。我知道我在这里做错了什么,我不知道那到底是什么。在 VBA 中,我认为与号表示长。但是,我对这种事情还不太熟悉。任何帮助,将不胜感激。我现在得到一个异常,无论我尝试将此值转换为 uint 的方式。

只需从字符串中删除 &H。 VBA 使用它来指示 "this is a hex value" 但它不是 C# 可以解释的有效十六进制字符串的一部分。

Convert.ToUInt32("FFFFFFF0", 16)