|
I am looking for a sample of adding "Start parameters" to a window service.
|
|
|
|
|
Services actually process 2 command lines.
(1) There's the old command line that you specify upon starting the program. A full command line that the service control manager uses to start your service.
(2) "Start Parameters" which the Service control manager passes to your service's dispatcher (the one you specify via StartServiceCtrlDispatcher() ). The "start parameters" are the ones that you see (and you can 'set') in the Services control panel.
I only use #1 -- which is parseable in the old fashioned argc/argv way. I don't see much use for the "start parameters" way....
Does this help? or confuse?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hi everyone,
I have a class like this:
class CFoo
{
public:
CFoo();
~CFoo();
BOOL SortByName();
protected:
std::vector<CRec*> m_Recs;
private:
struct NameComparer
{
bool operator()(const CRec* A,const CRec* B)
{
return ((A->m_strName) < (B->m_strName));
}
};
};
BOOL CFoo::SortByName()
{
std::stable_sort(m_Recs.begin(), m_Recs.end(), NameComparer());
return TRUE;
}
Now, basically, I am trying to properly write and use a predicate function (I think that's what they're called; please correct me if I'm wrong) in the context of calling std::stable_sort (and just std::sort for that matter). There are many helpful examples around, but they don't seem to cover dealing with a non-trivial class (or if they do I haven't 'gotten it' yet).
In my case, I want to be able to sort the vector of CRec 's according to several different CRec member variables (different CString s, int s, double s, etc.). My questions are:
1) Did I use proper coding techniques to solve the problem as I have shown here?
2) Is it the case that I need to add additional struct s under the private section of CFoo for each comparison CFoo member function I want to write (with the comparisons applied to the std::vector m_Recs and based on the CRec members themselves actually)?
3) Why do I need to wrap the comparison functions in a struct? How does that fact relate to operator() , etc.?
Thank you all again for reading and giving any advice,
Best,
Eric
|
|
|
|
|
It's usually best to wait a few days before posting the same question again. And, surprisingly, an answer may not be know by the current CP members!
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hi David,
I know. And I knew that I risked being rude, but I figured that since it was late when I left the post it might not get seen by many, so I took the chance.
Anyhow, I take your point and I appreciate your feedback.
Best,
Eric
|
|
|
|
|
Cloaca wrote:
And I knew that I risked being rude...
It was being rude per se, it's just that with timezone differences and the like, it may take two full days before the post has been digested by everyone.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
You are right David. That's a good point also. I should male it a policy not to repost for a week or so I guess.
Thanks again,
Eric
|
|
|
|
|
In sum, your solution is okay. In general, check out these books for in-depth explanation on STL.
The C++ Standard Library : A Tutorial and Reference by Nicolai M. Josuttis
Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library by Scott Meyers
Kuphryn
|
|
|
|
|
Hi Kuphryn,
I will grab these two references that you noted. And thanks for the comment on the way I'm doing it now, I appreciate your input!
Thanks very much,
Eric
|
|
|
|
|
Cloaca wrote:
Is it the case that I need to add additional structs under the private section of CFoo for each comparison CFoo member function I want to write [...]?
Yes. AFAIK every comparison need its own comparer (like you have with the NameComparer )
Cloaca wrote:
3) Why do I need to wrap the comparison functions in a struct? How does that fact relate to operator(), etc.?
struct does mean the same as class, but everything is public by default .
As you only want a class with only one public operator, writing struct instead of class does save you a whopping 6 keystrokes (7 for 'public' plus the ':', minus one because struct is longer than class .
I think that is the only reason.
"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.
|
|
|
|
|
Hi jhwurmbach,
Thanks for your reply. That makes sense, but it then makes me wonder why I need a class (or struct) at all to hold the comparison function.
Why is it that I just can't declare the comparison function (just as a 'simple' member of CFoo ) and pass it to the stable_sort() call? I have been reading about operator() and functors, but I am not putting it all together yet, I guess. Does it have someting to do with the fact that functions passed to the algorithms can only have one parameter?
I appreciate your help, thanks again!
Eric
|
|
|
|
|
stds::sort is a template function. That means the arguments for the function determines what kind of code the compiler generates for the function (as opposed to a regular function, where the compiler always generates the same code). A template argument must be either a type or a constant--the compiler must be able to determine what the argument is at compile time, so it knows what code to generate. For the sort function, the template argument might have been a functor type or it might have been a constant that resolves to a function pointer. If you think about it, you can see how making the argument a type gives much more flexibility to the user of the template function, so that is the choice that the template designer made.
|
|
|
|
|
Hi antlers,
Ahh. I think that puts it together for me. A function is of course not a type. But by using the 'struct method', you kind-of wrap the function in a type. And so it is acceptable to the algorithm at compile time. The syntax of operator() is the way a wrapped function can be exposed to the algorithm for use in, for example, a sort call as a comparison.
And this minimal extra work is the small price to pay for a very flexible system of getting whatever might be needed into the templated algorithms. I see. Thanks very much for your help, I appreciate it!
Best,
Eric
|
|
|
|
|
Hello all
I've an application which is working well on win2000 & winXP. But when I ran the same application in win98 & winMe, it's leading to fatal crash and giving me blue screen.
In the case of fatal crash, how can we detect to which part of the application is causing it? I'm not able to debug this problem on win98 and winMe.
If anyone know abt any tools or techniques which can help me in debugging the problem, pls help me.
Many thanks for your help.
Hari.
|
|
|
|
|
haritadala wrote:
In the case of fatal crash, how can we detect to which part of the application is causing it?
Are you using/assuming something that is not available on non-NT machines?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hello David
Thanks for the reply. I'm not using or assuming something that's not on NT machines. My application is taking to devices connected to usb port. I'm using the driver supplied by third party vendor(this driver works on all windows machines, according to vendor). I'm able to send/receive data even on win98/winMe. But when I try to disconnect I'm experiencing fatal crash.
Any ideas as on how to debug this problem will be very much appreciated.
Many thanks for your help.
Hari.
|
|
|
|
|
It sounds like you need to contact the vender of the driver.
If all else fails try to find a memory validator or crash protect program, that can generate a report, even if the code is not available.
Once upon a time, I kept rejecting the release of a program based on the reports generated by Bounds Checker, since our sister would not release the
code to me in order to find the multple problems. Eventualy, they just turned the whole project over to me and it took months to find and fix all the problems.
INTP
|
|
|
|
|
How is it that you are unable to debug this on 98/ME?
Are you using .net/2003? If so, look into the remote debugging features of it, you should be able to debug that way....
Or is the blue-screen coming before any exceptions are trapped?
-p
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hello all
Thanks for the replies. I'm not using .Net/2003. I'm getting blue screen before any exceptions are trapped. I'm getting the following error
fatal error 0E at 0028:C0003E8C
I looked at microsoft knowledge base for these error but couldn't find the solution
Any ideas?
Thanks for the help.
Hari.
|
|
|
|
|
I think that there are many causes -- what exactly does your program do?
You can check out this site (click here)[^]-- for possible answers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hello,
I need to loop through a directory and pull each file name from the given directory.. This should be easy but I have no idea where to start.. Can someone point me in the right direction..
Thanks,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
SDK: FindFirstFile, FindNextFile
MFC: CFileFind
Steve S
|
|
|
|
|
I looked at CFindFile earlier but this looks like a search function to me.. I don't see anywhy to tell it where to start looking.. I dont want to find all .rtf files on my machine just .rtf files given a directory to loop through.. Am I missing something? Can you set the init directory on CFindFile?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Never mind my last post.. CFileFind works perfectly...
Thank you!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Whew! I was beginning to think we were going to have to send it back for repair.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|