1

I have an app on Steam, and normally when I want to know what operating system I am using, then I use TOSVersion.Name from System.SysUtils.

And that works except when I run it through Steam Proton on Linux, then it says I'm running it on Windows, even though I'm on Linux.

But surely there must be a way to detect or know when the app is run through Steam Proton?

How can I detect when the app is run through Steam Proton (Linux)?

0

2 Answers 2

2

Since Proton is based on Wine you can try to import the function wine_get_version off ntdll.dll - if that was successful then your Windows program is emulated through Wine. Or forks of it, like Proton.

I wrote something like the function below about 15 years ago. It compiles, but I cannot verify if it still works as expected (but it should):

uses
  Windows;

function GetWineVersion(): String;
var
  hModule: HINST;
  pAddr: Pointer;
  fVer: function: PChar; stdcall;
begin
  hModule:= GetModuleHandle( PChar('ntdll') );  // There is no chance this should ever fail.
  if hModule<> 0 then begin
    pAddr:= GetProcAddress( hModule, PChar('wine_get_version') );
    // We could also try to import "wine_nt_to_unix_file_name" without ever executing it.

    if pAddr<> nil then begin
      @fVer:= pAddr;
      result:= StrPas( fVer() );  // Actually call version: get Wine's version text.
      exit;  // Success!
    end;
  end;

  result:= '';  // Function does not exist = not running on Wine.
end;
Sign up to request clarification or add additional context in comments.

Comments

1

After digging around, I found this post mentioning to check /etc/os-release.

So, I managed to figure out that you can use the following function to know if your app is running through Proton (Linux) or not:

function isLinuxViaSteamProton: Boolean;
begin
  Result := FileExists('/etc/os-release');
end;

I tested it with various different Proton versions as well as various different Linux systems. It works with all of them.


If the function returns true, then your app is run from Steam Proton (Linux).

If the function returns false, then you're using Windows or whatever else the TOSVersion.Name function returns.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.