在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失败!");
}
qtdllLoadlibrarymfc