我想做一个动态链接库DllDemo,和一个调用该DllDemo的可执行程序DLLTest,在DllDemo中定义函数
Value transferValue(int flag,Value& value,CString decodestring),Value是一个类,在DllMemo和DLLTest中都是一样的,请问这样的transferValue是否可以实现?
Value transferValue(int flag,Value& value,CString decodestring),Value是一个类,在DllMemo和DLLTest中都是一样的,请问这样的transferValue是否可以实现?
Dlldemo:动态链接库
Dlltest:可执行的exe文件,调用Dlldemo中的内容,
当Dlltest给Dlldemo传递一个Value类时,Dlldemo给传回一个CString类型,
当Dlltest给Dlldemo传递一个CString类时,Dlldemo给传回一个Value类
Value是自己定义的类。
我还可以在送分啊!!!!!!!!!!!!555555555555555555
把你的E-Mail短消息告诉我,我给你发过去。
1 类定义.h
// DllTransfer.h: interface for the CDllTransfer class.
//
//////////////////////////////////////////////////////////////////////#if !defined(AFX_DLLTRANSFER_H__35ED9875_E3AD_45C2_A339_E0AA0AC0BF26__INCLUDED_)
#define AFX_DLLTRANSFER_H__35ED9875_E3AD_45C2_A339_E0AA0AC0BF26__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000class AFX_EXT_CLASS CDllTransfer
{
public:
CDllTransfer();
virtual ~CDllTransfer();
public:
int x;
int y;
};#endif // !defined(AFX_DLLTRANSFER_H__35ED9875_E3AD_45C2_A339_E0AA0AC0BF26__INCLUDED_)2 Cpp 文件:
// DllTransfer.cpp: implementation of the CDllTransfer class.
//
//////////////////////////////////////////////////////////////////////#include "stdafx.h"
#include "DllTransfer.h"#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////CDllTransfer::CDllTransfer()
{
x=10;
y=10;
}CDllTransfer::~CDllTransfer()
{
}3 函数库:
//.h文件
#ifndef __MYFUN_H__
#define __MYFUN_H__#include "DllTransfer.h"
CDllTransfer AFX_EXT_API TransferDate();#endifCpp文件:
#include "stdafx.h"
#include "MyFun.h"CDllTransfer TransferDate()
{
CDllTransfer m_xx;
m_xx.x=100;
m_xx.y=200;
return m_xx;
}调用程序:
stdafx.h中加入
#pragma comment(lib,"..\\ReadDbfLib\\debug\\ReadDbfLib.lib")
#pragma message("Automatically linking with WFLib.dll")
#include "..//dllpath//DllTransfer.h"调用的文件里加入
#include "..\ReadDbfLib\MyFun.h"
用下面的方法调用是成功的
void CMainFrame::OnTesttranclass()
{
CDllTransfer m_xx;
m_xx=TransferDate();
}
exe中就可以直接定义一个类的对象,然后通过对象来调用成员函数来实现传递
------------
真是这样吗?如果是这样,我就不能这样做了,因为最后的调用程序可能是Java语言的
大家可以帮我看一下,不导出情况下,有什么办法?