在C++中导入 DLL 函数
import a dll function in C++
我有一个名为swedll32的Dll文件.dll用于天文计算。我已经在 C# 中导入了这些函数并正在使用它们。但是在 C++ 中,我已经尝试了所有可能的方法来导入这些函数,但它不起作用。
请有人演示如何导入例如具有给定名称的函数吗?
int swe_calc_ut(double tjd_ut,int ipl,int iflag,double* xx,char* serr)
,哪里tjd_ut =儒略日,世界时IPL = 正文编号iflag =一个 32 位整数,包含指示所需计算类型的位标志。
xx=经度、纬度、距离、速度(以长为单位(、以纬度为单位的速度和以远处为单位的速度的 6 个双精度数组。
serr[256] =字符串,用于在出现错误时返回错误消息。
虽然以下内容仍然有效,但此堆栈溢出答案也可能有所帮助。
本文包含一个从 DLL 导入函数的示例,但要点是:
int CallMyDLL(void){
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary("C:\MyDLL.dll");
/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"MyFunction");
/*
Define the Function in the DLL for reuse. This is just prototyping the dll's
function.
A mock of it. Use "stdcall" for maximum compatibility.
*/
typedef int (__stdcall * pICFUNC)(char *, int);
pICFUNC MyFunction;
MyFunction = pICFUNC(lpfnGetProcessID);
/* The actual call to the function contained in the dll */
char s[]= "hello";
int intMyReturnVal = MyFunction(s, 5);
/* Release the Dll */
FreeLibrary(hGetProcIDDLL);
/* The return val from the dll */
return intMyReturnVal;
}
相关文章:
- Visual c ++,使用字符串引用/指针调用 dll 函数
- 在 Microsoft Access SQL 中调用自定义 DLL 函数时传递的内存地址无效
- 调用 "project" 函数和调用 DLL 函数之间的区别
- 代码在 msvcrt .dll函数上设置断点失败
- VB.NET DLL中的C++DLL函数复制
- 在python-ctypes中声明变量并传递给dll函数
- 从 Python 调用 Windows DLL 函数时出错
- 调用 dll 函数时"Run-Time Check Failure #0 - The value of ESP"
- 列出 C# 中的 non-.NET DLL 函数
- 基本 DLL 函数
- 如何在不可修改的源代码中使用 DLL 函数?
- 对需要双精度数组和结构作为输入C++ DLL 函数的 C# 调用
- WScript.CreateObject 在调用 C++ COM dll 函数时返回空
- 如何在 lua cpp 模块中调用托管 c++ dll 函数
- 测试C++ DLL 函数
- 从 C# GUI 将 char * 参数传递给C++ dll 函数
- 使用指针调用C++ DLL 函数
- 在C++中导入 DLL 函数
- #VALUE!在 64 位 Excel 中调用 DLL 函数 (C++) 时
- 如何从 UWP 应用调用"libheif.dll"函数