- UID
- 68456
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-7-30
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
因为我要把图传到其它计算机去,要用到dll,而我不会,现在也没有资料。于是就问:在arx中如何使用dll? 就是C调用dll。
这有一个例子,能帮我写出来吗?
dll路径:C:\web.dll
有一个函数:int _stdcall connect(HTTP_CONNECTION **connection, const char *host, short port, const char *username, const char *password)
其中HTTP_CONNECTION 是一个结构体,定义如下
struct http_connection {
SOCKET socketd;
int status;
char *host;
struct sockaddr_in address;
int persistent;
HTTP_AUTH_INFO *auth_info;
};
(其它定义略)
问题:我怎么调用这个函数?比如在head.h 中如何声明,head.cpp中如何使用?
静态如何?
动态如何?
谢谢!
声明:
#define DllImport _declspec(dllimport)
typedef struct http_connection HTTP_CONNECTION;
typedef struct http_auth_parameter HTTP_AUTH_PARAMETER;
typedef struct http_auth_info HTTP_AUTH_INFO;
struct http_connection {
SOCKET socketd;
int status;
char *host;
struct sockaddr_in address;
int persistent;
HTTP_AUTH_INFO *auth_info;
};
struct http_auth_parameter {
char *name;
char *value;
HTTP_AUTH_PARAMETER *next_parameter;
HTTP_AUTH_PARAMETER *prev_parameter;
};
struct http_auth_info {
char *method;
int count;
HTTP_AUTH_PARAMETER *first_parameter;
HTTP_AUTH_PARAMETER *last_parameter;
};
extern "C" int _stdcall dav_init(void);
extern "C" int _stdcall dav_connect(HTTP_CONNECTION **connection, const char *host, short port, const char *username, const char *password);
调用:
HTTP_CONNECTION *connection = NULL;
connection = (HTTP_CONNECTION *) malloc(sizeof(HTTP_CONNECTION));
typedef int(proc1)(HTTP_CONNECTION **connection, const char *host, short port, const char *username, const char *password);
proc1* pFunc1;
HINSTANCE hInstance;
hInstance=::LoadLibrary("C:\\ploting\\webdav.dll");
if(hInstance==NULL)
{
acutPrintf("\n can not fine dll file.");
}
pFunc1=(proc1*)::GetProcAddress(hInstance,"dav_connect");
int test=(*pFunc1)(&connection,(char *)"192.168.0.22",8080,(char *)"maf",(char *)"maf");
acutPrintf("\n test is %d",test);
编译错误:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
是为什么? |
|