|
By shared I mean the same object is used by all dlls, so it is your first statement. I want all the programms to modify the same object. But right now I have a library (not dll), let's call it sdk.lib which has definition of the global object. My main program is linked with this library (so it has access to the global object). Then I have a dll, which is also linked with the sdk.lib. The question is what is the way to have main program and dll use the same global object defined in sdk.lib (not to have different instances, but to refer to the same one). Maybe I can not do it with a statically linked library sdk.lib?
In general, I want to have an sdk (like Photoshop SDK for example), so people could design their own plug-ins to be used in my program. And I am trying to understand the proper way to set-up my vc projects.
Regards,
Alexander.
|
|
|
|
|
Do you want 2 programs that run concurrently to be able to affect changes to objects in this DLL.
Process 1 changes something in the DLL and Process 2 can use this change? Or do you just want to share code among different programs.
You say you want to share data -- but it seems like you don't really need to. Shared DLLs with shared live data is a difficult thing to do.... And not often is it really needed.
Plug-ins are really just shared code packaged into a DLL. They often do not intend to be a machine wide data resource....
Consider your needs carefully.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
There is no need for two programs to change objects in DLL.
I want to enable plug-ins to modify objects, that are used by the main program. Plug-ins are loaded by the main program. Once plug-in is loaded I want to call a function from the plug-in and this function will do something, that changes objects in the main program (I could pass these objects as function parameters, but there is another way, because all sdk's do that). Example: My program draws a cube, cube has color for each side, I want that any plug-in could change these colors. So I create library (sdk.lib), which has definition of the cube class (CCube) and global instance of this class (CCube global_cube;). Then I create program, which setups window and calls global_cube.Draw() function. This works fine, but... I want to load a dll, which has function DoIt() and this function should call global_cube.ChangeColors(). This requires both main program and dll to refer to the same global_cube object.
And this is the point, where I have problems.
Regards,
Alexander.
|
|
|
|
|
I predict __declspec and interfaces will be in your future....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
sjcomp wrote:
It looks like main program has its own version and each dll has its own version, while I want it to be shared.
Dear sir,
Have you declared the global object as "extern" ?? In that way all the modules would share the same variable Otherwise each would create its own version.
For example,
Suppose In sdk.cpp we have the global object
//sdk.cpp
CGlobalClass gObject; //This is the actual instance
Now in Main.cpp and all plugins declare like..,
//Main.cpp
extern CGlobalClass gObject;
Do the same in all cpp files where the Global object appears.
Thanking you,
Yours,
P.GopalaKrishna.
|
|
|
|
|
What about functions, which refer to the same objects? Let's say I have my global object gObject and I have function DoSome(); in my sdk.cpp. Which does something with gObject. Would it still work properly? My confusion is, that once object is decleared external, it means, that it will be referenced at linking. But it will be linked with main program and the dll separately, which would cause them to have two different versions of the same object. I have a feeling that extern works only for the code in the same project, i.e. object files linked together. So it will not solve my problem. Maybe I am wrong, so I will try it.
Thanks everyone, who is helping me, I really appreciate your help.
Regards,
Alexander.
|
|
|
|
|
Dear sir,
You were right. Extern helps only with in the same project. Since others have already have already given the correct mechanisms for dll's I just didnt mention them. we should, as every one pointed out, use those dll export and import mechanism across executalbes. Sorry for that.
By the way as a matter of fact, if you distribute the SDK in Object files (rahter than in dlls) then we could as well get along with the externs !!
Thanking you,
Yours,
P.GopalaKrishna.
|
|
|
|
|
Hi, everyone.
Thank you for your help. But I am still missing the whole picture. Let me try to explain my confusion once more. I will describe the setup and I would need to know how to connect it
--- sdk.cpp --- compiles into sdk.lib
// defines global object
int& GetGlobal()
{
static int global_int=1;
return global_int;
}
--- sdk.h ---
extern "C" __declspec(dllimport)
int& GetGlobal();
--- plugin.cpp --- compiles into plugin.dll
#include "sdk.h"
// does something with a global object
extern "C" __declspec(dllexport)
void DoIt()
{
int& val=GetGlobal();
cout<
|
|
|
|
|
I am not really expecting an answer, but some clues...
Upon opening a socket, the socket opening doesn't fail. Yet, WSGetLastError() is returning a "file not found" error (a non winsock error).
Upon watching the file system (using FILEMON from SysInternals.com), I notice that my attempts to open a socket yield an attempt to load PSAPI.DLL from my current directory (every time).
This is the file not found, yet does not cause an socket error.
Questions:
1) Should I worry about this?
2) Why is winsock attempting to load PSAPI.DLL each time I create a socket?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
I am currently working on a very important development project for my school, and a serious problem has occured. For some reason, DDX_Control() and GetDlgItem() will not work in CFormView, how am i sopposed to access control handles? I can't find another way around it, because i want to use a list control.
-- Steve
|
|
|
|
|
Don't you have member variables for the controls in your form ? use them directly.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
They should work because I use them in my CFormView. Maybe you deleted something by mistake?
void CMyFormView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ICON_WINDOW, m_IconWindowCtrl);
DDX_Control(pDX, IDC_COMBO_ICONVIEW, m_ComboIconViewCtrl);
}
..
..
..
CListCtrl *pListCtrl = (CListCtrl *) GetDlgItem(IDC_ICON_WINDOW);
|
|
|
|
|
Why I can't use "\\servername\....\test.txt"?
When I use full path "c:\....\test.txt" it is fine.
|
|
|
|
|
Are you using CreateFile()? I got sick of that function for this reason and switched to the old <stdio.h> file functions. example:
FILE *file = fopen("\\servername\....\test.txt", "r");/*"r" means you're
reading the file........*/
if (file)
{
while (!feof(file)) /*while the file has not reached end of file*/
{
/*whatever........ go to cplusplus.com for a complete file function reference, type in "file functions" into the search field*/
}
fclose(file);//close the file
}
-- Steve
|
|
|
|
|
use "\\\\servername\\....\\test.txt"
and it will work
|
|
|
|
|
|
and you've tested the same filename string in a program like notepad?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
|
How about a code snippet?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
i've written a snmp class that uses winsnmp, i'am facing a problem when quering a Win2000 or WinXP snmp agent, the response time is more than 10ms. i've seen applications that can do that much faster like my code, any suggenstions ??
Thank you!
|
|
|
|
|
SNMP is based on UDP and is considered extremely low priority. It's possible that the servers where the agents are running have higher priority tasks.
Joe Woodbury
When all else fails, there's always delusion.
- Conan O'Brien
|
|
|
|
|
but this is with all servers/workstations, is there any way to boost the priortiy, do you have a glue how other programs might do that ?
mario prem
|
|
|
|
|
I have no idea, sorry.
Joe Woodbury
When all else fails, there's always delusion.
- Conan O'Brien
|
|
|
|
|
yeateday i posted following Q:
visible spaces of a Tab ('\t') character equal to 6 space (' ') characters in CRichEditCtrl by default.
in visual c++ ide (not RichEdit), there is a setting which can change visible spaces of a Tab character to any space characters, i want to create a similar setting for our users.
//-------------------------------
a reply says to use SetParaFormat() with TABSTOPS flag.
i tested today, but it doesn't fit our case because it only formats max to 32 TABs in a line, if a line is very long, the format doesn't work fully.
how to solve the Q?
thx.
thanks in advance for any hints and help.
includeh10
|
|
|
|
|
How to determine if the CD ROM door is closed?
|
|
|
|