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.
Printable View
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.
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
Hi,
I meen to export function form .EXE module and then import this function into .DLL.
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?
Don't believe it. if you have 4.2 or higher version of the C++ use and dllimport storage-class attributes properly.
Hi,
Would you write some sample code please.
Thanks in advance !
Hi,
I'd like to use a simple C++ function, not any COM object. Is it necessary using of COM-based classes?
This is BS.
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.
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
BS BS BS.
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]
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.
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
Hi,
Thank you very much. I'll try this.
Thanks once again !