|
|
I would like to thank CodeProject for announcing me as the winner of the "Favorite MFC/C++ Article of March 2004[^]" competition. I would like to thank my best friend Kamal Sekhon for her continuous support. I would also like to thank Nishant (the editor of my article), Chris Maunder and the whole CodeProject team, AND last, but not the least, I would like to thank all those people who posted their prestigious comments, encouraged me a lot, gave their ideas/suggestions, and of course, rated my article to make all this possible.
Thank you all,
Gurmeet BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
Congrat
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
how i can write Ackermann Function not use recursion
Nothing
|
|
|
|
|
|
To make a long story short, there's an external program that I have no control over that is consistantly leaking memory. This product is required by our customer, so we must use it.
Obviously, this program will cause Windows to run out of free memory if it is run long enough. Is there a way I can see the current Memory Usage of this other program -- like what Task Manager is displaying? I'd like my program to either warn the user or destroy that task if the size gets too large.
Any ideas?
|
|
|
|
|
|
|
Hi,
I have an executable being invoked from a VC++ code through ShellExecute. After the completing of this executable, I have got a list of jobs to be performed in a sequence.
But when I run this application, ShellExecute will create a different shell and execute the exe (which is as expected) and the list of jobs will also be executed before the completion of the execution of my exe.
eg.
ShellExecute(GetSafeHwnd(), "open", print.exe, params, NULL, SW_HIDE);
task1
task2
task3
I want print.exe to execute first and then go execute task1, task2, task3 in a sequence.
I want to know whether we have any synchronization method which can be invoked just before task1 so that the control will flow in a sequence.
print.exe is executed only thro' ShellExecute().
Either a system() call, WinExec() etc will not work.
Please help me out.
Thanks,
Prashant
|
|
|
|
|
Use ShellExecuteEx, set the flag member to SEE_MASK_NOCLOSEPROCESS to get the process handle and use WaitForSingleObject on that handle.
Jens
|
|
|
|
|
Thanks for the reply, that worked!!!
|
|
|
|
|
#include<iostream>
#include<complex>
using namespace std;
inline complex<double>&operator+=(complex<double>&cval,double dval)
{return cval==complex<double>(dval);
}
int main()
{
complex<double> cval(4.0,9.8);l
cval+=1;
cout<
|
|
|
|
|
main isn't returning a value; there is no return statement!
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
but compile will extend the inline that has the retun value
|
|
|
|
|
No it won't, except by chance of register values. If you want a function to return a value in C/C++, you have to use the keyword return .
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
hey,
don't confuse an inline woth a macro. An inline functions stays a function. when the docs say the compiler will extend the inline, first, it is not an obligation (it does it only if the function is not very complicated), second, it does NOT copy the content of the function at the calling, it makes an adaptation.
the function :
<font style="color:blue;">inline int</font> my_sum_func(<font style="color:blue;">int </font>iParam1, <font style="color:blue;">int</font> iParam2) {
return (iParam1 + iParam2); <font style="color:green;">
}
the calling :
<font style="color:blue;">void</font> main (<font style="color:blue;">void</font>) {
<font style="color:blue;">int</font> iSumResult = my_sum_func(5, 3);
}
<font style="color:green;">
the compiler will extend such code like this :
<font style="color:blue;">void</font> main (<font style="color:blue;">void</font>) {
<font style="color:blue;">int</font> iSumResult = (5 + 3);
}
are you now convinced ?
!!! : Don't forget : the compiler extends inlines functions only if it can, that is not an obligation to it !
TOXCCT >>> GEII power
|
|
|
|
|
I have a application that inserts a CString and CList in a std::map;
In .h file
typedef CList<csplfiletsinfo*, csplfiletsinfo*=""> SplFileTSInfoList;
typedef std::map<cstring, splfiletsinfolist*=""> tagSplFileInfoMap;
tagSplFileInfoMap m_SplFileInfoMap;
In .cpp file
//A vrialble of type SplFileTSInfoList
SplFileTSInfoList *l_SplFileTSInfoList;
//Insert the Key and the List in to the Map
m_SplFileInfoMap.insert(f_crstrUserID,l_SplFileTSInfoList);
But when I compile this I get an error.
error C2664: 'std::_Tree<_Traits>::iterator std::_Tree<_Traits>::insert(std::_Tree<_Traits>::iterator,const std::_Tree<_Traits>::value_type &)' : cannot convert parameter 1 from 'CString' to 'std::_Tree<_Traits>::iterator'
with
[
_Traits=std::_Tmap_traits<cstring,clist<csplfiletsinfo *,csplfiletsinfo="" *=""> *,std::less<cstring>,std::allocator<std::pair<const cstring,clist<csplfiletsinfo="" *,csplfiletsinfo="" *=""> *>>,false>
]
and
[
_Traits=std::_Tmap_traits<cstring,clist<csplfiletsinfo *,csplfiletsinfo="" *=""> *,std::less<cstring>,std::allocator<std::pair<const cstring,clist<csplfiletsinfo="" *,csplfiletsinfo="" *=""> *>>,false>
]
|
|
|
|
|
Well, I guess you would like to map a string to a CList.
If yes, use this:
<br />
typedef CList SplFileTSInfoList;<br />
typedef std::map< CString, SplFileTSInfoList > tagSplFileInfoMap;<br />
<br />
...<br />
<br />
m_SplFileInfoMap.insert( tagSplFileInfoMap::value_type( f_crstrUserID, l_SplFileTSInfoList ) );<br />
<br />
Jens
|
|
|
|
|
Your error is because you aren't calling insert properly. I would guess (though it's hard to tell from your code) that you will want to try
<br />
m_SplFileInfoMap.insert(make_pair(f_crstrUserID, l_SplFileTSInfoList));<br />
--Dean
|
|
|
|
|
I have a application that inserts a CString and CList in a std::map;
In .h file
typedef CList<csplfiletsinfo*, csplfiletsinfo*=""> SplFileTSInfoList;
typedef std::map<cstring, splfiletsinfolist*=""> tagSplFileInfoMap;
tagSplFileInfoMap m_SplFileInfoMap;
In .cpp file
//A vrialble of type SplFileTSInfoList
SplFileTSInfoList *l_SplFileTSInfoList;
//Insert the Key and the List in to the Map
m_SplFileInfoMap.insert(f_crstrUserID,l_SplFileTSInfoList);
But when I compile this I get an error.
error C2664: 'std::_Tree<_Traits>::iterator std::_Tree<_Traits>::insert(std::_Tree<_Traits>::iterator,const std::_Tree<_Traits>::value_type &)' : cannot convert parameter 1 from 'CString' to 'std::_Tree<_Traits>::iterator'
with
[
_Traits=std::_Tmap_traits<cstring,clist<csplfiletsinfo *,csplfiletsinfo="" *=""> *,std::less<cstring>,std::allocator<std::pair<const cstring,clist<csplfiletsinfo="" *,csplfiletsinfo="" *=""> *>>,false>
]
and
[
_Traits=std::_Tmap_traits<cstring,clist<csplfiletsinfo *,csplfiletsinfo="" *=""> *,std::less<cstring>,std::allocator<std::pair<const cstring,clist<csplfiletsinfo="" *,csplfiletsinfo="" *=""> *>>,false>
]
|
|
|
|
|
ykutanoor wrote:
m_SplFileInfoMap.insert(f_crstrUserID,l_SplFileTSInfoList);
Try
m_SplFileInfoMap.insert(std::make_pair(f_crstrUserID,l_SplFileTSInfoList));
There are other idioms for inserting into maps, I suggest reading around a bit.
Paul
|
|
|
|
|
I have a application that inserts a CString and CList in a std::map;
In .h file
typedef CList<csplfiletsinfo*, csplfiletsinfo*=""> SplFileTSInfoList;
typedef std::map<cstring, splfiletsinfolist*=""> tagSplFileInfoMap;
In .cpp file
//A vrialble of type SplFileTSInfoList
SplFileTSInfoList *l_SplFileTSInfoList;
//Insert the Key and the List in to the Map
m_SplFileInfoMap.insert(f_crstrUserID,l_SplFileTSInfoList);
But when I compile this I get an error.
error C2664: 'std::_Tree<_Traits>::iterator std::_Tree<_Traits>::insert(std::_Tree<_Traits>::iterator,const std::_Tree<_Traits>::value_type &)' : cannot convert parameter 1 from 'CString' to 'std::_Tree<_Traits>::iterator'
with
[
_Traits=std::_Tmap_traits<cstring,clist<csplfiletsinfo *,csplfiletsinfo="" *=""> *,std::less<cstring>,std::allocator<std::pair<const cstring,clist<csplfiletsinfo="" *,csplfiletsinfo="" *=""> *>>,false>
]
and
[
_Traits=std::_Tmap_traits<cstring,clist<csplfiletsinfo *,csplfiletsinfo="" *=""> *,std::less<cstring>,std::allocator<std::pair<const cstring,clist<csplfiletsinfo="" *,csplfiletsinfo="" *=""> *>>,false>
]
|
|
|
|
|
I wrote a C++ program the I run on a NT machine that writes structures to a binary file. I then move the binary file to a Unxi machine and I can't read the files correctly.
I am swaping the bytes, is this all that I need to do?
Thanks for ANY help.
Jim
|
|
|
|
|
Check the byte alignment. It is possible that the data is not written to the offset that you expect.
Ant.
|
|
|
|
|
It really depends on the architechture of each of the machines -- they might both be Little Endian, Big Endian, or a combination of the two. That is to say, you might not need to swap the bytes at all -- doing so could be what's giving you trouble.
If at all possible, try using the ntohs() and ntohl() functions to ensure you get your data correctly on any architecture.
--Dean
|
|
|
|
|