Click here to Skip to main content
15,897,094 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Strategy question Pin
Maxwell Chen8-Apr-04 18:57
Maxwell Chen8-Apr-04 18:57 
GeneralRe: Strategy question Pin
Cloaca9-Apr-04 8:54
Cloaca9-Apr-04 8:54 
GeneralRe: Strategy question Pin
Maxwell Chen11-Apr-04 16:16
Maxwell Chen11-Apr-04 16:16 
GeneralRe: Strategy question Pin
Cloaca12-Apr-04 5:13
Cloaca12-Apr-04 5:13 
QuestionMemory access from another app? Pin
Andrew Stampor8-Apr-04 9:49
Andrew Stampor8-Apr-04 9:49 
AnswerRe: Memory access from another app? Pin
Dominik Reichl8-Apr-04 10:07
Dominik Reichl8-Apr-04 10:07 
AnswerRe: Memory access from another app? Pin
Anonymous8-Apr-04 10:56
Anonymous8-Apr-04 10:56 
GeneralAdd NT Service support to existing MFC GUI App Pin
farzadb8-Apr-04 9:46
farzadb8-Apr-04 9:46 
Hi everyone.

I have an existing MFC based GUI Windows application to which I would like to add functionality so it can also run as a Service.

I have good understand of how a Service works and I've written one from scratch but I'm stumped on how I can convert an existing MFC based GUI app to run as a Service. The problem is how to do all the required MFC initialization when the SCM calls my app.

My first thought was to implment the startup code myself and simply handle a command line arg to determine if I should run as a Service or not. I can then intercept the startup before InitInstance() is called and my GUI is displayed. Of course I would implement the required Service methods such as 'ServiceMain' and 'ServiceControlHandler' then based on the command line arg I would hand of startup control to these methods and away I go to running a Service.

Then I looked at how much MFC is doing before it calls InitInstance() on my app and realized writing my own 'WinMain' isn't going to be trivial.

So basically I'm looking for advice on how to handle this. I could just write a standalone Service based on this app but I would love to just have one module which is dual purpose.

In writing this I just had a thought. Shouldn't I just determine if I'm running as a service or not in InitInstance() and go from there? Maybe that's the solution but I've typed this all out so I might as well post it. Smile | :)


GeneralRe: Add NT Service support to existing MFC GUI App Pin
Hashim Saleem8-Apr-04 14:27
Hashim Saleem8-Apr-04 14:27 
GeneralRe: Add NT Service support to existing MFC GUI App Pin
farzadb11-Apr-04 19:33
farzadb11-Apr-04 19:33 
Generaleasy_odbc compile problem Pin
intrinsic8-Apr-04 9:32
intrinsic8-Apr-04 9:32 
GeneralRe: easy_odbc compile problem Pin
Mike Dimmick9-Apr-04 0:26
Mike Dimmick9-Apr-04 0:26 
GeneralRe: easy_odbc compile problem Pin
intrinsic9-Apr-04 2:47
intrinsic9-Apr-04 2:47 
GeneralRe: easy_odbc compile problem Pin
intrinsic9-Apr-04 3:06
intrinsic9-Apr-04 3:06 
GeneralRe: easy_odbc compile problem Pin
Mike Dimmick9-Apr-04 5:50
Mike Dimmick9-Apr-04 5:50 
Generaloperator overloading Pin
Guido Loupias8-Apr-04 8:20
Guido Loupias8-Apr-04 8:20 
GeneralRe: operator overloading Pin
Renjith Ramachandran8-Apr-04 8:28
Renjith Ramachandran8-Apr-04 8:28 
GeneralRe: operator overloading Pin
toxcct8-Apr-04 9:23
toxcct8-Apr-04 9:23 
GeneralRe: operator overloading Pin
Guido Loupias8-Apr-04 9:50
Guido Loupias8-Apr-04 9:50 
Generalfile problem Pin
kfaday8-Apr-04 7:12
kfaday8-Apr-04 7:12 
GeneralRe: file problem Pin
Prakash Nadar8-Apr-04 7:31
Prakash Nadar8-Apr-04 7:31 
GeneralRe: file problem Pin
kfaday8-Apr-04 7:54
kfaday8-Apr-04 7:54 
GeneralRe: file problem Pin
Renjith Ramachandran8-Apr-04 8:37
Renjith Ramachandran8-Apr-04 8:37 
GeneralRe: file problem Pin
toxcct8-Apr-04 9:11
toxcct8-Apr-04 9:11 
GeneralRe: file problem Pin
Paul Ranson8-Apr-04 11:14
Paul Ranson8-Apr-04 11:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.