home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / smalltal / 2798 < prev    next >
Encoding:
Internet Message Format  |  1993-01-22  |  2.3 KB

  1. Path: sparky!uunet!usc!sdd.hp.com!srvr1.engin.umich.edu!jwh
  2. From: jwh@citi.umich.edu (Jim Howe)
  3. Newsgroups: comp.lang.smalltalk
  4. Subject: Re: How can I test for an opened DLL in Smalltalk/V 2.0 in OS/2?
  5. Date: 22 Jan 1993 18:26:47 GMT
  6. Organization: IFS Project, University of Michigan
  7. Lines: 45
  8. Distribution: world
  9. Message-ID: <1jpe97INNdpb@srvr1.engin.umich.edu>
  10. References: <C19MM7.28M@unix.portal.com>
  11. Reply-To: jwh@citi.umich.edu
  12. NNTP-Posting-Host: tarkus.citi.umich.edu
  13.  
  14. In article <C19MM7.28M@unix.portal.com>, magus@shell.portal.com (Magus Company) writes:
  15. |> I'm using Smalltalk/V PM 2.0 (for OS/2 2.0) to call functions in a C DLL. 
  16. |> No problem so far.  The DLL is accessed by sending an open message to its
  17. |> subclass of DynamicLinkLibrary, and has its unique instance (a PMHandle)
  18. |> assigned to a global variable, say VAR.  The DLL requires that I call an
  19. |> internal initialization routine after I open it, but only once.  
  20. |> 
  21. |> Question: How can my application tell if the DLL has already been opened? 
  22. |> If my application calls the DLL initialization routine a second time by
  23. |> mistake, an error message appears.  I can't do something like
  24. |> 
  25.  
  26. One way to accomplish what you want is to include the call to the
  27. initialization function in the open method used by the DLL.  You
  28. can then make a modification to SystemDictionary>>startUp and have
  29. the DLL opened automatically when the system starts up.  The new
  30. handle received as a result of invoking the open method would be
  31. assigned to the global variable used to reference your library,
  32. replacing the old handle (which is now invalid).
  33.  
  34. For example, in one of my applications, I need to reference functions
  35. contained in the PMWP dll.  My SystemDictionary>>startUp method looks
  36. like this:
  37.  
  38. startUp
  39.    ...
  40.    PMShellLibrary := PMShellLibraryDLL open.
  41.    VPMVM := VPMVMDLL open.
  42.    NlsLibrary := NLSDLL open.
  43.    PMWorkplace := PMWorkplaceDLL open.
  44.    ...
  45.  
  46. If you didn't want to include the call to the initialization function
  47. in the open method itself, you could implement an 'initialize' method
  48. which did the work.  In the startUp method, add a line which looks
  49. like this:
  50.  
  51.    PMWorkplace initialize.
  52.  
  53. That's all there is to it.
  54.  
  55.  
  56. James W. Howe                  internet: jwh@citi.umich.edu
  57. University of Michigan             uucp: uunet!mailrus!citi.umich.edu!jwh
  58. Ann Arbor, MI   48103-4943         
  59.