home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / mapismem.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.8 KB  |  98 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. #ifndef __SMEM_HPP__
  19. #define __SMEM_HPP__
  20.  
  21. //
  22. // Need this for Win16 since it is an undocumented message
  23. //
  24. #ifndef WIN32
  25.  
  26. #define WM_COPYDATA                     0x004A
  27.  
  28. /*
  29.  * lParam of WM_COPYDATA message points to...
  30.  */
  31. typedef struct tagCOPYDATASTRUCT {
  32.     DWORD         dwData;
  33.     DWORD         cbData;
  34.     LPVOID        lpData;
  35. } COPYDATASTRUCT, *PCOPYDATASTRUCT;
  36.  
  37. # ifndef LPCTSTR
  38. #   define LPCTSTR LPCSTR
  39. # endif
  40.  
  41.  
  42. #endif // ifndef WIN32
  43.  
  44. // The following structure will be stored in the shared memory 
  45. // and will be used to pass data back and forth 
  46.  
  47. #pragma pack(4) 
  48.  
  49. typedef struct  
  50.   DWORD m_dwSize;       // size of the shared memory block 
  51.   BYTE  m_buf[1];       // this is the buffer of memory to be used
  52. } CSharedMem; 
  53.  
  54. #pragma pack(4) 
  55.  
  56. // ******************************************************
  57. // Public routines...
  58. // ******************************************************
  59. // 
  60. // 
  61. // *create new* shared memory chunk 
  62. // once this is created, use the pointer
  63. // to the segment to to store data 
  64. // e.g.: 
  65. //     lpString = "string for communicator"; 
  66. //     lstrcpy((LPSTR)pData->m_buf[0], lpString); 
  67. //     pData->m_dwBytesUsed = lstrlen(lpString) + 1; // count '\0' 
  68. //  
  69. CSharedMem *
  70. NSCreateSharedMemory(DWORD memSize, LPCTSTR memName, HANDLE *hSharedMemory);
  71.  
  72. // 
  73. // *open existing* shared memory chunk 
  74. // once you have the pointer to the new segment 
  75. // use this pointer to access data, e.g.: 
  76. //
  77. // This will return the pointer to the memory chunk as well as
  78. // fill out the hSharedMemory argument that is needed for subsequent
  79. // operations.
  80. // 
  81. //  if(pData->m_dwBytesUsed > 0) 
  82. //  { 
  83. //    // use pData->m_buf here 
  84. //  } 
  85. //
  86. CSharedMem *
  87. NSOpenExistingSharedMemory(LPCTSTR memName, HANDLE *hSharedMemory);
  88.  
  89. //
  90. // You must pass in the pointer to the memory chunk as well as
  91. // the hSharedMemory HANDLE to close shared memory segment
  92. // 
  93. void
  94. NSCloseSharedMemory(CSharedMem *pData, HANDLE hSharedMemory);
  95.  
  96. #endif  // __SMEM_HPP__
  97.