home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!sdd.hp.com!srvr1.engin.umich.edu!jwh
- From: jwh@citi.umich.edu (Jim Howe)
- Newsgroups: comp.lang.smalltalk
- Subject: Re: How can I test for an opened DLL in Smalltalk/V 2.0 in OS/2?
- Date: 22 Jan 1993 18:26:47 GMT
- Organization: IFS Project, University of Michigan
- Lines: 45
- Distribution: world
- Message-ID: <1jpe97INNdpb@srvr1.engin.umich.edu>
- References: <C19MM7.28M@unix.portal.com>
- Reply-To: jwh@citi.umich.edu
- NNTP-Posting-Host: tarkus.citi.umich.edu
-
- In article <C19MM7.28M@unix.portal.com>, magus@shell.portal.com (Magus Company) writes:
- |> I'm using Smalltalk/V PM 2.0 (for OS/2 2.0) to call functions in a C DLL.
- |> No problem so far. The DLL is accessed by sending an open message to its
- |> subclass of DynamicLinkLibrary, and has its unique instance (a PMHandle)
- |> assigned to a global variable, say VAR. The DLL requires that I call an
- |> internal initialization routine after I open it, but only once.
- |>
- |> Question: How can my application tell if the DLL has already been opened?
- |> If my application calls the DLL initialization routine a second time by
- |> mistake, an error message appears. I can't do something like
- |>
-
- One way to accomplish what you want is to include the call to the
- initialization function in the open method used by the DLL. You
- can then make a modification to SystemDictionary>>startUp and have
- the DLL opened automatically when the system starts up. The new
- handle received as a result of invoking the open method would be
- assigned to the global variable used to reference your library,
- replacing the old handle (which is now invalid).
-
- For example, in one of my applications, I need to reference functions
- contained in the PMWP dll. My SystemDictionary>>startUp method looks
- like this:
-
- startUp
- ...
- PMShellLibrary := PMShellLibraryDLL open.
- VPMVM := VPMVMDLL open.
- NlsLibrary := NLSDLL open.
- PMWorkplace := PMWorkplaceDLL open.
- ...
-
- If you didn't want to include the call to the initialization function
- in the open method itself, you could implement an 'initialize' method
- which did the work. In the startUp method, add a line which looks
- like this:
-
- PMWorkplace initialize.
-
- That's all there is to it.
-
-
- James W. Howe internet: jwh@citi.umich.edu
- University of Michigan uucp: uunet!mailrus!citi.umich.edu!jwh
- Ann Arbor, MI 48103-4943
-