Installshield 添加应用程序到防火墙例外

function AddProcessFwauthor()

    STRING szCServer,szFServer,szTmp;

    OBJECT objFirewall, objProfile, objCS, objFS;

begin

    SdShowMsg("将服务器添加到Windows防火墙例外程序中,请稍后...", TRUE); 

    

    //要添加到防火墙程序的应用程序的完整路径:安装目录\WinClient.exe

    szCServer = TARGETDIR ^ ("WinClient" + ".exe");

    try     

        set objFirewall = CoCreateObject("HNetCfg.FwMgr");

    catch

    endcatch;



    try

        set objProfile = objFirewall.LocalPolicy.CurrentProfile;

        set objCS = CoCreateObject("HNetCfg.FwAuthorizedApplication");

        szTmp = szCServer;

        LongPathToQuote(szTmp, FALSE);

        objCS.ProcessImageFileName = szTmp;  

        

        //要添加到防火墙例外程序的显示名称

        objCS.Name = "WinClient";

        objCS.Scope = 0;

        objCS.RemoteAddresses = "*";

        objCS.IpVersion = 2;

        objCS.Enabled = TRUE;

        objProfile.AuthorizedApplications.Add(objCS);

    catch

    endcatch;

    SdShowMsg("将服务器添加到Windows防火墙例外程序中,请稍后...", FALSE);

    return TRUE;

end;

测试通过,yeah!

你可能感兴趣的:(Install)