⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 source.cpp

📁 memory map file class for C++ builder
💻 CPP
字号:
#include "stdafx.h"
#include "MemMap.h"

using namespace std;

int main()
{
	CMemMap	mmp;
	unsigned int i;
	double j = -123.456;

	try 
	{
		mmp.Create(_T("594855C7-9888-465a-8BC8-D9797874EB9F"),INFINITE,2048);

		if ( mmp.WaitToWrite() ) {

			for (i=0; i<3; i++,j*=7.23) {
				wcout << _T("Adding Binary: ") << j << endl;
				mmp.AddBinary(&j,sizeof(double),i);
			}

			
			for (i=0,j=0; i<3; i++) {
				mmp.GetBinary(&j,sizeof(double),i);
				wcout << _T("GetBinary Returned: ") << j << endl;
			}
			
			for (i=0; i<3; i++,j*=7.23) {
				wcout << _T("Updating binary to: ") << j << endl;
				mmp.UpdateBinary(&j,sizeof(double),i);
			}
			
			for (i=0,j=0; i<3; i++) {
				mmp.GetBinary(&j,sizeof(double),i);
				wcout << _T("GetBinary Returned: ") << j << endl;
			}

			for (i=0; i<3; i++) {
				wcout << _T("Deleting ID: ") << i << endl;
				mmp.DeleteID(i);
			}

			for (i=0; i<3; i++) {
				wcout << _T("Adding string \"Hello World!\"") << endl;
				mmp.AddString(_T("Hello World!"),i);
			}

			for (i=0; i<3; i++) {
				wcout << _T("GetString Size Returned: ");
				wcout << (UINT)mmp.GetString(0,0,i) << endl;
			}

			for (i=0; i<3; i++) {
				wcout << _T("GetString returned: ");
				wcout << (LPCTSTR)mmp.GetString(i) << endl;
			}

			for (i=0; i<3; i++) {
				wcout << _T("Deleting ID: ") << i << endl;
				mmp.DeleteID(i);
			}

			wcout << _T("Freeing the memory") << endl;
			mmp.Vacuum();

			wcout << _T("Releasing lock") << endl;
			mmp.Done();
		}
	}
	catch (LPCTSTR sz)
	{
		wcout << sz << endl;
	}

	char c(' ');

	while (c != 'q' && c != 'Q')
	{
		cout << "Press q then enter to quit: ";
		cin >> c;
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -