home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / mswindo / programm / win32 / 828 < prev    next >
Encoding:
Text File  |  1992-09-04  |  3.7 KB  |  86 lines

  1. Newsgroups: comp.os.ms-windows.programmer.win32
  2. Path: sparky!uunet!gatech!news.ans.net!nynexst.com!gallifrey!baruch
  3. From: baruch@gallifrey.NoSubdomain.NoDomain (Robert Baruch)
  4. Subject: Re: NT, 3.1, and Global Memory
  5. Message-ID: <1992Sep4.141213.5736@nynexst.com>
  6. Sender: baruch@gallifrey (Robert Baruch)
  7. Organization: NYNEX Science & Technology, Inc.
  8. References: <1992Sep02.180251.7874@microsoft.com> <KEVIN.92Sep4095239@runningbear.edscom.demon.co.uk>
  9. Date: Fri, 4 Sep 92 14:12:13 GMT
  10. Lines: 74
  11.  
  12. In article <KEVIN.92Sep4095239@runningbear.edscom.demon.co.uk>, kevin@edscom.demon.co.uk (Kevin Broadey) writes:
  13. |> >>>>> Regarding Re: NT, 3.1, and Global Memory; johnhall@microsoft.com
  14. |> >>>>> (John Hall) adds:
  15. |> 
  16. |> In article baruch@nynexst.com (Robert Baruch) writes:
  17. |> 
  18. |> | After reading countless paragraphs on how Windows supports only 
  19. |> | a few means of data transfer between applications, I have come to
  20. |> | the conclusion that if I didn't want to use DDE, I could use a DLL,
  21. |> | and GlobalAlloc memory which could then be shared between
  22. |> | all the applications using that DLL.
  23. |> | 
  24. |> | My questions are:
  25. |> | 
  26. |> | (1)  If I GlobalAlloc in the DLL, and get a handle using one application,
  27. |> |      then another application accesses this handle, will I get the data from
  28. |> |      the first application UNDER WINDOWS NT?  I know that it works
  29. |> |     under Windows 3.1.
  30. |> 
  31. |>     John> No.  This won't work.
  32. |> 
  33. |>     John> However, I have just posted a dll which handles shared memory
  34. |>     John> under Windows NT.  Operations are ShrAlloc(), ShrLock(),
  35. |>     John> ShrUnlock(), ShrFree(), ShrName() to assign a name to a handle
  36. |>     John> and ShrGet() to get a handle based upon a name.
  37. |> 
  38. |>     John> I even make heroic efforts to force all addresses to be identical
  39. |>     John> across processes.
  40. |> 
  41. |>     John> This is available on Compuserve WIN32 porting from OS/2.
  42. |> 
  43. |>     John> Included in this kit is source code for the dll, test code,
  44. |>     John> and some discussions on implementation decisions.  
  45. |> 
  46. |>     John> I'll ask Alistair to place it on ftp.
  47. |> 
  48. |> There's something strange going on here.
  49. |> 
  50. |> I've got 2 Windows 3.1 applications that I'm porting to NT.
  51. |> 
  52. |> App1 does GlobalAlloc, GlobalLock, fills in the memory, GlobalUnlock,
  53. |> PostMessage the handle to app2.
  54. |> 
  55. |> App2 does GlobalLock, reads the memory, GlobalUnlock, GlobalFree.
  56. |> 
  57. |> Everything is fine and dandy.
  58. |> 
  59. |> Admittedly this isn't done in a DLL, but since DLLs (by default) run as
  60. |> if they were part of the app (accessing the app's data space, for
  61. |> instance) this shouldn't make any difference.
  62. |> 
  63. |> So what's going on?
  64.  
  65. Apparently passing data using global allocations works experimentally under 3.1, and
  66. possibly NT.  However, Microsoft keeps saying that you shouldn't use this, 
  67. because applications are not guaranteed to have the same addressing space
  68. in future versions of NT.  I guess they want to leave that avenue open to them, and
  69. they can't do that if they support global alloc data passing.
  70.  
  71. There were two reasons I allocated my global data in a DLL:
  72.  
  73. (1)  The rationalization: The DLL contains functions which create data pipes, and so
  74.      I wanted to manage all the data in the DLL, just passing handles to the applications.
  75.     The DLL actually creates circular buffers, with messages on the buffer being globally
  76.     allocated data.
  77.  
  78. (2)  The real reason:  I read that you could allocate data in a DLL if you wanted to
  79.       pass it between allocations.  I think they actually meant local alloc, but I used
  80.       global alloc because I didn't want to be limited to less than 64K of data.
  81.  
  82. I'm not sure if that answers your questions.  I took two interpretations of your
  83. question and answered them.
  84.  
  85. --Rob
  86.