Hi Captive Engineer!
I think, the question is, if the information is available in the runtime - if not, there will be no chance to get it in a program.
If Codesys converts the device tree into a pure list of adresses, that is used by the runtime, you cannot find the name of the device, which is part only of the project, not of the running program.
So in my opinion, the general task is to put the device names into a structure, that is handled in the runtime - which seems to be done at least for some connections - these can be read with that block from Schneider.
I tried to get some information from Codesys support months ago, but they couldn't help me - so let'S wait and hope for better times