CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    May 1999
    Posts
    61

    Help me to import function from .EXE to DLL

    Hi,
    I need your help. I cant't export function from EXE and import it into DLL.
    I'd like to tell me what I must do for my problem's decision.
    This DLL is linked with that EXE - file.


  2. #2
    Join Date
    Sep 1999
    Posts
    9

    Re: Help me to import function from .EXE to DLL

    In exe Go to Menu Project\settings and on Link tab
    type name of your yourdll.Lib file in Text box
    Object\Library Module then compile exe.

    before this don't ferget to declare function in dll as
    extren "C" _dllspec(dllexport) void Function();
    and declare same function in exe
    as
    extren "C" _dllspec(dllimport) void Function();



    Please let me know if this works


  3. #3
    Join Date
    May 1999
    Posts
    61

    More exactly !

    Hi,
    I meen to export function form .EXE module and then import this function into .DLL.


  4. #4
    Join Date
    May 1999
    Location
    Texas, USA
    Posts
    568

    Re: More exactly !

    It cannot be done unless your EXE is a full server. And then you are not necessarily exporting functions, you are exporting COM objects. But it can be done that way.

    What kind of function is it anyway?


  5. #5
    Guest

    Re: Help me to import function from .EXE to DLL

    Don't believe it. if you have 4.2 or higher version of the C++ use and dllimport storage-class attributes properly.


  6. #6
    Join Date
    May 1999
    Posts
    61

    Some help ?

    Hi,
    Would you write some sample code please.
    Thanks in advance !


  7. #7
    Join Date
    May 1999
    Posts
    61

    Simple function

    Hi,
    I'd like to use a simple C++ function, not any COM object. Is it necessary using of COM-based classes?


  8. #8
    Guest

    Re: More exactly !

    This is BS.



  9. #9
    Join Date
    May 1999
    Location
    Texas, USA
    Posts
    568

    Re: More exactly !

    Okay if it is bs, then tell him how to do it.

    I cannot see how to export a function from an exe into a dll without it being a COM full server. And to be honest why would you want to export from an EXE to a DLL?

    Please enlighten me.


  10. #10
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help me to import function from .EXE to DLL

    Are you saying that instead of

    - an EXE calling a DLL function

    you want to

    - call the EXE function from the DLL?

    If we are talking about the same thing, the way that you would do this that I am aware of is to supply a callback function to the DLL. In other words, the DLL defines a function pointer, and the EXE tells the DLL to set the function pointer to one of the functions in the EXE. Once this is done, the DLL makes an indirect call on the function pointer whenever it wants to call the EXE function.

    This method has been used since 16-bit Windows. Back in those days, the function would have to be "exported" and the DLL would have to call MakeProcInstance() on the passed function pointer to get the thunk correct. For 32-bit Windows, you don't need to do this anymore.

    If this is what you want, then this is the way of doing it. There is no need for COM or anything like that.

    Regards,

    Paul McKenzie


  11. #11
    Guest

    Re: More exactly !

    BS BS BS.


  12. #12
    Guest

    Re: More exactly !

    BS is a right term.
    I will send you a code sample of class exported from exe to a dll.
    Class CChildFrameInExe is used in the dll to derive CChildFrameInDLL. CChildFrameInDLL is used in exe to register template and use it as child frame of the app.

    Good luck,

    [email protected]



  13. #13
    Join Date
    Aug 1999
    Location
    Belgium
    Posts
    206

    Re: More exactly !

    Hi,

    I am interested in your "magical" EXE export - DLL import approach. If it works It could be an interesting technique. Could you post or send an example please?

    Best Regards,

    GBO.


  14. #14
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Some help ?

    Drago, see my response. And I think you have to be more clear as to what you are trying to do. Like I stated, if it is as simple as trying to make the DLL call an EXE function at certain points within the DLL, then the simple function pointer and callback mechanism is all that you need to do.

    As a matter of fact, look at functions such as SetTimer(), EnumWindows(), etc. If you take a look at the prototypes to these Windows API functions, your application supplies an application defined callback function. This callback function is then called by, guess what?...KERNEL32.DLL, USER.EXE, or GDI.EXE!

    If you don't understand function pointers, then the "sample code" that you want would be best served if you study how to call an indirect function given a function pointer. This is all you need to know, and is basic C++ with really nothing to do with Windows. Any good book on C++ (or even C) covers function pointers. This sounds like the easiest approach to me instead of fiddling around with importing/exporting/COM etc.

    Regards,

    Paul McKenzie


  15. #15
    Join Date
    May 1999
    Posts
    61

    Thanks

    Hi,
    Thank you very much. I'll try this.
    Thanks once again !


Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured