CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    system processes for VB apps

    In Visual Basic how would one hide the application process from showing and not show up in the process list when you do a Ctrl+Alt+Del?


  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: system processes for VB apps

    Here's some code I picked up a while back

    This ones for Windows 95/98 - I can't test it here as I'm running NT4:


    '
    ' In a form / module - change public to private as appropriate
    '
    ' ServiceFlags: 0 means unregister as a service, 1 means to register.
    '
    public Declare Function RegisterServiceProcess Lib "kernel32" _
    (byval ProcessID as Long, byval ServiceFlags as Long) as Long
    '
    public Declare Function GetCurrentProcessId Lib "kernel32" () as Long
    '
    '
    public Sub HideApp()
    'When you register the service process it becomes hidden.
    ret = RegisterServiceProcess (GetCurrentProcessId, 1)
    End Sub
    '
    public Sub ShowApp
    'And the unhidden when you unregister it when you're
    'finished with hiding it.
    '
    ret = RegisterServiceProcess (GetCurrentProcessId, 0)
    End Sub




    The code for NT is slightly easier (again in a module / form depending on how you want to use it ):


    option Explicit
    '
    public Declare Function GetWindow Lib "user32" (byval hwnd as Long, byval wCmd as Long) as Long
    public Declare Function ShowWindow Lib "user32" (byval hwnd as Long, byval nCmdShow as Long) as Long
    public Const GW_OWNER = 4
    public Const SW_HIDE = 0
    public Const SW_SHOW = 5
    '
    '
    public Sub HideApp(byval mainFrmHwnd as Long)
    'Hide the app from the task manager.
    '
    Dim lRtn as Long
    '
    lRtn = GetWindow(mainFrmHwnd, GW_OWNER)
    lRtn = ShowWindow(lRtn, SW_HIDE)
    End Sub
    '
    public Sub ShowApp(byval mainFrmHwnd as Long)
    'Show the app from the task manager.
    '
    Dim lRtn as Long
    '
    lRtn = GetWindow(mainFrmHwnd, GW_OWNER)
    lRtn = ShowWindow(lRtn, SW_SHOW)
    End Sub




    Call the above with the 'hwnd' of your main form (eg. HideApp frmMain.hwnd)



    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured