I want to ask a question about how to call VB.NET DLL from a C ++ program
I tried calling the VB.NET DLL file from C ++ many times and it works fine, but the problem is that I cannot call the VB.NET DLL file function (I can only load the VB.NET DLL file)
in VB.NET DLL I have the following code:
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
==============================
My C ++ code:
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); }
My next steps:
1) I created the VB.NET DLL.
2) I created a new visual C ++ application and selected "win32 console application"
3) I wrote code to call DLLs and functions (as you can see above)
I missed anything in the step or code because I can call the VB.NET DLL file, but I cannot name the VB.NET DLL function
as you can see, I wrote GETLASTERRIR () to find ERROR
cout <GetLastError () <cps;
but I found this error 127 in the function on failure and 203 in the call dll
can someone help me
Thank you very much
Hello
source share