http://installshield.jaron.cn/forum/dispbbs.asp?boardID=3&ID=284614&page=1
#include "ifx.h"  
#define Emty  "" //宏定义DOS功能把Emty 替换为""  
prototype RegUnInstall(STRING);
string szDir, szVirtual;
prototype void CheckRequirements(); //检测系统必备.net和iis  
prototype void CreateVirtualDir(STRING,string);//创建虚拟目录 参数1虚拟目录名 参数2物理路径

function OnFirstUIBefore()    
    number  nResult,nSetupType;
    string  szName, szCompany;
    string  szTargetPath;
    string  szComponents, szTargetdir;
    number  nLevel;
    LIST    listStartCopy;
    number  nvSize;  
  
begin
     CheckRequirements();
Dlg_SdWelcome:  

    SetTitle (@TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION);        
    nResult = SdWelcome( "欢迎使用爱普管理系统安装向导","以下将在你的计算机上安装开源爱普ERP,若要继续安装,请点击下一步......" );
  
    Dlg_SdLicense:  
      
  
    nResult= SdLicense( Emty, Emty, Emty,  SUPPORTDIR ^ "license.txt" );
    if (nResult = BACK) goto Dlg_SdWelcome;

Dlg_SdRegisterUserEx:
  
    nResult = SdRegisterUser( Emty, Emty, szName, szCompany );
    if (nResult = BACK) goto Dlg_SdLicense;

Dlg_SdAskDestPath:
    TARGETDIR = PROGRAMFILES^@PRODUCT_NAME;
    szDir = TARGETDIR;  
    nResult = AskDestPath( Emty, Emty, szDir,0 );
    TARGETDIR = szDir;
    if (nResult = BACK) goto Dlg_SdRegisterUserEx;

Dlg_SetupType:  
      
       nSetupType = TYPICAL; //默认安装类型
    nResult = SetupType ( Emty , Emty , Emty , nSetupType , 0 );
    if (nResult = BACK) then
        goto Dlg_SdAskDestPath;
    else
        nSetupType = nResult;
        if (nSetupType != CUSTOM) then
        szTargetPath = TARGETDIR;
        nvSize = 0;
        ComponentCompareSizeRequired(MEDIA,szTargetPath,nvSize);
        if (nvSize != 0) then      
                MessageBox( szSdStr_NotEnoughSpace, WARNING );
            goto Dlg_SetupType;
            endif;
        endif;  
    endif;

Dlg_SdComponentTree:
    if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType;      
    szTargetdir = TARGETDIR;
    szComponents = "";
    nLevel = 2;
    if (nSetupType = CUSTOM) then
      nResult = SdComponentTree(Emty, Emty, szTargetdir, szComponents, nLevel);
      if (nResult = BACK) goto Dlg_SetupType;  
    endif;
    
Dlg_AskText :  
szVirtual=@PRODUCT_NAME;    
SetDialogTitle(DLG_ASK_TEXT,Emty);
nResult=SdShowDlgEdit1 ("设置虚拟目录", "请输入虚拟目录名,安装程序将设置IIS信息服务.\n如果您没有填写,安装程序将按默认方式创建!","虚拟目录名称:",szVirtual);

Dlg_SdStartCopy:
    if (szVirtual = "") then
  MessageBox ("请输入虚拟目录的名称!",INFORMATION) ;  
  goto   Dlg_AskText;

  endif;

   listStartCopy = ListCreate( STRINGLIST );
    ListAddString(listStartCopy,"用户名:"+szName,AFTER);
     ListAddString(listStartCopy,"公司名称:"+szCompany,AFTER);  
    ListAddString(listStartCopy,"目标目录:"+szDir,AFTER);  
    ListAddString(listStartCopy,"请确认您填写的信息,按下一步开始复制文件",AFTER);
    nResult = SdStartCopy( "", "", listStartCopy );
    ListDestroy(listStartCopy);

    if (nResult = BACK) goto Dlg_SdComponentTree;          
     SetStatusWindow(0, "");
       Enable(STATUSEX);
       StatusUpdate(ON, 100);
         return 0;
end;

function OnMoving()
    string szAppPath;
begin
     RegUnInstall("");
    szAppPath = TARGETDIR;
    RegDBSetItem(REGDB_APPPATH, szAppPath);
    RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY);
end;  

function void CheckRequirements()  
begin  
SdShowMsg ("安装程序正在检测系统必备组件......",TRUE);
Delay(1);  
SdShowMsg (Emty,FALSE);
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
if (RegDBKeyExist ("System\\CurrentControlSet\\Services\\IISADMIN" ) != 1) then
  if(SprintfBox(MB_OK,"检测系统环境","你的计算机没有被安装IIS,请安装后重试,安装程序将退出!")=IDOK)
then exit;  
endif;  
endif;
if (RegDBKeyExist ("SOFTWARE\\Microsoft\\.NETFramework\\policy\\v1.1" ) != 1) then        
  if(LaunchAppAndWait ( SUPPORTDIR ^"dotnetfx.exe" , "/q:a/l" ,WAIT)<0) then
     SprintfBox(MB_OK,".NET安装","安装.net框架时发生意外,请重新安装!");
   endif;
   endif;      
end;  

function  void CreateVirtualDir(VirtualFolder, szDir)

begin
if (VirtualFolder = "") then
MessageBox ("请输入虚拟目录的名称!",INFORMATION) ;
else
SdShowMsg (" 正在创建虚拟目录"+VirtualFolder+"请不要关闭....", TRUE);
Delay(1);
LaunchAppAndWait(SUPPORTDIR^"Create.exe", VirtualFolder+" \""+TARGETDIR+"\" ",WAIT);

//AddFolderIcon (FOLDER_DESKTOP , "爱普管理系统" ,"http://localhost"^VirtualFolder^"Default.aspx" ,Emty, Emty, 0, Emty, REPLACE|RUN_MINIMIZED);
  //这里不知道为什么 只要创建快捷方式就很卡 得等待很久
//AddFolderIcon ( FOLDER_PROGRAMS , "爱普管理系统" ,"http://localhost"^VirtualFolder^"Default.aspx" ,Emty, Emty, 0, Emty, REPLACE|RUN_MINIMIZED);
SdShowMsg (Emty,FALSE);
endif;

end;


function RegUnInstall(szKey)
   STRING svUninstLogFile;  
begin

    //反安装的注册

       InstallationInfo(@COMPANY_NAME, @PRODUCT_NAME, @PRODUCT_VERSION, @PRODUCT_KEY);

       DeinstallStart(TARGETDIR, svUninstLogFile, "", 0);

       RegDBSetItem(REGDB_UNINSTALL_NAME, @PRODUCT_NAME);

       DeinstallSetReference (TARGETDIR ^ @PRODUCT_KEY);    

end;    


function OnFirstUIAfter()
      
     NUMBER bOpt1, bOpt2,nResult, nDefOptions;
    
     begin  
     Disable(STATUSEX);
     CreateVirtualDir(szVirtual, szDir);//这里会出现Dos窗口
     if (!BATCH_INSTALL) then
     bOpt1 = FALSE;
     bOpt2 = TRUE;
    
     nResult = SdFinish( "安装完成","已经成功安装爱普管理系统,单击完成以退出安装向导", Emty, "阅读Readme文件", "立刻运行程序", bOpt1, bOpt2 );
    
     if bOpt1 = TRUE then
     CopyFile (SUPPORTDIR^"Readme.txt" , "Readme.txt" );
     LaunchApp ( WINDIR^"Notepad.exe" , TARGETDIR^"Readme.txt" );
     endif;
     if  bOpt2=TRUE then
      LaunchAppAndWait(SUPPORTDIR^"IEXPLORE.EXE","localhost"^szVirtual^"default.aspx",NOWAIT) ;
      endif;
      return 0;
     endif;

    end;

function OnMaintUIAfter()
    STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
    NUMBER bOpt1, bOpt2;
begin
Disable(STATUSEX);

    ShowObjWizardPages(NEXT);

bOpt1   = FALSE;
    bOpt2   = FALSE;
    szMsg1  = SdLoadString(IFX_SDFINISH_MAINT_MSG1);
szTitle = SdLoadString(IFX_SDFINISH_MAINT_TITLE);
    SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);
end;


下面这个是建ISS虚拟目录用到的CREATE.EXE的源代码

#include<stdio.h>
#include <stdlib.h>
char *  concat(const char * dos,const char * argv)
{char *str;
int i,j,dos_len,argv_len,length;
dos_len=strlen(dos);
argv_len=strlen(argv);
length=dos_len+argv_len;
str=(char *)malloc(length+1);
  for(i=0,j=argv_len;i<dos_len||j>=0;)
{
  if(i<dos_len)  
    str[i]=dos[i++];
  if(j>=0)
   str[length--]=(argv)[j--];
}

  return str;
}
main(int argc, char* argv[])
{
if(argc>2)
{
char *str=concat("@cscript.exe %SystemDrive%/Inetpub/AdminScripts/adsutil.vbs delete w3svc/1/root/",*++argv);  
system("@echo off");
system(str);
free(str);
str=concat("@cscript.exe %SystemDrive%/Inetpub/AdminScripts/adsutil.vbs create_vdir w3svc/1/root/",*argv);
system(str);
free(str);
str=concat("@cscript.exe %SystemDrive%/Inetpub/AdminScripts/adsutil.vbs set w3svc/1/root/",*argv);
str=concat(str,"/path \"");
str=concat(str,*++argv);
str=concat(str,"\"");
system(str);
free(str);
str=concat("@cscript.exe %SystemDrive%/Inetpub/AdminScripts/adsutil.vbs APPCREATEPOOLPROC w3svc/1/root/",*--argv);
system(str);
free(str);
str=concat("@cscript.exe %SystemDrive%/Inetpub/AdminScripts/adsutil.vbs set w3svc/1/root/",*argv);
str=concat(str,"/AccessScript TRUE");
system(str);
free(str);
str=concat("@cscript.exe %SystemDrive%/Inetpub/AdminScripts/adsutil.vbs set w3svc/1/root/",*argv);
str=concat(str,"/AccessFlags 513");
system(str);
free(str);
str=concat("@cscript.exe %SystemDrive%/Inetpub/AdminScripts/adsutil.vbs set w3svc/1/root/",*argv);
str=concat(str,"/AuthFlags 5");
system(str);
free(str);
str=concat("@cscript.exe %SystemDrive%/Inetpub/AdminScripts/adsutil.vbs set w3svc/1/root/",*argv);
str=concat(str,"/DefaultDoc \"Default.aspx\"");
system(str);
free(str);
system("@cls");
system("@exit");
}
}

posted on 2007-07-07 16:41  draeag  阅读(628)  评论(0编辑  收藏  举报