0

我是在 c++ 中使用 .dll 的新手,并试图在我的代码中加载一个 .dll 文件。dll 是“Extremely Simple Capture API”或 escapi.dll 。我从中获得 .dll 的站点不包含带有 .dll 的库文件,并且考虑到我不知道如何使用库文件加载 .dll,尝试在没有它的情况下执行此操作会加倍困难。我只想用电脑上的网络摄像头拍一张快照,然后在屏幕上显示图像。

我从 .dll 中使用的函数是:

int setupESCAPI(int height, int width);
int initCapture(SimpleCapParams *capture);
void doCapture();
void isCaptureDone();
void deinitCapture();

如果有人能给我简单的说明,告诉我如何在没有 .lib 文件的情况下包含这个 .dll,我将不胜感激。谢谢。

4

2 回答 2

2

I looked at the download for ESCAPI and it has all you need. Just include escapi.cpp in your project and call setupESCAPI. setupESCAPI loads the DLL for you. You will also need to put the DLL in the same folder as your executable.

于 2014-11-17T20:30:31.397 回答
0

链接到 DLL 的一种优雅方式是动态的。这样就不需要 LIB 文件,并且您可以进行更好的错误管理。这篇文章不错:

http://msdn.microsoft.com/en-us/library/ms810279.aspx

您基本上所做的是在 C++ 中创建要在 DLL 中调用的函数的原型。(不完全是原型,但你可以用同样的方式思考它们)

然后调用 LoadLibrary 加载 DLL,并调用 GetProcAddress 将原型链接到 DLL 中的每个函数。

然后您可以调用您的“函数”(原型)-它们将附加到 DLL 中的函数

于 2014-11-17T20:32:06.103 回答