Beispiel #1
0
int main(int argc, char *argv[])
{
    double result;
    QCoreApplication a(argc, argv);
    /* 这里创建一个QLibrary对象,libsum.so在之前创建的,用于求和并返回结果的函数 */
    QLibrary mylib2("SiUSBXp");
    mylib2.load();
    QLibrary mylib("GY7502_USBSPI");
    if(mylib.load())
    {
        /* 用load()来加载DLL成功*/
        qDebug() << "load DLL success!\n";
        typedef double (*OpenFunc)();
        /*用resolve来解析sum2函数*/
        OpenFunc device_open=(OpenFunc)mylib.resolve("GY7502_USBSPI_Open");
        if(device_open)
            /* 解析成功,sum2函数指针不为0,可以调动了 */
            qDebug() << "resolve success!\n";
        else
            qDebug() << "resolve failed!\n";
        /* 测试一下 */
        result = device_open();
        qDebug() << "opening...";
    }
    else
        qDebug() << "load DLL failed!\n";

    a.exit(0);
}
Beispiel #2
0
void Widget::on_pushButton_2_clicked()
{
   //加载插件
   QLibrary mylib("helloworld.dll");   //声明所用到的dll文件
   if (mylib.load())              //判断是否正确加载
   {
       Funs open=(Funs)mylib.resolve("showDialog");    //援引 add() 函数
       if (open)                  //是否成功连接上 add() 函数
       {
           QDialog *form1= open();
           form1->show();
        }
    }
}
Beispiel #3
0
void Widget::on_pushButton_clicked()
{
    QLibrary mylib("helloworld.dll");   //声明所用到的dll文件
    int result;
    QString sresult;
    if (mylib.load())              //判断是否正确加载
    {
        Fun open=(Fun)mylib.resolve("print_str");    //援引 add() 函数
        if (open)                  //是否成功连接上 add() 函数
        {
             open(QString("hello world"));
        }
    }
    else
    {
        QMessageBox::information(NULL,"NO","DLL is not loaded!");
    }

}
Beispiel #4
0
int main() {
   std::cout << "hello world from the #cccamp2015, the answer is " << std::endl;
   std::cout << mylib(23) << std::endl;
}
bool public_encryption_dog::conductlock()
{
    errsrring.clear();
    //1
#ifdef Q_OS_WIN
    //windows下加密狗
    long nAppID = 1650534242; //应用程序ID, 4字节,通过设号工具设置  注意保密
    long Keys[8]= {0};
    long nKeyNum = 0;

    //QLibrary mylib("NoxApp64.dll");   //声明所用到的dll文件 我的是64位编译器 所以使用64 位dll
    QLibrary mylib(QCoreApplication::applicationDirPath() + "/NoxApp.dll");   //声明所用到的dll文件

    if(mylib.load())
    {
        NoxFind my_NoxFind=(NoxFind)mylib.resolve("NoxFind");
        NoxOpen my_NoxOpen=(NoxOpen)mylib.resolve("NoxOpen");
        NoxGetLastError my_NoxGetLastError=(NoxGetLastError)mylib.resolve("NoxGetLastError");
        NoxReadStorage  my_NoxReadStorage=(NoxReadStorage)mylib.resolve("NoxReadStorage");
        NoxClose my_NoxClose=(NoxClose)mylib.resolve("NoxClose");

        if(!my_NoxFind || !my_NoxOpen || !my_NoxGetLastError || !my_NoxReadStorage || !my_NoxClose)   //保证每个函数导入成功
        {
            errsrring=tr("加密狗错误,导入库错误");
            return false;
            //            return SOFTDOG_ERR_WRONGLIB;
        }

        if(0 !=my_NoxFind(nAppID,Keys,&nKeyNum))
        {
            errsrring=tr("加密狗错误,没有找到加密狗");
            return false;
            //            return SOFTDOG_ERR_NODOG;
        }
        qDebug()<<"There are" <<nKeyNum<<" NOX keys.\n";

        //打开第一只加密锁
        char * userPin = "8c751b20059acb5a"; //用户密码,通过设号工具设置 注意保密
        if( 0 != my_NoxOpen(Keys[0],userPin))
        {
            errsrring=tr("加密狗错误,导入库错误");
            return false;
            //            return SOFTDOG_ERR_WRONGDOG;
        }
        qDebug()<<"Open Key Successfuflly!\n";

        //存储区读(16字节)
        unsigned char readStorage[16] = {0};
        if( 0 != my_NoxReadStorage(Keys[0],readStorage))
        {
            errsrring=tr("加密狗错误,导入库错误");
            return false;
            //            return SOFTDOG_ERR_WRONGDOG;
        }

        //关闭加密锁
        my_NoxClose(Keys[0]);
    }
    else
    {
        errsrring=tr("加密狗错误,没有找到加密狗库文件");
        return false;
        //        return SOFTDOG_ERR_NOLIB;
    }
#endif
    return true;
    //    return SOFTDOG_NOERR;
    //2
}