本文介绍了在Vb 2010中调用C ++ DLL函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
-SA double __stdcall Dif(int a)
{
if (a != 1300)
{
return value;
}else
{
return 9048034884;
}
}—SA
double __ stdcall Dif( int a) { if (a!= 1300 ) { return value ; } else { return 9048034884 ; } }
这是我在C ++中的功能。 我想要从VB 2010调用此dll函数。 请帮助我这样做。
解决方案Imports System.Runtime.InteropServices Public Class Form1 < DllImport( Dlllock.dll , CallingConvention:= CallingConvention.StdCall)> _ 私有共享函数Dif(< MarshalAs(UnmanagedType.I4)> ByVal b As Integer)As Double 结束函数
昏暗 a As Double a = Dif( 1300 ) MsgBox(a)
你需要的是P / Invoke: en.wikipedia/wiki/Platform_Invocation_Services [ ^ ]。 你真的需要学习如何使用它。请从这里开始: msdn.microsoft/library/en-us/ vcmxspec / html /vcmg_PlatformInvocationServices.asp [ ^ ]。 此CodeProject文章也很有用: Essential P / Invoke [ ^ ]。 祝你好运,
This is my function in C++. I want to call this dll function from VB 2010. Please Help Me to do this.
解决方案 Imports System.Runtime.InteropServices Public Class Form1 <DllImport("Dlllock.dll", CallingConvention:=CallingConvention.StdCall)> _ Private Shared Function Dif(<MarshalAs(UnmanagedType.I4)> ByVal b As Integer) As Double End FunctionDim a As Double a = Dif(1300) MsgBox(a)What you need is called P/Invoke: en.wikipedia/wiki/Platform_Invocation_Services[^]. You really need to learn how to use it. Please start here: msdn.microsoft/library/en-us/vcmxspec/html/vcmg_PlatformInvocationServices.asp[^]. This CodeProject article can also be useful: Essential P/Invoke[^]. Good luck,
更多推荐
在Vb.net 2010中调用C ++ DLL函数
发布评论