|
Be very sure you have used the correct num of parameters and return type in your handler. Most of these macros exhibit this 'crash in release' prob if you get this wrong.
|
|
|
|
|
Hi,
I have created a fantastic NT service which does some cool stuff. However, I need a method to Administer this fabulous app. Ideally I'd like to be able to popup a GUI in the service with a windows message or something.
Is it possible for a Service to have a GUI? I've looked into it a little and saw the article here about the NT Service with a shell tray icon, but I need a full dialog based GUI.
Possible?
Cheers
James
|
|
|
|
|
this is straight forward. Invoke your dialog in the normal fashion with CDialog. (just like its done from the CApp implementation in a MFC framework based dialog appwizard project).
You're service needs to be able to "Interact with the desktop" though.
|
|
|
|
|
I have never done this, but the last 2 weeks I have been developing a service that loads a dll and installs a WH_KEYBOARD_LL hook in the system, and I have need some help and a lot of information.
There are a lot of good articles in the MSJ and in the MSDN about your question, but I'm sure about it's possible, the only thing you have to control is if the GUI is ready: if nobody has logged in and the desktop is not ready your gui will crash.
MSJ article:
Why Do Certain Win32 Technologies Misbehave in Windows NT Services?
There you will find info. about another article of Jeff Richter that clarifies more services.
Well, at last let me beg your pardon, my english it's very bad. (I'm novice with it...)
|
|
|
|
|
Messages are easy enough - just call MessageBox with the MB_SERVICE_NOTIFICATION flag set. No need to be logged in.
Administration really is best done by a separate desktop app communicating with the service - for example, you could set up a loopback TCP connection on an unused port with which to communicate from your admin dialog to the service.
If _monitoring_ the service is the primary goal, maybe UDP would be easier.
|
|
|
|
|
A good book on Services is Programming Server-Side Applications for Windows 2000.
It covers NT in general, and points out the pitfalls in advance, along with integration/administration/performance, scalability, security and stability issues which you should be aware of if writing services.
Its kind of a service bible.
Giles
|
|
|
|
|
Hi!
Possible decision - create the regular GUI application (may be - CPL), that stores the config info into the Registry, and in the service use RegNotifyChangeKeyValue to be informed, when the change occured, to be able to retrieve the new values.
Regards,
Gennady
|
|
|
|
|
A NT Service may well have a GUI, but this comes with some drawbacks.
Only services running in the "local system" user account can have the priviledge "interact with desktop", which is needed to have a visual GUI.
The "local system" user account is restricted in some access rights, for instance, it isn't allowed to open the client side of named pipes.
Another drawback is that every user who logs on to the machine the service runs on is abled to see and interact with the service's GUI.
This is not feasible for secure operation.
I would recommend using a separate GUI application for interaction with the service. Simple commands could be sent from GUI to service using user-defined codes for the ControlService() function.
Data could be sent using named pipes or shared memory (who'd want to do it that way?!) or sockets.
|
|
|
|
|
Why not creating a service with the ATL wizard and use the COM mechanism to interact between your service and your GUI application ? It's easier to use then named pipes or shared memory. After creating a service with the ATL wizard, you can adapt the CServiceModule::Run to do whatever you like (running code, adding COM objects, ...). There's a book about NT services that covers all of this (even how to optimize ATL created services for performance).
-Nick-
|
|
|
|
|
I am trying to populate a ListBox in a dialog.
My error is in this line:
m_MyDialog.m_ctlMyListBox.AddString("Hello");
I can populate the list box AFTER I open the dialog, but if I try to place anything in the ListBox BEFORE I open the dialog, I get a assertion error. I can, however, set other variables in the dialog prior to opening it.
Where have I failed?
Richard
|
|
|
|
|
CListBox::AddString is just a thin MFC wrapper over Win32 message LB_ADDSTRING. The function will work only if your CListBox variable is properly initialized (mapped to some HWND). The initialization usually occurs in DoDataExchange called from CDialog::OnInitDialog - DDX_Control does this.
You can't initialize CListBox before dialog is created - there's no listbox window to be associated with C++ member variable of type CListBox.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello, the codegurus around the world.
If you have no idea of that ListBox is acutally created or not,
we can check this by GetSafeHwnd() or GetDlgItem();
if (m_MyDialog.m_ctlMyListBox.GetSafeHwnd())
or
if (m_MyDialog.GetDlgItem(IDC_MYLISTBOX))
These values isn't NULL,
we can add the string to the list box.
Otherwise, we must change the location which the code tries
to add the strings to the listbox.
Have a nice day.
-Masaaki Onishi-
|
|
|
|
|
Populating a list box with it's initial contents is usually done in OnInitDialog(). You could always have a list of items in a collection which the OnInitDialog functions puts in the listbox at runtime if you needed to set your items up before the dialog is created.
> Andrew.
|
|
|
|
|
I'm new in VC++ programming, and i have to create a dlgbox which have a button which have to catch value in a access database. i don't know how to do that, so if someone could help by showing the correct syntax for this application.
thanks
gerald
|
|
|
|
|
do you mean that when they click a button a value must be read from the database and displayed on a dialog control?
if so, open a connection to the database (cdatabase and crecordset) and code the button click handler to read the reqd value from the reqd table (defined in crecordset) ... then display it on the reqd control
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
you see what i mean but could you be more explicit about the implementation, i never do this kind of work before?
|
|
|
|
|
In my propertyPages I need to use member variable of their propertySheet object But it is unidentified .
How can I call this variable ???
|
|
|
|
|
Use code like this in your poperty pages:
(CMyPropSheet*) pSheet = (CMyPropSheet*)GetParent();
Paolo.
|
|
|
|
|
I've been programming for a while now and created a vector drawing app and all, but one thing still bugs me...
I can't figure out what handles are
I mean for example the hWnd and hInstance?! My guess is that they are some kind of pointers?
The documentation of c++ doesn't tell me anything interesting. And I couldn't find anything on the internet. Please help me and tell me what they are for
Thanks,
WAVK
|
|
|
|
|
Handles are used for identifying OS objects (files, device contexts, windows, pens, etc). They may be pointers, array indices, map keys or something entirely else - the point is that the value of the handle is understood only by system. Your app is expected to use the handle via API functions - there's no need to 'interpret' their values other than checking for NULL or INVALID_HANDLE_VALUE.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
the type HANDLE is actually defined as void *
|
|
|
|
|
It doesn't matter. It's just a 32-bit value. On my W2K box calling CreateFile just returned HANDLE == 0x54, which is not a valid pointer, but perfectly valid file handle.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
No wonder I didn't understand them. This must be the most abstract thing of c
WAVK
|
|
|
|
|
Handles are a feature of Windows API, not the C++ language. That's why they aren't mentioned in C/C++ books.
|
|
|
|
|
Hi,
I need to be able to find out whether there is a process called OUTLOOK.EXE running. How do I do this?
Also, once i've found the process, I'll be displaying a message to the user to close it... but i suppose a neater way would be to close it for them. is this possible?
Thanks
|
|
|
|