zoukankan      html  css  js  c++  java
  • Delphi:程序自己删除自己,适用于任何windows版本(含源码)

    Delphi:程序自己删除自己,适用于任何windows版本(含源码)

    function Suicide: Boolean;
    var
      sei: TSHELLEXECUTEINFO;
      szModule:  PChar;
      szComspec: PChar;
      szParams:  PChar;
    begin
      szModule  := AllocMem(MAX_PATH);
      szComspec := AllocMem(MAX_PATH);
      szParams  := AllocMem(MAX_PATH);
      if ((GetModuleFileName(0,szModule,MAX_PATH)<>0) and
        (GetShortPathName(szModule,szModule,MAX_PATH)<>0) and
        (GetEnvironmentVariable('COMSPEC',szComspec,MAX_PATH)<>0)) then
      begin
        lstrcpy(szParams,'/c del ');
        lstrcat(szParams, szModule);
        sei.cbSize      := sizeof(sei);
        sei.Wnd          := 0;
        sei.lpVerb      := 'Open';
        sei.lpFile      := szComspec;
        sei.lpParameters := szParams;
        sei.lpDirectory  := 0;
        sei.nShow        := SW_HIDE;
        sei.fMask        := SEE_MASK_NOCLOSEPROCESS;
        if (ShellExecuteEx(@sei)) then
        begin
          SetPriorityClass(sei.hProcess,HIGH_PRIORITY_CLASS);//IDLE_PRIORITY_CLASS);
          SetPriorityClass( GetCurrentProcess(),
                            REALTIME_PRIORITY_CLASS);
          SetThreadPriority( GetCurrentThread(),
                            THREAD_PRIORITY_TIME_CRITICAL);
          SHChangeNotify(SHCNE_Delete,SHCNF_PATH,szModule,nil);
          Result := True;
        end
        else
          Result := False;
      end
      else
        Result := False;
    end;

  • 相关阅读:
    将python的代码文件打包成可执行文件
    SpringBoot整合JdbcTemplate连接Mysql
    Golang开发环境搭建
    java中的Lamdba表达式和Stream
    MySQL 优化1
    MySQL you *might* want to use the less safe log_bin_trust_function_creators variable
    MySQL mysqlbinlog
    MySQL 事件调度器
    MySQL 忘记密码解决办法
    MySQL 创建自定义函数(2)
  • 原文地址:https://www.cnblogs.com/bdccloudy/p/7665189.html
Copyright © 2011-2022 走看看