Back to index

lightning-sunbird  0.9+nobinonly
mapismem.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef __SMEM_HPP__
00038 #define __SMEM_HPP__
00039 
00040 //
00041 // Need this for Win16 since it is an undocumented message
00042 //
00043 #ifndef WIN32
00044 
00045 #define WM_COPYDATA                     0x004A
00046 
00047 /*
00048  * lParam of WM_COPYDATA message points to...
00049  */
00050 typedef struct tagCOPYDATASTRUCT {
00051     DWORD         dwData;
00052     DWORD         cbData;
00053     LPVOID        lpData;
00054 } COPYDATASTRUCT, *PCOPYDATASTRUCT;
00055 
00056 # ifndef LPCTSTR
00057 #   define LPCTSTR LPCSTR
00058 # endif
00059 
00060 
00061 #endif // ifndef WIN32
00062 
00063 // The following structure will be stored in the shared memory 
00064 // and will be used to pass data back and forth 
00065 
00066 #pragma pack(4) 
00067 
00068 typedef struct  
00069 { 
00070   DWORD m_dwSize;       // size of the shared memory block 
00071   BYTE  m_buf[1];       // this is the buffer of memory to be used
00072 } CSharedMem; 
00073 
00074 #pragma pack(4) 
00075 
00076 // ******************************************************
00077 // Public routines...
00078 // ******************************************************
00079 // 
00080 // 
00081 // *create new* shared memory chunk 
00082 // once this is created, use the pointer
00083 // to the segment to to store data 
00084 // e.g.: 
00085 //     lpString = "string for communicator"; 
00086 //     lstrcpy((LPSTR)pData->m_buf[0], lpString); 
00087 //     pData->m_dwBytesUsed = lstrlen(lpString) + 1; // count '\0' 
00088 //  
00089 CSharedMem *
00090 NSCreateSharedMemory(DWORD memSize, LPCTSTR memName, HANDLE *hSharedMemory);
00091 
00092 // 
00093 // *open existing* shared memory chunk 
00094 // once you have the pointer to the new segment 
00095 // use this pointer to access data, e.g.: 
00096 //
00097 // This will return the pointer to the memory chunk as well as
00098 // fill out the hSharedMemory argument that is needed for subsequent
00099 // operations.
00100 // 
00101 //  if(pData->m_dwBytesUsed > 0) 
00102 //  { 
00103 //    // use pData->m_buf here 
00104 //  } 
00105 //
00106 CSharedMem *
00107 NSOpenExistingSharedMemory(LPCTSTR memName, HANDLE *hSharedMemory);
00108 
00109 //
00110 // You must pass in the pointer to the memory chunk as well as
00111 // the hSharedMemory HANDLE to close shared memory segment
00112 // 
00113 void
00114 NSCloseSharedMemory(CSharedMem *pData, HANDLE hSharedMemory);
00115 
00116 #endif  // __SMEM_HPP__