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;

  • 相关阅读:
    C# GridView点击某列打开新浏览器窗口
    大白话系列之C#委托与事件讲解(二)
    大白话系列之C#委托与事件讲解(一)
    Razor语法大全
    Expression<Func<T,TResult>>和Func<T,TResult>
    C#委托的介绍(delegate、Action、Func、predicate)
    Android--样式经验
    Android--onSaveInstanceState()保存数据
    Android--ActivityLiving生命周期
    android--快捷键
  • 原文地址:https://www.cnblogs.com/bdccloudy/p/7665189.html
Copyright © 2011-2022 走看看