我想问关于如何从 C++ 程序调用 VB.NET DLL 的问题
我曾多次尝试从 C++ 调用 VB.NET DLL 文件,它工作正常,但问题是我无法调用 VB.NET DLL 文件的功能(我只能加载 VB.NET DLL 文件)
在 VB.NET DLL 中,我有以下代码:
Public Function example_function1(ByVal i As Integer) As Integer
Return 3
End Function
Public Function example_function2(ByVal i As Integer) As Integer
Return 3
End Function
==============================
我的 C++ 代码是:
typedef int (__stdcall *ptf_test_func_1_type)(int);
typedef int (__stdcall *ptf_test_func_2_type)(int*);
int i =1;
HINSTANCE dll_instance = LoadLibrary("DLLs7.dll");
int main()
{
if(dll_instance !=NULL)
{
printf("The DLLs file has been Loaded \n");
cout << GetLastError() << endl;
ptf_test_func_1_type p_func1=(ptf_test_func_1_type)GetProcAddress(dll_instance,"Class1::example_function1");
ptf_test_func_2_type p_func2=(ptf_test_func_2_type)GetProcAddress(dll_instance,"Class1::example_function2");
// Function No 1 //
if (p_func1 != NULL)
{
cout << "\nThe function number 1 is " << p_func1(i) << endl;
}
else
{
cout << "\nFailed" << endl;
cout << GetLastError() << endl;
}
// Function No 2 //
if (p_func2 != NULL)
{
cout << "\nThe function number 2 is" << p_func2(&i) << endl;
}
else
{
cout << "\nFailed" << endl;
cout << GetLastError() << endl;
}
}
else
{
printf("\nDLLs file Load Error");
cout << GetLastError() << endl;
}
cout << GetLastError() << endl;
return(0);
}
我的以下步骤是:
1) 我已经创建了 VB.NET DLL。
2)我创建了一个新的应用程序visual C++并选择了“win32控制台应用程序”
3)我已经编写了调用 DLL 和函数的代码(如上所示)
我是否错过了步骤或代码中的任何内容,因为我可以调用 VB.NET DLL 文件但我不能调用 VB.NET DLL 函数
如您所见,我已经编写了 GETLASTERRIR() 来查找错误
cout << GetLastError() << endl;
但是我在失败时在函数中发现了这个错误 127,在调用 DLL 文件中发现了 203
谁能帮我
非常感谢
问候