123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- // ShareMemory_IF.cpp : 定义 DLL 应用程序的导出函数。
- //
- #include "stdafx.h"
- #include <string>
- #include "ShareMemory_IF.h"
- using namespace std;
- CShareMemory_Circle *g_pBigSm = NULL;
- CShareMemory_Circle *g_pSmallSm = NULL;
- string g_Sharemem_if_BigName = "CirSMIFBig";
- string g_Sharemem_if_SmallName = "CirSMIFSm";
- SHAREMEMORY_IF_C_API int Init_Circle_SM_IF(DWORD &BigBlockSize, DWORD &BigBlockCount, DWORD &SmallBlockSize, DWORD &SmallBlockCount)
- {
- int ret = -1;
- if (g_pBigSm == NULL)
- {
- g_pBigSm = new CShareMemory_Circle();
- }
- if (g_pSmallSm == NULL)
- {
- g_pSmallSm = new CShareMemory_Circle();
- }
- if (g_pBigSm->Create(g_Sharemem_if_BigName.c_str(), BigBlockSize, BigBlockCount, SM_READWRITE) >= 0)
- {
- g_pBigSm->Close();
- ret = g_pSmallSm->Create(g_Sharemem_if_SmallName.c_str(), SmallBlockSize, SmallBlockCount, SM_READWRITE);
- g_pSmallSm->Close();
- }
- //return 0;
- return ret;
- }
- SHAREMEMORY_IF_C_API const char* Get_Circle_SM_Object(DWORD BlockSize)
- {
- if (g_pSmallSm->GetSize() >= BlockSize)
- {
- return g_Sharemem_if_SmallName.c_str();
- }
- else if (g_pBigSm->GetSize() >= BlockSize)
- {
- return g_Sharemem_if_BigName.c_str();
- }
- return NULL;
- }
- SHAREMEMORY_IF_C_API void Exit_Circle_SM_IF()
- {
- delete g_pBigSm;
- g_pBigSm = NULL;
- delete g_pSmallSm;
- g_pSmallSm = NULL;
- }
|