内存映射

‘’‘

int nMemSize = 4096;

//获取共享内存
if (!hCqShareMem_)
{
    
    std::wstring share_mapping_name = L"tkm_cq_memory_mapping";
    hCqShareMem_ = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, share_mapping_name.c_str());
    if (!hCqShareMem_ || hCqShareMem_ == INVALID_HANDLE_VALUE) {
        g_log_wnd->Print(L"与Q群采集通信失败,请检查Q群采集应用是否已经正常加载");
        cq_info_.effective = 0;
        m_pBtnCQLoginStatus->SetText(L"Q群采集未登录");
        m_pBoxMyQQGroup->RemoveAll();
        return;
    }
}

//映射
char* pRawShareAddr = NULL;
pRawShareAddr = (char *)MapViewOfFile(hCqShareMem_, FILE_MAP_ALL_ACCESS, 0, 0, 0);
memset(pRawShareAddr, 0, nMemSize); // 清空数据
//写入命令
g_log_wnd->Print(L"发送Q群采集命令:get_cq_info");
strcpy(pRawShareAddr, "get_cq_info");

//结束映射
UnmapViewOfFile(pRawShareAddr);

’‘’