Loadlibrary失败,错误127

仒雨 2013-09-25 04:43:57
在HookDll.dll(全局钩子)里调用由Qt(Qtwinmigrate)编写的dll,出现Loadlibrary加载失败的情况,错误代码127,但是Qt编写的那个dll已经放到相应目录了,我也尝试了将由Qt编写dll的DllMain中所依赖的一些dll譬如说MINGWM10.dll、LIBGCC_S_DW2-1.dll、QTCORE4.dll、QTGUI4.dll放到了exe的目录,却还是出现127的错误。
我在Qt的那个dll里加个简单的接口却能够在新创建的mfc对话框工程中正常调用

Qt编写的dll部分main.cpp中部分内容如下:
extern "C" __declspec(dllexport) bool showDialog( HWND parent )
{
QWinWidget win( parent );
win.showCentered();
QMessageBox::about( &win, "About QtMfc", "QtMfc Version 1.0\nCopyright (C) 2003" );

return TRUE;
}

extern "C" __declspec(dllexport) int GetCtrlState(HWND ctrlHwnd)
{
QWidget *myWidget=NULL;
myWidget=QWidget::find(ctrlHwnd);
if (myWidget==NULL)
return -1;
QCheckBox *myCheckBox= qobject_cast<QCheckBox *>(myWidget);
if (myCheckBox->checkState()==Qt::Unchecked)
{
return 0;
}
else if (myCheckBox->checkState()==Qt::Checked)
{
return 2;
}
else
{
return 1;
}
}

extern "C" __declspec(dllexport) int Add(int i,int j)
{
return i+j;
}
在钩子dll里部分代码如下:
结构体的定义部分
struct VarChilds{
IAccessible** paccChild;
VARIANT* pvarChild;
CRect rectPos;
};
调用qt编写dll的部分:
std::vector<VarChilds>::iterator itChild;
itChild=childs.begin();

HWND temp1=NULL;
WindowFromAccessibleObject(*(itChild->paccChild),&temp1);
if (temp1==NULL)
OutputDebugString("句柄temp1为空!\n");
HINSTANCE hiTemp=NULL;
hiTemp=LoadLibrary("qtdialog.dll");
if (hiTemp==NULL)
OutputDebugString("Dll入口hiTemp为空!\n");
DWORD dw=GetLastError();
TCHAR chDw[100]={0};
sprintf(chDw,"错误:%d\n",dw);
OutputDebugString(chDw);
CString strDw;
strDw.Format("错误:%d\n",dw);
OutputDebugString(strDw);
typedef int (*pGetCtrlState)(HWND ctrlHwnd);
pGetCtrlState GetCtrlState=(pGetCtrlState)GetProcAddress(hiTemp,"GetCtrlState");
if (GetCtrlState)
{
int stateTemp=GetCtrlState(temp1);
CString strTemp1;
strTemp1.Format("控件状态:%d\n",stateTemp);
OutputDebugString(strTemp1);
}
else
{
OutputDebugString("在HookDll中导入qtdialog.dll失败!");
}
...全文
494 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
仒_雨 2013-10-18
  • 打赏
  • 举报
回复
缺少dll所以来的动态链接库,用depends打开看就知道了应该

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧