Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Exporting a function from an EXE to be used by another App


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: May 13, 2016 2:56 AM Last Post By: Ahmed Sayed
Ahmed Sayed

Posts: 173
Registered: 8/9/07
Exporting a function from an EXE to be used by another App  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 12, 2016 1:26 AM
Hi all,

I was wandering if there is a way to export a function from an App EXE the same way we export functions from dlls and use it inside another application? Also can I debug the 1st EXE exported function using Run --> Parameters (2nd App as the Host App and 1st App as Parameters)?

Because i tried it but every time i run the 1st App with the exported function it only get launched normally not launching the second host App.

Any help will be appreciated.
--
The limits of my language mean the limits of my world
Jan Dijkstra

Posts: 206
Registered: 11/4/99
Re: Exporting a function from an EXE to be used by another App  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 12, 2016 7:25 AM   in response to: Ahmed Sayed in response to: Ahmed Sayed
Ahmed Sayed wrote:
Hi all,

I was wandering if there is a way to export a function from an App EXE the same way we export functions from dlls and use it inside another application?

Technically, yes. At least for Windows Desktop targets, but I assume you were referring to those.

However, calling/using them from another application is an entirely different matter. To be able for app #2 to call a function exported by app #1, app #1 needs to be present in the memory space of app #2. And that is something Windows won't allow you to do. There are ways around this (the debugger does this, for example), but normally you are not allowed to do this.

What you could do instead, is to implement your function in a DLL, and link both of your apps with that DLL.

Or, if you must make it an app, build your app as a COM server, and export your function using COM interfaces. Then you can import the type library from app #1 (which now is a COM server) in app #2, and call your function using the COM interface.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Exporting a function from an EXE to be used by another App  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 12, 2016 10:05 AM   in response to: Jan Dijkstra in response to: Jan Dijkstra
Jan wrote:

Or, if you must make it an app, build your app as a COM
server, and export your function using COM interfaces.

Or you can use RPC (Remote Procedure Calls) instead of COM (which uses RPC
internally).

https://msdn.microsoft.com/en-us/library/windows/desktop/aa378651.aspx

Or any number of other IPC mechanisms (named pipes, mailslots, sockets, etc)
to allow app 2 to communicate with app 1.

--
Remy Lebeau (TeamB)
Ahmed Sayed

Posts: 173
Registered: 8/9/07
Re: Exporting a function from an EXE to be used by another App  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 13, 2016 2:56 AM   in response to: Ahmed Sayed in response to: Ahmed Sayed
Thanks for your reply.

But, what the second app will hold is a descendant of a TFrame that needed to be tested inside App1. That's why i want to debug App2 inside App1 using the IDE. They are not client server Apps, and i will link both with run-time packages off course.

App1 will be the host App.
In the Parameters Window i will pass App2 EXE file as a CL Parameter.
App1 will load App2 EXE as if it was a normal dll and get the exported function.
The exported function of App2 will return a new TFrame instance that will be a child to a TabItem control.

The idea is that the user want to use App2 as a standalone or alongside other apps inside App1 as a freame inside a tab control.

If it not possible in the IDE to do so while testing is it possible to just develop App2 normally and then at run-time attach it to App1 like a dll?

--
The limits of my language mean the limits of my world

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02