Hi Bill.  I wrote that libraries should support multiple calls to Open/Close
simply because sharing is one of the primary underlying principles of a code
library!  Don't let that stop you from doing your own thing though.

Others have already answered the two questions you pose below, so I'll forgo
that.  If you want to implement a shared library that only a particular
program can use, only allow the reference count to get to 1.  Any further
open attempts should return an error.

So once you've loaded the Library and opened it, you will be the only one
who can use it until you close it.

If your app is not running, though, someone else is able to load your lib
and use it.  If you want to extend your security to prevent this from
happening, implement the reference count cap above, and also use a feature
(see FtrSet/FtrGet).  For example, your app sets a special feature with a
checksum or something.  Then in your lib's Open(), verify that the feature
exists and verify the checksum -- else, return err.  When your app
AppStop's, clear the feature.  That way nobody else can Open the library.

A static (link-time) library might be another solution for you.  With a
static lib, nobody else should touch your library code because it's part of
your PRC.

Later,
-Jeff Ishaq
The Windward Group

-----Original Message-----
From: Turner, Bill/EXEUG3 [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 10, 2000 1:11 PM
To: 'Palm Forum'
Subject: Exclusive use shared library?


In the technical paper "Mastering Shared Libraries", it is stated that
shared libraries should allow for multiple calls to Open (and a
corresponding number of calls to Close).  However, I have a shared library
that is using the dynamic loading aspects rather than the sharing aspects --
in fact, I would like to prevent two different applications using the
library at the same time.

So, what I'm asking is two-fold:

1) Is it required that a shared library allow for multiple nested Open
calls?  (If not, then my question is answered -- second and subsequent Open
requests fail)

2) If I do have to allow a single application to make multiple Open calls,
is there some way of identifying which application is making the call?  I
tried SysTaskID, but it doesn't appear to be what I would expect (and yeah,
it's listed in the System Use Only section of the manual....)

--Bill Turner
PSC Inc.

Reply via email to