C++Builder编写dll时如何添加共享数据段
2006-09-07 11:01
706 查看
yesry (噎死你)
回复于 2003-10-24 11:56:55 得分 0
整理后:
工程的名字ShareMemory
//-++-+-+--+-文件uShareMemory.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#include "SharedUnit.h"
#pragma argsused
extern int Data;
extern struct test t;
extern char buff[100];
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
strcpy(t.sb,"ffff");//不知道为什么无用的也做一做
return 1;
}
//---------------------------------------------------------------------------
#define DLL_EXPORT extern "C" __declspec(dllexport)
DLL_EXPORT
void WINAPI SetData(char *p)
{
strcpy(buff,p);
}
DLL_EXPORT
void WINAPI GetData(char *p)
{
strcpy(p,buff);
}
//-++-+-+--+-文件ShareUnit.h
#include <vcl.h>
struct test
{
int age;
int xy;
char *sb;
};
//-++-+-+--+-文件ShareUnit.cpp
#pragma option -zRSHSEG
#pragma option -zTSHCLASS
#include "SharedUnit.h"
int Data = 0;
test t={120,10,"asdg"};//必须的,不管你用不用
char buff[100];
//-++-+-+--+-文件ShareMemory.def
SEGMENTS SHSEG CLASS 'SHCLASS' SHARED
回复于 2003-10-24 11:56:55 得分 0
整理后:
工程的名字ShareMemory
//-++-+-+--+-文件uShareMemory.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#include "SharedUnit.h"
#pragma argsused
extern int Data;
extern struct test t;
extern char buff[100];
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
strcpy(t.sb,"ffff");//不知道为什么无用的也做一做
return 1;
}
//---------------------------------------------------------------------------
#define DLL_EXPORT extern "C" __declspec(dllexport)
DLL_EXPORT
void WINAPI SetData(char *p)
{
strcpy(buff,p);
}
DLL_EXPORT
void WINAPI GetData(char *p)
{
strcpy(p,buff);
}
//-++-+-+--+-文件ShareUnit.h
#include <vcl.h>
struct test
{
int age;
int xy;
char *sb;
};
//-++-+-+--+-文件ShareUnit.cpp
#pragma option -zRSHSEG
#pragma option -zTSHCLASS
#include "SharedUnit.h"
int Data = 0;
test t={120,10,"asdg"};//必须的,不管你用不用
char buff[100];
//-++-+-+--+-文件ShareMemory.def
SEGMENTS SHSEG CLASS 'SHCLASS' SHARED
相关文章推荐
- 如何与应用程序或其他 DLL 共享自己 DLL 中的数据?
- VS2005 如何编写DLL以及添加DLL
- 多个session共享数据如何实现 - PHP进阶
- dll中共享数据
- DataList多行数据后如何添加一条分隔线
- android面试题:请介绍下ContentProvider是如何实现数据共享的
- 如何把ASP编写成DLL这篇文章主要是把ASP代码变成组件
- 如何实现数据共享而不更改其值
- C#调用非托管C编写DLL的数据类型转换
- 回答一位朋友的提问:在Delphi7下如何与DLL共享数据库连接
- 如何用数据驱动实现通用化巡检APP(如何一个界面里添加多个点击拍照按钮并显示在不同的imageview里)
- 在vs2008中编写dll如何生成lib文件
- 在vs2008中编写dll如何生成lib文件
- Swing编程之 如何在JTable中添加数据
- 如何在MapReduce的各任务之间共享数据
- 如何用VC编写供PB调用的DLL (转)
- 使用Dictionary集合编写的通用的后台添加数据
- SQL Server 2005中的分区表(二):如何添加、查询、修改分区表中的数据 .
- lib,dll区别 及 VS中如何添加lib,dll
- LIB,DLL区别 及 VS中如何添加LIB,DLL