【发布时间】:2010-10-01 22:07:21
【问题描述】:
好的,所以我有一个编译为 DLL 文件的 C++ 项目。我可以在 C# 中引用此文件并查看/使用 DLL 文件中的所有对象和函数。我需要做的是通过VB6引用这些对象和函数。
C++ 代码中没有任何内容,看起来像是在创建 DLL。没有 '__declspec(dllexport)' 修饰符,只有 C++ 代码。
有这样的对象:
String ^
Array^
我不完全确定它们是什么。我对 C++ 的了解不是很广泛,而且我只为 Linux 系统编写过 C++ 代码,尽管从用法来看它们有点像指针。这些对象与 C++ 中的 DLL 有什么关系吗?
无论如何,我可以添加我需要的任何包装器或添加定义文件 (.def),尽管我不知道要使用什么包装器,也不知道定义文件如何工作或需要如何构造.
感谢任何帮助和/或建议。如果您也可以向我推荐一些好的信息,那将很有帮助。我所做的所有搜索都没有帮助。
请记住,我需要从 VB6 访问此 C++ DLL 中的所有函数和对象。
谢谢。
编辑:在问题中添加了 .h 文件和 AssemblyInfo.cpp 规范
我更改了这些文件中的一些名称,但结构相同。请注意,这引用了其他文件,但我假设如果可以使一个文件工作,那么其他文件可以使用相同的过程。我可以看到每个对象,但看不到方法:
//myDBObject.h
#pragma once
using namespace System;
namespace myDBNamespace {
#include "ProblemSolution.h"
public ref class MyDataBaseAccessor
{
public:
MyDataBaseAccessor();
static String ^ GetServiceVersion() { return sDLLVersion;};
int GetServiceStatus() { return myiDBStatus;};
String ^ GetMyVersion();
String ^ GetDBVersion();
String ^ GetDLLVersion();
String ^ GetExpireDate();
MyOtherObject ^ GetMyOtherObject();
int ProcessProblem(ProblemSolution ^ dsps);
private:
static MyDataBaseController ^ myDataBase;
static MyOtherObject ^ myObjs;
static MyDataset ^ myDS;
static String ^ myDBPath;
static String ^ sDLLVersion = "0.01";
static String ^ sReqDBVer = "0.01";
static int myiDBStatus;
static bool myBoolean, myOtherBoolean, mybNoChain;
};
}
这是 AssemblyInfo.cpp 文件:
#include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("My Product Title")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("My Company")];
[assembly:AssemblyProductAttribute("My Product Name")];
[assembly:AssemblyCopyrightAttribute("My Copyright")];
[assembly:AssemblyTrademarkAttribute("My Program")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(true)]; //Here is the ComVisible tag. It was false and I set it to true
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = false)];
【问题讨论】: