.CPP导出函数extern "C" WININETAPI wchar_t* ExportSession(CWininetHook* pObject,wchar_t* url)
{
if(pObject != NULL)
{
//return pObject->GetSession(url);
return url;
}
return NULL;
}C#调用函数 [DllImport("wh.dll")]
static private extern string ExportSession(IntPtr p,string url );
C#和VC++都是在.NET4框架下.Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'D:\SoftWare\WHC100504\WHC\Debug\MyIE.exe'.
Additional Information: A call to PInvoke function 'MyIE!MyIE.Form1::ExportSession' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
{
if(pObject != NULL)
{
//return pObject->GetSession(url);
return url;
}
return NULL;
}C#调用函数 [DllImport("wh.dll")]
static private extern string ExportSession(IntPtr p,string url );
C#和VC++都是在.NET4框架下.Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'D:\SoftWare\WHC100504\WHC\Debug\MyIE.exe'.
Additional Information: A call to PInvoke function 'MyIE!MyIE.Form1::ExportSession' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
[DllImport("wh.dll", EntryPoint="ExportSession", SetLastError=true, CharSet=CharSet.Unicode, ExactSpelling=true, CallingConvention=CallingConvention.Cdecl)]
static private extern string ExportSession(IntPtr p,string url );DllImport
http://a18zhizao.com/y2009/1052_the-usage-of-c-dllimport.html
但又产生另外一个错误:Windows has triggered a breakpoint in MyIE.exe.This may be due to a corruption of the heap, which indicates a bug in MyIE.exe or any of the DLLs it has loaded.This may also be due to the user pressing F12 while MyIE.exe has focus.The output window may have more diagnostic information.还是不能得到我想要值,不知道从何入手?