好的,所以我有一個編譯爲DLL文件的C++項目。我能夠在C#中引用此文件,並查看/使用DLL文件中的所有對象和函數。我需要做的是通過VB6引用這些對象和功能。如何在不通過COM的情況下從VB6調用C++ DLL?
C++代碼沒有任何內容,看起來像是在創建一個DLL。沒有'__declspec(dllexport)'修飾符,只是C++代碼。
有對象是這樣的:
String^
Array^
我不能完全確定它們是什麼。我對C++的瞭解不是非常廣泛,我只是用C++編寫Linux系統,儘管從使用它們看起來像指針。這些對象與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)];
試過了。我能夠引用它,但我看不到任何對象或方法。 – 2010-10-01 22:58:19
@Mike - 您應該能夠在OLEVIEW.EXE中查看TLB文件 - 您是否看到要訪問的內容? – 2010-10-01 23:01:29
@Steve - 在oleview中,除了UUID,版本等,TLB文件是空的。聲明'庫MyObject {}'是空的。 – 2010-10-04 15:49:46