识别运行Delphi 7程序的服务器(Identifying the server from which a Delphi 7 program is run)

在各种服务器上部署了单独版本的Delphi 7程序。 为了帮助解决报告的错误,我正在尝试编写一个函数来识别程序运行的服务器。

以下代码获取本地计算机名称。

sbAll.Panels.Items[1].Text := 'Server: ' + GetEnvironmentVariable('COMPUTERNAME');

假设程序的绝对路径是:

\\Swingline\Programs\Folder\Program.exe

如何让它返回Server: Swingline无论它运行的是什么计算机?

Separate versions of a Delphi 7 program have been deployed on various servers. In order to help troubleshoot reported errors, I'm trying to write a function to identify what server the program is running from.

The following code gets me the local computer name.

sbAll.Panels.Items[1].Text := 'Server: ' + GetEnvironmentVariable('COMPUTERNAME');

Assuming that the absolute path of the program is:

\\Swingline\Programs\Folder\Program.exe

How do I get it to return Server: Swingline regardless of what computer it is run from?

最满意答案

您可以使用Application.ExeName,用斜杠拆分并获取第二个元素......

You can probably use Application.ExeName, split it by the slashes and get the second element...

更多推荐