zoukankan      html  css  js  c++  java
  • 更新win7资源管理器

    更新exeplorer.exe:

    1、方法1:

    void RefreshExplorer()
    {
        char strShell[1024];
        SHELLEXECUTEINFOA shellExeInfo={0};
        shellExeInfo.cbSize=sizeof(SHELLEXECUTEINFOA);
        shellExeInfo.fMask=SEE_MASK_NOCLOSEPROCESS;
        shellExeInfo.nShow=SW_HIDE;
        shellExeInfo.lpVerb="open";
        GetSystemDirectoryA(strShell,1024);
        strcat(strShell,"\taskkill.exe");
        shellExeInfo.lpFile=strShell;
        shellExeInfo.lpParameters="/F /IM explorer.exe";
        ShellExecuteExA(&shellExeInfo);
        WaitForSingleObject(shellExeInfo.hProcess,INFINITE);
        GetWindowsDirectoryA(strShell,1024);
        strcat(strShell,"\explorer.exe");
        WinExec(strShell,SW_SHOW);
    }

    方法2:

    char* tolow(char *s)
    {
        int i, j; 
        for (i = 0;i < strlen(s); i++)
        { 
            for (j = 0;j < strlen(s); j++) 
                if (s[j] >= 'A' && s[j] <= 'Z') 
                    s[j] = s[j] - 'A' + 'a'; 
        }
        return s;
    }
    
    //杀死进程
    void kill(char proc[1024])
    {
        HANDLE   hSnapShot   =   ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);  
        if(hSnapShot   ==   0)  
            return;  
        PROCESSENTRY32   thePE;  
        thePE.dwSize   =   sizeof(PROCESSENTRY32); 
        //遍历正在运行的第一个系统进程
        bool   Status   =   Process32First(hSnapShot,&thePE);  
        bool   bHaveFlag   =   false;  
        DWORD  ProcessID = 0;
        while(Status)  
        {
            //遍历正在运行的下一个系统进程 
            Status   =   Process32Next(hSnapShot,&thePE); 
            char myproc[1024] ;
            strcpy(myproc,thePE.szExeFile);
            strcpy(myproc,tolow(myproc));//转小写
            //找到相应的进程 **.exe
            if (strcmp(myproc,proc)==0)
            {  
                bHaveFlag   =   true;  
                ProcessID   =   thePE.th32ProcessID;  
                //结束指定的进程 ProcessID
                if(!TerminateProcess(OpenProcess (PROCESS_TERMINATE||PROCESS_QUERY_INFORMATION,false,ProcessID),0)) //参数为0,会引起资源管理器自动重启! 
                {
                    MessageBox(NULL, TEXT("无法终止指定的进程"), TEXT("提示"), MB_OK);
                }
                break;  
            }  
        }  
        CloseHandle(hSnapShot);
    }
  • 相关阅读:
    函数细节
    ElementUI的Table组件自定义合计行内容
    好看的字体收藏
    MD5加密生成与SHA526加密生成
    XML和Map之间互相转换
    银联支付
    微信支付开发
    MySql创建索引,添加索引
    jqgrid分级表格合并
    关于C# XmlDocument方法Load加载流后自动释放流的解决方法
  • 原文地址:https://www.cnblogs.com/wangzhigang/p/5233524.html
Copyright © 2011-2022 走看看