把进程注册为服务进程,在98下任务管理其不可见
2k,nt下不行的,需要其他方法,比如使用dll.

解决方案 »

  1.   

    使用了未公开的API函数,要先声明一下    typedef DWORD (WINAPI *MYFun)(DWORD,DWORD);
    HMODULE hnd=LoadLibrary("Kernel32.dll");
    if (hnd)
    {
    MYFun pFun=NULL;
    pFun=(MYFun)GetProcAddresshnd,"RegisterServiceProcess");
            if (pFun)
    pFun(GetCurrentProcessId(),1或0);
    FreeLibrary(hnd);
    }
      

  2.   

    RegisterServiceProcess
    The RegisterServiceProcess function registers or unregisters a service process. A service process continues to run after the user logs off. To call RegisterServiceProcess, retrieve a function pointer using GetProcAddress on KERNEL32.DLL. Use the function pointer to call RegisterServiceProcess. DWORD RegisterServiceProcess(
      DWORD dwProcessId,  
      DWORD dwType        
    );Parameters
    dwProcessId 
      Specifies the identifier of the process to register as a service  process. Specifies NULL to register the current process. 
    dwType 
      Specifies whether the service is to be registered or unregistered. This parameter can be one of the following values.  
    Value Meaning 
    0 Unregisters the process as a service process. 
    1 Registers the process as a service process. 
    Return Values
    The return value is 1 if successful or 0 if an error occurs.