安卓手机怎样退出正在运行的程序

安卓手机怎样退出正在运行的程序,第1张

如果按返回键(或者全面屏手势中的左右侧边缘向内滑闭春)无反应,可以考虑按菜单键(或者全面屏手势中的底液盯部向上滑动并停顿),切换到应用进程总览界面,然后按“x”或者向侧面滑动那一个APP的小窗口,强制关闹态和闭那一个APP进程。

1,用BAT文件\x0d\x0aPrivate Sub Form_Load()\x0d\x0a\x0d\x0aOpen App.Path &"\a.bat" For Output As #1\x0d\x0a'"@echo off" 不显示执行过程\x0d\x0aPrint #1, "@echo off"\x0d\x0aPrint #1, "sleep 100"\x0d\x0a'a.bat 删除指定文件\x0d\x0aPrint #1, "del " &App.EXEName + ".exe"\x0d\x0a'a.bat 删除握亏空自身\x0d\x0aPrint #1, "del a.bat"\x0d\x0aPrint #1, "cls"\x0d\x0aPrint #1, "exit"\x0d\x0aClose #1\x0d\x0a\x0d\x0aShell App.Path &"\空兆a.bat", vbHide\x0d\x0aEnd\x0d\x0a\x0d\x0aEnd Sub\x0d\x0a\x0d\x0a2、用API\x0d\x0a一个模块,非原创(我修改部分代码),可以让程序退出后自毁(删除自身)。\x0d\x0a原理还特别不清楚,不过应该和CMD的DEL命令有关,但删除时没看到CMD.EXE进程,速段瞎度也很快\x0d\x0a成功率挺高的(我还没失败过)\x0d\x0a\x0d\x0a创建一个模块,写入代码:\x0d\x0aConst NORMAL_PRIORITY_CLASS = &H20\x0d\x0aConst REALTIME_PRIORITY_CLASS = &H100\x0d\x0aConst THREAD_PRIORITY_NORMAL = 0\x0d\x0aConst THREAD_PRIORITY_IDLE = -15\x0d\x0aConst IDLE_PRIORITY_CLASS = &H40\x0d\x0aConst DETACHED_PROCESS = &H8\x0d\x0aConst CREATE_SUSPENDED = &H4\x0d\x0aConst THREAD_PRIORITY_TIME_CRITICAL = 15\x0d\x0aConst SW_HIDE = 0\x0d\x0aConst STARTF_USESHOWWINDOW = &H1\x0d\x0a\x0d\x0aType STARTUPINFO\x0d\x0acb As Long\x0d\x0alpReserved As String\x0d\x0alpDesktop As String\x0d\x0alpTitle As String\x0d\x0adwX As Long\x0d\x0adwY As Long\x0d\x0adwXSize As Long\x0d\x0adwYSize As Long\x0d\x0adwXCountChars As Long\x0d\x0adwYCountChars As Long\x0d\x0adwFillAttribute As Long\x0d\x0adwFlags As Long\x0d\x0awShowWindow As Integer\x0d\x0acbReserved2 As Integer\x0d\x0alpReserved2 As Long\x0d\x0ahStdInput As Long\x0d\x0ahStdOutput As Long\x0d\x0ahStdError As Long\x0d\x0aEnd Type\x0d\x0a\x0d\x0aType PROCESS_INFORMATION\x0d\x0ahProcess As Long\x0d\x0ahThread As Long\x0d\x0adwProcessId As Long\x0d\x0adwThreadId As Long\x0d\x0aEnd Type\x0d\x0a\x0d\x0aType SECURITY_ATTRIBUTES\x0d\x0anLength As Long\x0d\x0alpSecurityDescriptor As Long\x0d\x0abInheritHandle As Long\x0d\x0aEnd Type\x0d\x0a\x0d\x0aDeclare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long\x0d\x0aDeclare Function GetEnvironmentVariable Lib "kernel32" Alias "GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpBuffer As String, ByVal nSize As Long) As Long\x0d\x0aDeclare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long\x0d\x0aDeclare Function GetCurrentProcess Lib "kernel32" () As Long\x0d\x0aDeclare Function GetCurrentThreadId Lib "kernel32" () As Long\x0d\x0aDeclare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long\x0d\x0aDeclare Function SetThreadPriority Lib "kernel32" (ByVal hThread As Long, ByVal nPriority As Long) As Long\x0d\x0aDeclare Function ResumeThread Lib "kernel32" (ByVal hThread As Long) As Long\x0d\x0aDeclare Function GetCurrentThread Lib "kernel32" () As Long\x0d\x0aDeclare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long\x0d\x0a\x0d\x0aFunction DeleteMe() As Boolean\x0d\x0aDim szModuleAs String\x0d\x0aDim szComspec As String\x0d\x0aDim szParamsAs String\x0d\x0a\x0d\x0aDim si As STARTUPINFO\x0d\x0aDim pi As PROCESS_INFORMATION\x0d\x0aDim sa1 As SECURITY_ATTRIBUTES\x0d\x0aDim sa2 As SECURITY_ATTRIBUTES\x0d\x0a\x0d\x0aszModule = String(512, 0)\x0d\x0aszComspec = String(512, 0)\x0d\x0aszParams = String(512, 0)\x0d\x0a\x0d\x0a'// get file path names:\x0d\x0aIf ((GetModuleFileName(0, szModule, 512) 0) And (GetShortPathName(szModule, szModule, 512) 0) And (GetEnvironmentVariable("COMSPEC", szComspec, 512) 0)) Then\x0d\x0a'// set command shell parameters\x0d\x0aszComspec = Left(szComspec, InStr(szComspec, Chr(0)) - 1)\x0d\x0aszModule = Left(szModule, InStr(szModule, Chr(0)) - 1)\x0d\x0a\x0d\x0aszComspec = szComspec &" /c del " &"""" &szModule &"""" '这里是我(yfdyh000)修改的,支持带空格路径\x0d\x0a'szComspec = szComspec &" /c del " &szModule'原代码\x0d\x0a\x0d\x0a'// set struct members\x0d\x0aWith si\x0d\x0a.cb = Len(si)\x0d\x0a.dwFlags = STARTF_USESHOWWINDOW\x0d\x0a.wShowWindow = SW_HIDE\x0d\x0aEnd With\x0d\x0a'// increase resource allocation to program\x0d\x0aCall SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS)\x0d\x0aCall SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)\x0d\x0a\x0d\x0a'// invoke command shell\x0d\x0a'Debug.Print CreateProcess(vbNullString, szComspec, sa1, sa2, 0&, CREATE_SUSPENDED Or DETACHED_PROCESS, 0&, vbNullString, si, pi)\x0d\x0aIf CreateProcess(vbNullString, szComspec, sa1, sa2, 0, CREATE_SUSPENDED Or DETACHED_PROCESS, 0, vbNullString, si, pi) Then\x0d\x0a'// suppress command shell process until program exits\x0d\x0aCall SetPriorityClass(pi.hProcess, IDLE_PRIORITY_CLASS)\x0d\x0aCall SetThreadPriority(pi.hThread, THREAD_PRIORITY_IDLE)\x0d\x0a\x0d\x0a'// resume shell process with new low priority\x0d\x0aCall ResumeThread(pi.hThread)\x0d\x0a\x0d\x0a'// everything seemed to work\x0d\x0aDeleteMe = True\x0d\x0aExit Function\x0d\x0aElse '// if error, normalize allocation\x0d\x0aCall SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS)\x0d\x0aCall SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL)\x0d\x0aEnd If\x0d\x0aEnd If\x0d\x0aDeleteMe = False\x0d\x0aEnd Function\x0d\x0a\x0d\x0a在程序中调用命令:DeleteMe(比如在:Form_Unload)\x0d\x0a如果返回True证明成功,退出后会自动删除自身。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12227295.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-22
下一篇 2023-05-22

发表评论

登录后才能评论

评论列表(0条)

保存