🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.misc
Article #1833

Re: DLL-question

#1833
From: Tom W. Brown
Date: Tue, 15 Dec 1992 17:48
49 lines
2302 bytes
In article <2914@media03.UUCP>, rla@media03.UUCP (Raymond van der Laan) writes:
|> Is this possible in a DLL:
|> 
|>     ... x;
|>     ... y;
|> 
|>     f1 ()
|>     {
|>         y = GlobalAlloc(...);
|>         x = GlobalLock(y);
|>         PeekMessage()
|>         if ours then memcpy(x,...,...);
|>         else Translate & DispatchMessage
|>         ...
|>     }
|> 
|>     f2 (a)
|>     {
|>         memcpy(a, x, ...);
|>         GlobalFree(y);      <-------------\
|>     }                                     |
|>                                           |
|> The caller calls f1, then f2.             |
                                             |
Yes, but some considerations:                |
                                             |
  - Don't forget the GlobalUnlock().  -------/

  - If x and y are global variables for the DLL then f1() and f2() are
    not reentrant.  Consider what happens if you have two applications
    using your DLL and the translate/dispatch within f1() for app1 causes
    app2 to call f1().

    This is probably not a concern for you, but if it is then you will
    want to take some steps to either prevent reentrancy, provide
    some form of mutual exclusion in f1() and f2(), or allow x and y
    to be instance variables for each application using the DLL.

  - The above example is clear enough in what it does, but not at all
    clear is why you are considering this.  What is happening in your
    application that requires this functionality in a DLL?



----------------------------------------------------------------------------
Tom Brown               |  "She turned me into a newt...
PE Nelson Systems       |                                  ... I got better"
twbrown@pe-nelson.com   |                    Monty Python and the Holy Grail
----------------------------------------------------------------------------
Technical Details
Message-ID: <713@lax.lax.pe-nelson.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!lax.pe-nelson.com!lax!twbrown
References: <2914@media03.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!lax.pe-nelson.com!lax!twbrown
From: twbrown@PE-Nelson.COM (Tom W. Brown)
Newsgroups: comp.os.ms-windows.programmer.misc
Subject: Re: DLL-question
Keywords: Alloc, Peekmessage
Message-ID: <713@lax.lax.pe-nelson.com>
Date: 15 Dec 92 17:48:09 GMT
References: <2914@media03.UUCP>
Sender: news@lax.pe-nelson.com
Organization: PE-Nelson
Lines: 49