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) 新しいアプリケーション ビジュアル C++ を作成し、「win32 コンソール アプリケーション」を選択しました。
3) DLL と関数を呼び出すコードを作成しました (上記を参照)。
VB.NET DLL ファイルを呼び出すことはできますが、VB.NET DLL 関数を呼び出すことができないため、手順またはコードで何か見逃していましたか?
ご覧のとおり、エラーを見つけるために GETLASTERRIR() を作成しました
cout << GetLastError() << endl;
しかし、失敗したときに関数でこのエラー127が見つかり、呼び出しDLLファイルで203が見つかりました
誰でも私を助けることができます
どうもありがとうございました
よろしく