How can I use NVAPI to determine the connection between the graphics card output ports and the connected displays, similar to what is shown in the NVI

Hello! I am currently working on developing the port EDID locking feature using NVAPI. I have found that I can lock the EDID using the displayID obtained through NvAPI_GPU_GetAllDisplayIds, but the port I wish to lock does not correspond to the one actually locked by the displayID. Therefore, how can I determine which graphics card port the displayID is connected to?