[C++] DLL question

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

[C++] DLL question

Postby xenose » Thu Sep 13, 2018 7:35 pm

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.
xenose
 
Posts: 2
Joined: Thu Sep 13, 2018 6:57 pm

Re: [C++] DLL question

Postby rlebeau » Fri Sep 14, 2018 9:49 am

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.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1560
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: [C++] DLL question

Postby xenose » Mon Sep 17, 2018 7:10 am

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!
xenose
 
Posts: 2
Joined: Thu Sep 13, 2018 6:57 pm


Return to Technical

Who is online

Users browsing this forum: No registered users and 12 guests

cron