G
Guest
I'm trying to pinvoke a function in a C++ dll but I'm getting an error that
entry point can not be located from my pinvoke code. Do I need to add any
code to the C++ DLL to make the pinvoke? The following is what I have in my
C# code:
[DllImport("PropSheetHost.dll")]
public static extern void ShowAdProp(
[MarshalAs(UnmanagedType.LPStr)]
String m);
//This is where I invoke the function
private void propertyToolStripMenuItem_Click(object sender,
EventArgs e)
{
ShowAdProp("'CN=1608,CN=Users,CN=Accounting,CN=Contexts,CN=Unity,CN=Symark,CN=Program Data,DC=unity,DC=windev,DC=symark,DC=com");
}
//This is start of the C++ dll
using namespace std;
void ShowAdProp(wstring adPath)
{
CoInitialize(NULL);
HRESULT hr;
HINSTANCE hInstance = NULL;
HWND hwndConsole = GetConsoleWindow();
if(hwndConsole)
{
hInstance = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hwndConsole,
GWLP_HINSTANCE);
}
CPropSheetHost *pHost = new CPropSheetHost(hInstance);
// Hold a reference count for the CPropSheetHost object.
pHost->AddRef();
hr = pHost->SetObject(adPath.c_str());
entry point can not be located from my pinvoke code. Do I need to add any
code to the C++ DLL to make the pinvoke? The following is what I have in my
C# code:
[DllImport("PropSheetHost.dll")]
public static extern void ShowAdProp(
[MarshalAs(UnmanagedType.LPStr)]
String m);
//This is where I invoke the function
private void propertyToolStripMenuItem_Click(object sender,
EventArgs e)
{
ShowAdProp("'CN=1608,CN=Users,CN=Accounting,CN=Contexts,CN=Unity,CN=Symark,CN=Program Data,DC=unity,DC=windev,DC=symark,DC=com");
}
//This is start of the C++ dll
using namespace std;
void ShowAdProp(wstring adPath)
{
CoInitialize(NULL);
HRESULT hr;
HINSTANCE hInstance = NULL;
HWND hwndConsole = GetConsoleWindow();
if(hwndConsole)
{
hInstance = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hwndConsole,
GWLP_HINSTANCE);
}
CPropSheetHost *pHost = new CPropSheetHost(hInstance);
// Hold a reference count for the CPropSheetHost object.
pHost->AddRef();
hr = pHost->SetObject(adPath.c_str());