Results 1 to 5 of 5

Thread: implementing windows function in qt

  1. #1
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default implementing windows function in qt

    hi..
    i'm trying to convert vc++ code into QT.
    in Vc++the code calls inbuilt function GetProcAddress ()

    After searching on google, i found some info about it.


    GetProcAddress ()
    Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL).
    Syntax
    C++

    FARPROC WINAPI GetProcAddress(
    __in HMODULE hModule,
    __in LPCSTR lpProcName
    );

    I'm not sure about it i.e (GetProcAddress is windows function)
    Correct if i'm wrong.

    How can the same function be implemented in Qt ?

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: implementing windows function in qt

    If there's GetProcAddress, there will no doubt be LoadLibrary too somewhere, in which case, take a look at http://doc.trolltech.com/4.5/qlibrary.html

    In particular, GetProcAddress should match to the 'resolve' function quite nicely.

  3. The following user says thank you to squidge for this useful post:

    aj2903 (2nd December 2009)

  4. #3
    Join Date
    Dec 2009
    Posts
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: implementing windows function in qt

    There is no need to implement your own function for GetProcAddress

    Qt also provide the dll loading functinality through QLibrary class

    you can look into this class..


    here is a sample code for the same.......


    QLibrary library( "dll_Name" );
    library.resolve("Function_Name"); // same as GetProcAddress


    I hope it will resolve your problem

  5. The following user says thank you to arashadsaifi for this useful post:

    aj2903 (2nd December 2009)

  6. #4
    Join Date
    Jul 2009
    Posts
    36
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: implementing windows function in qt

    Is there any example of Qt In which dll is used.
    When I load a dll by using GetProcAddress() I had get error i.e. function is not declare.

    Can anyone have any Idea to solve this problem or small example of How to use dll in Qt.

  7. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: implementing windows function in qt

    If GetProcAddress doesn't work for you, then Qt resolv function is unlikely to work either.

    But here goes:

    Qt Code:
    1. typedef void (*proto)();
    2. QLibrary lib("somelib");
    3. proto func = (proto) lib.resolve("dosomething");
    To copy to clipboard, switch view to plain text mode 

    you can then use 'func' as a normal function pointer, ie: func()

    Note that you do not need the '.DLL' part of the library. This is assumed automatically and makes the code more portable (ie, when compiled under Linux, it will automatically add '.so' instead)

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Regading Driver to connect Postgresql Database
    By dummystories in forum Installation and Deployment
    Replies: 38
    Last Post: 12th March 2009, 07:19
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.