|
I don't know much about the Smart-pointer. Why is it better?
ccp
|
|
|
|
|
ccp999 wrote: I don't know much about the Smart-pointer. Why is it better?
When it goes out of scope, it automatically deletes the memory it points to, but only if no other smart-pointer points to it.
Just note that the std::auto_ptr which comes with the STL ist something different and unusable for this purpose.
The best implemetation I know of is that at www.boost.org[^]
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
- Root
|-- + Item1
<------File test.xml------->
|-- * Node0........
|---- Item2
|-- o Node1........
| |---- test1
| |---- test1
| |---- test1
+ Example
+ End
1.<------Node------->
Custom item, full of the row. The width of the row is a variable.
The item can't be click, drap&drop, delete and act.
2.|-- o Node1.......
The "o", in front of Node1 is a custom icon, which is a "+" as usual for expanded a item. Not all of icon is changed, only for specifically type.
The "......" behind "Node1" is a line full of the row.
------------------------------------------------
At the end, I'm sorry for my badly English
I'm coding.I'm living
|
|
|
|
|
Small Car wrote: I'm sorry for my badly English
I think your english is better than the problem that you have stated.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Haha
Thank you!
I'm coding.I'm living
|
|
|
|
|
See CTreeCtrl class on MSDN it has three exmples
|
|
|
|
|
what is the purpose of private constructors and destructors ?
|
|
|
|
|
One is to disable creation and destruction of an object except through specific methods.
class CFoo
{
public:
static CFoo* Create() { return new CFoo(); }
static void Destroy(CFoo *pDelete ) { delete pDelete; }
private:
CFoo() {}
~CFoo() {}
};
Steve
|
|
|
|
|
That means Cant we create instance of the class , If the Constructor is private ?
|
|
|
|
|
Actually by placing constructor private you can restrict from creating object without paramater in following manner.
class A
{
private:
A();
public:
A(int i)
{
}
};
In above case object of the class A can be created only by passing any integer value. So that you make the class consistent.
This is the case where constructors are made private.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
One more scenario is here for private constructor when you never want to inherit the class.
You can not derive a child class if all constructors of base class is private..
...
I m a bit confuse about private destructors...
Rahul Agarwal
(Software Developer)
|
|
|
|
|
Rahul_Agarwal wrote: One more scenario is here for private constructor when you never want to inherit the class
can u please elaborate this.
|
|
|
|
|
Search for the term "singleton class", this is one of the occurences where having a private c'tor will come in useful. A singleton is a class where only one instance can be created, any further attempts to create an instance result in a pointer to the first.
|
|
|
|
|
Krishnatv wrote: That means Cant we create instance of the class , If the Constructor is private ?
no you didn't look Stephen's example correctly.
the constructors are private, so, they cannot be accessed from outside the class.
but there is a methode Create in his sample, which actually instanciates the class.
the main purpose for this is to create a singleton class (a class which only one instance exist at a time) :
<font color=green></font>
<font color=blue>class</font> CMyTypeFactory {
<font color=blue>private</font>:
MyType* m_instance; <font color=green>
CMyTypeFactory();
~CMyTypeFactory();
<font color=blue>public</font>:
<font color=blue>static</font> MyType* Create(); <font color=green>
<font color=blue>static void</font> Destroy(); <font color=green>
};
<hr>
<font color=green></font>
CMyTypeFactory::CMyTypeFactory() : {
m_instance = NULL;
<font color=blue>this</font>->Create();
}
<font color=green></font>
CMyTypeFactory::~CMyTypeFactory() {
<font color=blue>this</font>->Destroy();
}
<font color=green></font>
MyType* CMyTypeFactory::Create() {
<font color=blue>if</font> (m_instance == NULL) {
m_instance = <font color=blue>new</font> MyType;
}
<font color=blue>return</font> m_instance;
}
<font color=green></font>
<font color=blue>void</font> CMyTypeFactory::Destroy() {
<font color=blue>if</font> (m_instance != NULL) {
<font color=blue>delete</font> m_instance;
}
}
|
|
|
|
|
I think your greative power is nice,different message
|
|
|
|
|
No it doesn't; it means only member functions of friends can call them.
Steve
|
|
|
|
|
I created a tree control.... Which displaying Folders and files of a particular drive.
In this system volume information,Recyclebin folders are displaying, now i want only display folders and files of that drive only...Not to display system hidden folders
|
|
|
|
|
You can when read file or folders check for attrib if they are system or hidden dont show,how to read files/folders?
|
|
|
|
|
How can I get information about running processes on my computer including process tree, dependencies, memory usage, I/O threads etc. Thank you!
modified 9-Mar-17 17:09pm.
|
|
|
|
|
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return NULL;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the memory usage for each process
for ( i = 0; i < cProcesses; i++ )
{
CString strFileNamePath, strFileName;
processID = aProcesses[i];
// Print the process identifier.
TRACE( "\nProcess ID: %u\n", processID );
// Get a list of all the modules in this process.
hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ | PROCESS_TERMINATE,
FALSE, processID );
if( EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
{
char szModName[MAX_PATH];
// Get the full path to the module's file.
if ( GetModuleFileNameEx( hProcess, hMods[0], szModName,
sizeof(szModName)))
{
// Print the module name and handle value.
TRACE("\t%s (0x%08X)\n", szModName, hMods[0] );
strFileNamePath.Format("%s", szModName);
strFileName = strFileNamePath.Mid(strFileNamePath.ReverseFind('\\') + 1, strFileNamePath.GetLength());
}
}
CloseHandle( hProcess );
}
this is how you can retrieve the file names of all running process,
similarily there are psapi functions to get memory usage, I/O threads
Cheers,
Sujith
|
|
|
|
|
You can see an article of Mr David Crow about procceses I think its helpful for you
|
|
|
|
|
I have a service (written in Visual C++ 6), running under Windows 2003. I need to get the name of the currently logged in user, but most Windows APIs I have found return the username of the *calling thread*, which when run as a system, is always "SYSTEM".
I have tried these APIs so far:
GetUserName
GetUserNameEx
Unfortunately, all of the above return the username "SYSTEM". Any suggestions?
|
|
|
|
|
Maybe a stupid question: Did you set a specific user account for the service (to run under)?
And are you aware of the fact that a service isn't allowed to run under an account that has a blank (empty) password?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
There's no need to specify user account for service unless it is exactly what you need. Most of the system/user services should work on Local System account which is almost designed for this purpose.
Regards
|
|
|
|
|
what about getting it from the registry...
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name
not sure if it's what you need, but maybe it'll help
|
|
|
|