Results 1 to 14 of 14

Thread: [RESOLVED] Prevent Program Process Termination and Uninstallation

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Resolved [RESOLVED] Prevent Program Process Termination and Uninstallation

    Hi, I'm currently facing another problem. Using VB.NET, Windows Mobile 6 SDK, Visual Studio 2005.

    My team has been facing a pretty advanced level task. I need to prevent the mobile phone user from terminating my program's process from the windows mobile's "task manager"-like interface as well as preventing them from uninstalling it.

    Is there a way to do so? Please kindly give us your advices. Thanks

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Prevent Program Process Termination and Uninstallation

    You can probably prevent uninstallation by deleting the apps unistall entry in the registry.

    ShowWindow(hWnd, SW_HIDE) SHOULD hide in tasks list
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Re: Prevent Program Process Termination and Uninstallation

    Thanks, I understand the registry part, but I'm not quite sure what you meant by "ShowWindow(hWnd, SW_HIDE)". Do I need to import any libraries for it?

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Prevent Program Process Termination and Uninstallation

    P/Invoke ShowWindow

    <DllImport("CoreDll")> _
    Public Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
    End Function

    Const SW_HIDE As Integer = 0

    ShowWindow(me.handle,SW_Hide)
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Re: Prevent Program Process Termination and Uninstallation

    Do you mean

    Code:
    Public Declare Function ShowWindow Lib "coredll" Alias "ShowWindow" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer


    and on Page Load

    Code:
    ShowWindow(Me.Handle, SW_HIDE)
    Where as SW_HIDE is a constant?

    Code:
    Const SW_HIDE = 0
    Const SW_NORMAL = 1
    Const SW_SHOWMINIMIZED = 2

    I tried this in my program but turn out our program is still showing in the memory settings and can be terminated.

  6. #6
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Prevent Program Process Termination and Uninstallation

    Has your program got a form - if so set
    Me.Text = ""
    That should prevent it from showing
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Re: Prevent Program Process Termination and Uninstallation

    Thanks, that was a nice way to get pass that problem.

    Is there a way I can detect changes in the registry?

    Like files, thereis a FileSystemWatcher. Is there one for the registry?
    Last edited by heatgutsexe; Jul 23rd, 2008 at 12:08 AM.

  8. #8
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Prevent Program Process Termination and Uninstallation

    In on of my other answers I pointed you at a video solution for that at http://msdn.microsoft.com/en-us/netf.../cc709417.aspx

    That, with a bit of adaptation should do what you need
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  9. #9

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Re: Prevent Program Process Termination and Uninstallation

    Thanks. I tried that method and it requres me to target a value in a certain key.

    I already have a function that would let me find keys base on a target and delete values.

    Now I need is a very general detection of registry change, as in regardless of which key or which values are changed.

    Is there a way to do so?

  10. #10
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Prevent Program Process Termination and Uninstallation

    Not that I am aware of - anyone else?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  11. #11

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Re: Prevent Program Process Termination and Uninstallation

    Ok, if that's the case, nevermind about it. Then I'll need to go for another approach using that user-defined state.

    However, I need to ask, last time you gave me this code

    Code:
    AppPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
    to get currently running program's path as string.

    Is there a similar way to get the company's name and program's name that is stated in the project and grab them as string?

    As in eventually, those two strings will form the registry key when the program is installed. HKEY_Local_Machine\Security\AppInstall\<company's name><space><program name>.

  12. #12
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Prevent Program Process Termination and Uninstallation

    You can certainly get it using OpenNetCF which hints that you can't get it as standard

    Code:
    Private Sub GetCompanyName()
        ' Get the file version for the notepad.
        Dim myFileVersionInfo As FileVersionInfo = _
            FileVersionInfo.GetVersionInfo("%systemroot%\Notepad.exe")
        
        ' Print the company name.
        textBox1.Text = "The company name: " & myFileVersionInfo.CompanyName
    End Sub 'GetCompanyName
    Although this may help.
    Last edited by petevick; Jul 28th, 2008 at 03:21 AM.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  13. #13

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Re: Prevent Program Process Termination and Uninstallation

    Wow, thanks alot Petevick, we really appreciate your help.

  14. #14
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [RESOLVED] Prevent Program Process Termination and Uninstallation

    I hope we get credit in your project

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

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