home *** CD-ROM | disk | FTP | other *** search
- Path: 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
-
- 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
- ----------------------------------------------------------------------------
-