PDA

Click to See Complete Forum and Search --> : [RESOLVED] Prevent Program Process Termination and Uninstallation


heatgutsexe
Jul 21st, 2008, 06:21 AM
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

petevick
Jul 21st, 2008, 07:59 AM
You can probably prevent uninstallation by deleting the apps unistall entry in the registry.

ShowWindow(hWnd, SW_HIDE) SHOULD hide in tasks list

heatgutsexe
Jul 21st, 2008, 09:47 AM
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?

petevick
Jul 21st, 2008, 10:15 AM
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)

heatgutsexe
Jul 21st, 2008, 07:38 PM
Do you mean

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



and on Page Load

ShowWindow(Me.Handle, SW_HIDE)

Where as SW_HIDE is a constant?

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.

petevick
Jul 22nd, 2008, 02:25 AM
Has your program got a form - if so set
Me.Text = ""
That should prevent it from showing

heatgutsexe
Jul 22nd, 2008, 09:35 PM
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?

petevick
Jul 23rd, 2008, 01:29 AM
In on of my other answers I pointed you at a video solution for that at http://msdn.microsoft.com/en-us/netframework/cc709417.aspx

That, with a bit of adaptation should do what you need

heatgutsexe
Jul 24th, 2008, 08:23 PM
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?

petevick
Jul 25th, 2008, 02:05 AM
Not that I am aware of - anyone else?

heatgutsexe
Jul 27th, 2008, 07:32 PM
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

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>.

petevick
Jul 28th, 2008, 03:18 AM
You can certainly get it using OpenNetCF which hints that you can't get it as standard

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 (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=394516&SiteID=1) may help.

heatgutsexe
Jul 28th, 2008, 04:08 AM
Wow, thanks alot Petevick, we really appreciate your help.

petevick
Jul 28th, 2008, 08:36 AM
I hope we get credit in your project ;)

Pete