سلام.
من یک DLL ایجاد کردم و برای نمونه یک تابع با نام MyFunc برای اون ایجاد کردم:
APIFunctions.h
#ifdef APIFUNCTIONS_EXPORTS
#define APIFUNCTIONS_API __declspec(dllexport)
#else
#define APIFUNCTIONS_API __declspec(dllimport)
#endif
// This class is exported from the APIFunctions.dll
class APIFUNCTIONS_API CAPIFunctions {
public:
CAPIFunctions(void);
// TODO: add your methods here.
public:
int MyFunc(int a);
};
//0x8007000B
extern APIFUNCTIONS_API int MyFunc(int a);
APIFUNCTIONS_API int MyFunc(int a);
extern APIFUNCTIONS_API int nAPIFunctions;
APIFUNCTIONS_API int fnAPIFunctions(void);
APIFunctions.cpp
#include "stdafx.h"
#include "APIFunctions.h"
// This is the constructor of a class that has been exported.
// see APIFunctions.h for the class definition
CAPIFunctions::CAPIFunctions()
{
return;
}
int CAPIFunctions::MyFunc(int a)
{
return (a * 2);
}
من می خوام توابع این فایل dll رو از طریق تعریف تابع بصورت Declare در VB.Net استفاده کنم. منتها خطایی به این مضمون ارسال می کنه:
Declare.jpg
همچنین فایل dll رو در پوشه برنامه قرار دادم و تابع API رو به اینصورت تعریف کردم:
Declare2.jpg
من تجربه ای در ++VC ندارم پس ممکنه مشکلی در تعریف تابع باشه یا برای Compile خصوصیات رو صحیح تعیین نکرده باشم، چطور می شه این خطا رو برطرف و از تابع استفاده کرد؟