Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a MainProgram.exe, this program use a MainLibrary.dll. I need to make another MyProgram.exe, that modify this MainLibrary.dll in real time. Every time I change setting in the MyProgram.exe, the MainLibrary.dll receive this settings and use them for the MainProgram.exe.

C#
class MainWindow
{
    public:
        MainWindow();
        ~MainWindow();
        list <SubWindow*> GetVector();
        list <subwindow*> MainWin;
        list <subwindow*>::iterator it;
};

list <SubWindow*> MainWindow::GetVector()
{
    // list <SubWindow*> MainWin;
    return MainWin;
}

list <void*>::iterator it; // ?????
typedef list <void*>(*VECTOR)(); // ?????
VECTOR _VECTOR;

HINSTANCE hDLL = LoadLibrary("Win32Project.dll");

if (hDLL != NULL)
{
    _VECTOR pVectorFunction = (VECTOR)GetProcAddress(hDLL, "GetVector");

    if (pVectorFunction)
    {
        for (it = MainWin.begin(); it != MainWin.end(); it++)
        {
            //do stuff here
        }
    }
}
Posted
Updated 30-Jul-15 4:58am
v7
Comments
Sergey Alexandrovich Kryukov 29-Jul-15 20:55pm    
First, why loading a DLL dynamically? Why not exporting a function and using that exported function? Why not creating an exported function providing access to a vector object?
—SA
chandanadhikari 30-Jul-15 8:14am    
Hello SA,
greetings sir!
The OP has given some clarification regarding his question (please see his comment below).
So there is 1 dll and 2 applications which consume it, at same time. Updates done to the dll from 1 application should be visible to application 2 in real time .
i think some sort of call back functionality will be needed here but, i am not sure if that is the 'best' approach.
can you please suggest some efficient approach OR do you think some basic design change will be a better way to achieve what the OP is trying to do .
many thanks!
chandanadhikari 30-Jul-15 3:33am    
hi,
just trying to understand your scenario :
you have some application(Some.exe) . A dllwithstructure.dll having a datastructure(vector/list) will be loaded into this Some.exe wherein another dll will consume the data structure.
so basically you are trying to pass around the datastructure between separate binaries.
is my understanding correct ??

1 solution

You have to use some sort of Inter-process Communications (IPC) to get your applications communicating, you can't load a DLL and pass it data for the other exe.

There are a variety of IPC options, see the Wikipedia page and read up on your options then find one that suits your needs.
IPC Wikipedia[^]
 
Share this answer
 
Comments
CPallini 30-Jul-15 12:27pm    
5.
Albert Holguin 30-Jul-15 12:50pm    
thanks for the upvote

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