使用AMD ADL在C#中获取监视器EDID

时间:2013-10-24 17:00:59

标签: c# amd-processor edid

我正在使用AMD ADL来枚举和操作附加到我系统的显示器。我需要的一个必要功能是能够读取和解析显示EDID。我能够解析EDID的字节数组表示,但是我无法获取EDID。基于ADL文档,我定义了ADLDisplayEDIDData结构并导入了ADL_Display_EdidData_Get函数。但是,任何执行我的代码都会导致retvalue -3错误。此重估值表示无效参数。

EDIDData结构:

[StructLayout(LayoutKind.Sequential)]
internal struct ADLDisplayEDIDData
{
    internal int Size;
    internal int Flag;
    internal int EDIDSize;
    internal int BlockIndex;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 255)]
    internal byte[] EDIDData;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
    internal int[] Reserved;
}

DLLImport:

[DllImport(Atiadlxx_FileName)]
internal static extern int ADL_Display_EdidData_Get(int adapterIndex, int displayIndex, ref ADLDisplayEDIDData EDIDData);

我的声明有错误吗?有没有人对ADL有任何经验并获得EDID信息?

提前谢谢。

1 个答案:

答案 0 :(得分:0)

试试这个:

[DllImport(Atiadlxx_FileName)]
internal static extern int ADL_Display_EdidData_Get(int adapterIndex, int displayIndex, [In, Out] ADLDisplayEDIDData[] EDIDData);

ADLDisplayEDIDData[] EDID = new ADLDisplayEDIDData[2];
NVGetMonitorEDIDs(0, EDID);

最好将维度长度传递给c ++,如下所示:

[DllImport(Atiadlxx_FileName)]
internal static extern int ADL_Display_EdidData_Get(int adapterIndex, int displayIndex, [In, Out] ADLDisplayEDIDData[] EDIDData, int iLength);

ADLDisplayEDIDData[] EDID = new ADLDisplayEDIDData[2];
NVGetMonitorEDIDs(0, EDID, EDID.Length);