Agusto Xaverius P Sipahutar

Job:Making some bugs and patch
Moss/Wss,C#,Sql Server,WWF,K2.BP
Motto : Keep Study and study
See also: Other Geeks@INDC

News

My Certification



MCP ID# 3552391

My Curiculum Vitae


Other Article

My Community

My Article/Share Knowledge

Others Moss/Wss Site

September 2005 - Posts

Kill all of the running programs on your mobile device
Source code : http://www.eggheadcafe.com/articles/dotnet_compact_framework_kill_processes.zip
 
C# Clean Kill Class
using System;
using System.Runtime.InteropServices;
using SmartDeviceApplication2;

namespace SmartDeviceApplication2
{

   public class CleanKill
   {

      public CleanKill() { }
	 
      [DllImport("aygshell.dll")]
      public static extern int SHCloseApps(int dwMemSought);
 
      public static bool Execute()
      {
                 
         try
         {

           if (SHCloseApps(int.MaxValue)!= 0)
           {
             return false;
           }
         }
         catch  { } 

         return true;
      }
 
  }
}
C# Form1
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using SmartDeviceApplication2;

  static void Main() 
  {
    Application.Run(new Form1());
  }

  
  private void Form1_Load(object sender, System.EventArgs e)
  {
     CleanKill.Execute();
     this.Close();
     Application.Exit(); 
  }
Share this post: | | | |
Posted: Sep 14 2005, 12:23 AM by agusto | with no comments
Filed under:
End Application from Visual Basic 6.0 Application
Buat menjadi satu class pada visual basic dan gunakan pada saat close program waktu di MDI nya.
Sebab terkadang program masih ada di memory.
 
Private Declare Function GetWindowThreadProcessId Lib "user32" _
        (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
        ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
        (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" _
        (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
 
Public Sub GP_EndApplication(hwnd As Long)
    Dim hInst                              As Long
    Dim hProcess                           As Long
    Dim lProcessID
    Dim lExitCode                          As Long
       
        hInst = GetWindowThreadProcessId(hwnd, lProcessID)
        'Get handle to process
        hProcess = OpenProcess(&H1F0FFF, 0&, lProcessID)
        If hProcess <> 0 Then
            'get exit code
            GetExitCodeProcess hProcess, lExitCode
            If lExitCode <> 0 Then
                'bye-bye
                lRet = TerminateProcess(hProcess, lExitCode)
            End If
        End If
End Sub
Share this post: | | | |
Posted: Sep 14 2005, 12:18 AM by agusto | with no comments
Filed under: