Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I need export the functions in an exe, how to do this? Please help me. Thanks.
Posted

You can't really directly export a function from an exe to another process, I guess it would help to understand what it is you're trying to achieve

If you've got some really cool code you want to re-use somewhere else, pull that code into a DLL and use it from both exes

If you want some form of inter-process communication, you have a number of options, including

1. COM/RPC - but this is a sledgehammer to crack a nut
2. Mailslots/Pipes/Sockets - if you just need to move data between
3. MemoryMapped files - if you want to share memory

take a look at http://msdn.microsoft.com/en-us/library/aa365574(VS.85).aspx[^]
 
Share this answer
 
A bad design if you export a function from an EXE. Well, may I ask who will IMPORT that function - a DLL in same process?

You can export a function using
__declspec(dllexport) int yourfunction();


and import as:

__declspec(dllimport) int yourfunction();


Are you serious you are using VC6 still ??
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-May-11 22:49pm    
This is correct, my 5. There are cases when this is useful. For example, your process can host some plug-ins if the form of DLLs; so this is the way to pass plug-in API. It works.
--SA
Ajay Vijayvargiya 5-May-11 22:57pm    
Well, that simply means the EXE should have .LIB file with it, OR the DLL would load the function dynamically using GetProcAddress. I would prefer a callback function, which would be imported from DLL, and EXE would call that function, passing the address (name) of the function in EXE.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900