|
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?
|
|
|
|
|
I'm building an app just as a personal toolbox for myself (may become cp article) and I'm looking for some suggestions. This app will need a database of some sort, and I'm leaning on using an embedded database rather then using MySQL or other service.
I've looked at the XML database options, but I don't like the idea of how large those files could potentially become. Anyone know of any free alternatives? Any database libs out there that I can embed into my app?
It doesn't have to be fully SQL complient, but I would like to be able to do simple joins at the bare minimum.
My code isn't buggy. Those are all fleatures.
|
|
|
|
|
|
SQLite seems popular and well supported, so this could be a good way to go. I don't like the fact that it is written in C and some other things are strange, but this is very personal stuff.
I'm working on app that uses pugXML (here on CP) as its database, and am very, very happy with this.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Ever think about MSDE as a database?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|