Reputation: 239
My friend and I are working on a project.
He gave me a .dll file which can activate web camera and stream the view.
He also gave me a small example project written in VS2013 MFC that demos the function.
typedef int(*ExtportFuncA)(void);
typedef int(*Open)(void);
void Ctrydll2Dlg::OnBnClickedOk()
{
//CDialogEx::OnOK();
ExtportFuncA ga = NULL;
HINSTANCE hLib = LoadLibrary(_T("ShowImg.dll"));
if (hLib)
{
ga = (ExtportFuncA)GetProcAddress(hLib, "ExtportFuncA");
ga();
}
system("pause");
}
void Ctrydll2Dlg::OnBnClickedButton1()
{
Open gb = NULL;
HINSTANCE hLib = LoadLibrary(_T("ShowImg.dll"));
if (hLib)
{
gb = (ExtportFuncA)GetProcAddress(hLib, "Open");
int system = gb();
if (system == -1)
{
printf("not get device");
}
}
}
However, I failed to load that .dll file in QT project.
#include <QCoreApplication>
#include <QLibrary>
#include <QDebug>
typedef int (*ExportFuncA)(void);
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QLibrary lib("ShowImg.dll");
lib.load();
if(!lib.load())
{
qDebug() << "Cannot Open Library";
return 0;
}
ExportFuncA CLI = (ExportFuncA)lib.resolve("ExportFuncA");
if(!CLI)
{
qDebug() << "Cannot Load Function";
return 0;
}
printf("Hello World");
return a.exec();
}
The error always shows "Cannot Open Library", that means the .dll cannot be loaded at the beginning,
but my friend's demo project runs fine on my computer, I can see the camera's image.
I suspect the problem is related to 32bit and 64bit format,
but since I am not familiar with .dll file, any suggestion will be grateful.
Upvotes: 0
Views: 2524