How to make a variable unique in the program?



Hi,

Recently I downloaded a trace library from internet.

Here is some code:

//The user can't use XYTraceHelper directly
class XYTraceHelper
{
XYTraceHelper();
...
protected:
HANDEL m_hFile;
};

XYTraceHelper theHelper;

WRITETRACE(LPCTSTR szFormat, ...)
{
//save trace info into file
theHelper.Write(... );
}


In the constructor of XYTraceHelper the m_hFile will be initialized. And
because there is only one instance of XYTraceHelper (theHelper), all the
trace infomation will be wrote in a single file.

But if I use the library both in exe and dll, there woudle be two trace file
saved. This isn't what I want. I want to use the same "theHelper" in both
exe and dll. What should I do?

Thanks in advanced.





.



Relevant Pages


Loading