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

整理后:
工程的名字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