在CMainFrame::OnCreate()中:ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW);
HINSTANCE hInstProcess= LoadLibrary("KERNEL32.DLL"); 
if(hInstProcess) 
{            
typedef DWORD (WINAPI *MYFUNC)(DWORD,DWORD);          
MYFUNC RegisterServiceProcessFun = NULL;     
RegisterServiceProcessFun = 
(MYFUNC)   GetProcAddress(hInstProcess, "RegisterServiceProcess");
if(RegisterServiceProcessFun)     
{   //把本程序注册为service          
RegisterServiceProcessFun(
GetCurrentProcessId(),
1//RSP_SIMPLE_SERVICE
);
}     
FreeLibrary(hInstProcess); 
}
}