Detect citrix “application mode”?

China☆狼群 提交于 2019-12-02 21:25:06
John Sibly

Not sure exactly how to do this in delphi, but if you can call out to the user32.dll, and call the function:

if (GetSystemMetrics(SM_REMOTESESSION) != 0)
{
   // We are in a remote session
}

This should tell you if you are running in a Citrix or Terminal Services environment. SM_REMOTESESSION is defined as:

#define SM_REMOTESESSION        0x1000

More info on the GetSystemMetrics api here: Link to msdn

Edit The following page describes how to do exactly the above in delphi. What works for Terminal Services should also work for Citrix:

Is your Delphi Application Running under Terminal Services as a Remote Session

This works for me:

return System.Windows.Forms.SystemInformation.TerminalServerSession;

A side-note for the curious: The solution proposed by "open-collar" is just a .NET wrapper for the one given by John Sibly. They should return the same result in every case. I confirmed this by disassembling the System.Windows.Forms.SystemInformation class.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!