Page 1 of 1

[C++] DLL question

PostPosted: Thu Sep 13, 2018 7:35 pm
by xenose
I'm trying to create a DLL that the other program can get data and set settings to my program by dll in the same PC.

schematic diagram:
A.exe -> xxx.DLL -> B.exe

xxx.dll and B.exe are the program which I can modify.

There are 2 ways below, I'm not sure which way is feasible, please advise. Thank you very much!
1.Using function pointers that DLL can call function in B.exe
2.Using VCL SocketClient in DLL and B.exe to communicate.

Re: [C++] DLL question

PostPosted: Fri Sep 14, 2018 9:49 am
by rlebeau
xenose wrote:I'm trying to create a DLL that the other program can get data and set settings to my program by dll in the same PC.


Does your app have to be running at the time in order for the DLL to do its work? Or can the DLL do its work even if your app is not running? It makes a big difference in how you implement the DLL.

xenose wrote:1.Using function pointers that DLL can call function in B.exe


That will not work, as A.exe and B.exe will have loaded their own separate copies of xxx.dll and thus cannot (safely) share pointers with each other.

xenose wrote:2.Using VCL SocketClient in DLL and B.exe to communicate.


That is one option, if the DLL requires your app to be running in order to do its work. In general, any IPC (inter-process communication) mechanism will work, as there are many options available besides sockets, including:

- window messages
- named pipes
- mailslots
- RPC (remote procedure call)
- ActiveX/COM

Just to name a few.

Re: [C++] DLL question

PostPosted: Mon Sep 17, 2018 7:10 am
by xenose
rlebeau wrote:Does your app have to be running at the time in order for the DLL to do its work? Or can the DLL do its work even if your app is not running? It makes a big difference in how you implement the DLL.

Have to running at the time in order for the DLL to do its wok

Thank you a lot Remy.
I tried the MapViewOfFile function of windows API and it works!