Click here to Skip to main content
15,886,788 members
Articles / Desktop Programming / MFC

Shared memory

Rate me:
Please Sign up or sign in to vote.
4.80/5 (6 votes)
28 Sep 20028 min read 221.7K   6K   84  
Share variables in the shared memory across processes
// TestSMDlg.h : header file
//

#if !defined(AFX_TESTSMDLG_H__73FE91AA_ACB1_11D4_9B42_00AA0066B154__INCLUDED_)
#define AFX_TESTSMDLG_H__73FE91AA_ACB1_11D4_9B42_00AA0066B154__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "SharedMemory.h"

/////////////////////////////////////////////////////////////////////////////
// CTestSMDlg dialog

class CTestSMDlg : public CDialog
{
// Construction
public:
	CTestSMDlg(CWnd* pParent = NULL);	// standard constructor
	~CTestSMDlg();

// Dialog Data
	//{{AFX_DATA(CTestSMDlg)
	enum { IDD = IDD_TESTSM_DIALOG };
	CButton	m_CBtnTestExch;
	CButton	m_CBtnIncr;
	CButton	m_CBtnExchAdd;
	CButton	m_CBtnExch;
	CButton	m_CBtnDecr;
	CButton	m_CBtnCmpExch;
	CButton	m_CBtnWaiForVar;
	CListCtrl	m_SharedMemView;
	CButton	m_CBtnSetVal;
	CButton	m_CbtnRefr;
	CButton	m_CBtnDel;
	CButton	m_CbtnAdd;
	CString	m_CsUsedSize;
	CString	m_CsMemorySize;
	CString	m_CsTotalUsage;
	CString	m_CsVariablesCount;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTestSMDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;
	CSharedMemory *m_psm;

	void UpdateButtonsState(int pos);

	// Generated message map functions
	//{{AFX_MSG(CTestSMDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnAdd();
	afx_msg void OnDel();
	afx_msg void OnRefr();
	afx_msg void OnSetval();
	afx_msg void OnDblclkSharedmemory(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnWaitForChange();
	afx_msg void OnWaitForMem();
	afx_msg void OnItemclickSharedmemory(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnClickSharedmemory(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnKeydownSharedmemory(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnCompareexchange();
	afx_msg void OnDecrement();
	afx_msg void OnExchange();
	afx_msg void OnExchangeadd();
	afx_msg void OnIncrement();
	afx_msg void OnRead();
	afx_msg void OnTestexchange();
	afx_msg void OnWrite();
	afx_msg void OnWaitformultivarchange();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TESTSMDLG_H__73FE91AA_ACB1_11D4_9B42_00AA0066B154__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions