Results 1 to 6 of 6

Thread: How to get an array of bytes from a DLL?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: How to get an array of bytes from a DLL?

    it would be better to see the code from application where your problem appears, and you are showing code from some application not connected with problem... and I think it's rather just-in-time debugger or something like that which is caused by some error in your application - "segmentation fault" would be my guess, probably you're returning pointer to no more existing data or something like that. Can you show us the code? And try to use debbuger to see where the error occurs - much faster then asking us to resolve problem which is exactly that what debbuger should find in a blink of an eye.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  2. #2
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: How to get an array of bytes from a DLL?

    I am using QtCreator to build the application

    The DLL is built using VS and it is working as it has to. There are no problems with the dll

    My task is to, use the DLL, get the array of bytes from it, and display it.

    I had tried the same thing, but instead of array of bytes, i had to get a string from a different DLL.

    the code for that is shown in my earlier post.

    I tried using QByteArray but i am getting only 1 character return. I dont know if its working or some sort of bug in the code.

    Qt Code:
    1. QLibrary *loadLibrary = new QLibrary("sample_for_rohit");
    2.  
    3. loadLibrary->load();
    4. if (loadLibrary->isLoaded() == false)
    5. qDebug()<<"error not loaded";
    6. else
    7. qDebug()<<"loaded";
    8.  
    9.  
    10. typedef QByteArray (*MyPrototype)();
    11. MyPrototype myFunction = (MyPrototype) QLibrary::resolve("sample", "TestDll");
    12.  
    13. QByteArray ba = myFunction();
    14.  
    15. char *b = ba.data();
    16.  
    17. ui->dispEdit->setText(b);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: How to get an array of bytes from a DLL?

    and what that function in DLL is returning exactly?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  4. #4
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: How to get an array of bytes from a DLL?

    It returns a array of bytes. (not a string)

  5. #5
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: How to get an array of bytes from a DLL?

    I don't know C++ type named "array of bytes"...
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. Phonon issues with DirectSound9
    By Zoltán in forum Qt Programming
    Replies: 2
    Last Post: 2nd February 2009, 02:48
  2. QTcpSocket exception.
    By Fastman in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2008, 13:51
  3. How many bytes did i send?
    By yagabey in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2008, 10:12
  4. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 09:16
  5. How to construct Image from Bytes
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 29th January 2007, 05:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.