Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
my code

my code in the start of the service funcation.

code:
C++
SappDialog obj;
CoInitialize(NULL);
AFX_MANAGE_STATE(AfxGetStaticModuleState());
HINSTANCE hInst1= GetModuleHandle (0);
HWND hDlg;
hDlg = CreateDialog(hInst1, MAKEINTRESOURCE(IDD_DIALOG1), 0, DialogProc, 0);
ShowWindow(hDlg, 5);

IDD_DIALOG1 - my Dialog box id.

if i try like that the dialog box is not launching.
i want to launch the dialog box, before service get starts.
Posted
Updated 6-Nov-12 23:21pm
v2
Comments
enhzflep 7-Nov-12 6:09am    
You were given the answer yesterday. (here)
Sergey already told you that you don't do that with a service. What makes you think the answer will be different if you re-phrase the same question? My 1.

1 solution

Think about what you're trying to achieve. You want to show a dialog before the service starts, but if you put the dialog code in the service, the service has to start before you show the dialog. I'd leave the service as it is, and have a small app that you can use to start the service with which shows the dialog before starting the service.

If you need a GUI you should rethink. The wikipedia article: http://en.wikipedia.org/wiki/Windows_service[^] clearly states "a Windows service is a long-running executable that performs specific functions and it is designed not to require user intervention"
 
Share this answer
 
v2
Comments
@BangIndia 7-Nov-12 5:56am    
ok. i accept. how to launch a dialog in the service.
once service started i need to ask one input from the user.
how to do that?
jim lahey 7-Nov-12 5:58am    
That's not the job of a windows service to be honest. Services are intended to run unattended. See my updated answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900