Subject Re: Identifying whether client library is embedded or normal
Author Adam
--- In firebird-support@yahoogroups.com, Nando Dessena <nando@...> wrote:
>
> Adam,
>
> A> The local connection used in Firebird does not work with Terminal
> A> Services.
>
> Correct - partly. If the Firebird Server is running in the same Window
> Station (read "terminal session", in this context) as the client,
> local connections will work. Try running fbserver.exe -a before
> running your application *from the terminal session* and see. I agree
> the point is moot anyway - nobody is going to use a database server
> this way. ;-)
>
> P.S. I don't know about Firebird 2's XNET replacement for the local
> protocol, but it might well work across window stations.
>
> A> This means that embedded Firebird can not be used within a
> A> Terminal Server session.
>
> Wrong. An embedded connection has nothing to do with a local
> connection, although unfortunately they choose the same syntax to
> indicate both (please address complaints to Dmitry Y. - I tried years
> ago but got no luck - and anyway fbembed is so wonderful that one
> could surely stand a few glitches. :-)). An embedded connection, that
> consists of in-process function calls, will work in all cases in which
> your process works and can find fbembed.dll and its support files.
>

I understand these are different under-the-hood, but when I attempted
it in practice a while back it did not work. I did post a bug report
last year reporting that I had issues with both local connection and
embedded connections on 2003 server (1346568). Alexander Peshkov
kindly pointed out the problem was with Terminal Services. Perhaps he
was only referring to the local connection, but in any case, I made an
embedded version of our program, tested it on a XP box and it worked
fine. I then zipped it and uploaded it to a TS session where it did
not work.

I agree that embedded is still good even with this limitation, and it
would be even better if FB 2 resolves the local connection issue. I
can not install a RC database engine on that machine at this time (as
I am sure you can appreciate). Although I expect FB 2 to go general
just before this project is completed (based on the Roadmap + some
slippage allowance).

> A> Basically, my delphi application needs to know whether to insert
> A> 'localhost:' to the start of the connection string or not.
>
> given what I wrote above, this shouldn't be a requirement anymore. In
> any case, if you still need to do it for whatever reason, you might
> want to query the OS to know whether you're in a terminal session or
> not. I must have some Delphi code (easily translatable to other
> languages, as it's a bunch of Win32 API calls) around for that. Let me
> know and I'll dig it up for you.

As I was typing my response to Helen, it struck me that I could just
see if Windows would tell me whether I was running in a TS Session and
internally adjust using that mechanism. This is precisely what I did.

In case anyone was wondering:

function RunningOnTerminalServices : Boolean;
const
sm_RemoteSession = $1000; { from WinUser.h }
begin
Result := GetSystemMetrics(sm_RemoteSession) <> 0;
end;

Thanks
Adam