I got a c++ DLL like this:
#include "stdafx.h"
#include <string.h>
#include <iostream>
using namespace std;
BOOL booltest(string info1, string info2, DWORD dword1)
{
if (dword1 == 5)
{
return FALSE;
}
if (!strcmp(info1.c_str(), "hello")) // check if info1 = "hello"
{
return FALSE; // if so return false
}
return TRUE; // if not return true
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
i have a button control on a form in a VB project and I would like to P/Invoke to call the booltest function. but I also need to pass the parameters! And obviously the data types between managed and unmanaged are different..!
Anyone have a working solution to this or useful pointers? I been tryna do this for some time now...
thanks (a sorry for english )
edit: to start?
<DllImport("mydll.dll")>
Public Shared Function booltest(...?) As Boolean
End Function
?
Disclaimer: I'm still learning VB.net so don't hurt me if I'm wrong.
I ran into a similar issue a couple of weeks ago. First, make sure you add a reference to your project for the DLL. Then make sure you use the 'import' statement at the head of your code. After that, you should be able to call a function normally.