Tuesday, October 5, 2010

reboot function in installshield

///////write it in separate .rul file and name it for example reboot.rul/////
 #define TITLE_TEXT "reboot example"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
 prototype kRebootDialog();
function kRebootDialog()
    NUMBER nvDefChoice;
begin
    // Query to reboot computer.
    RebootDialog (TITLE_TEXT, "", 0);
end;
///////////////////////////call this function in a separate .rul file. and include ........
#include "reboot.rul"

function OnFirstUIBefore()
begin

kRebootDialog();
end;

Monday, October 4, 2010

mail.rul

//===========================================================================
//
//  File Name:    Setup.rul
//
//  Description:  Blank setup main script file
//
//  Comments:     Blank setup is an empty setup project. If you want to
//      create a new project via. step-by step instructions use the
//      Project Assistant.
//
//===========================================================================
// Included header files ----------------------------------------------------
#include "ifx.h"
#include "diskspace.rul"
 #include "addint.rul"
 #include "concatenate.rul"
 #include "createlist.rul" 
  #include "readwritetext.rul"
  #include "listinfo.rul"
        
        
         

 
  
//---------------------------------------------------------------------------                                                                       
// OnFirstUIBefore
//
// First Install UI Sequence - Before Move Data
//
// The OnFirstUIBefore event is called by OnShowUI when the setup is
// running in first install mode. By default this event displays UI allowing
// the end user to specify installation parameters.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnFirstUIBefore()
    number  nResult, nLevel, nSize, nSetupType,listID, listInfo,nvVar, nSum;
    number nFirst, nSecond;
    string  szTitle, szMsg,sconcat ,szOpt1,sfirststring,ssecondstring, svconcat, szOpt2, szLicenseFile,sthirdstring,szString, svSum;
    string  szName, szCompany, szTargetPath, szDir, szFeatures, szTargetdir;
    BOOL    bLicenseAccepted,bIsEnoughDiskSpace,hMSI,concatenate_example, list_add_example,list_info_example;
begin        
          list_info_example= list_info();  
          
              if(list_info_example) then
             
                 // SdShowInfoList (szTitle, szMsg, listInfo);
                 endif;
                      
               list_info();
               readandwrite();
               readline();
               nFirst=2;
               nSecond=3;
               nSum = Addint(nFirst, nSecond);
               NumToStr ( svSum, nSum );
               MessageBox(svSum, INFORMATION);
            
        ////concatenate///
              sfirststring="hello";
             ssecondstring="Everybody";
            sconcat=concatenate(sfirststring,ssecondstring);
           
             //NumToStr( svconcat, sconcat);
             MessageBox(sconcat, INFORMATION);
      list_add_example= ListAddStrings();
      if( list_add_example) then
       szString = "Keyboard";
        MessageBox (szString, INFORMATION);
        endif;
    
  
    
  
   
   // prototype BOOL ExFn_GetSystemInfo(hMSI);
   //Add_to_int=Add_to_integer();
  //if(Add_to_int) then
  
   // MessageBox ("sum", INFORMATION);
   //endif;
   bIsEnoughDiskSpace=Get_disk_Space();
 
   if!(bIsEnoughDiskSpace) then 
        MessageBox ("not enough space", SEVERE);
    //abort;
  endif; 
   
    nSetupType = COMPLETE;
    szDir = TARGETDIR;
    szName = "";
    szCompany = "";
    bLicenseAccepted = FALSE;
    // ExFn_GetSystemInfo(hMSI);
// Beginning of UI Sequence
Dlg_Start:
    nResult = 0;
Dlg_SdWelcome:
    szTitle = "";
    szMsg = "";
    //{{IS_SCRIPT_TAG(Dlg_SdWelcome)
    nResult = SdWelcome( szTitle, szMsg );
    //}}IS_SCRIPT_TAG(Dlg_SdWelcome)
    if (nResult = BACK) goto Dlg_Start;
Dlg_SdLicense2:
    szTitle = "";
    szOpt1 = "";
    szOpt2 = "";
    //{{IS_SCRIPT_TAG(License_File_Path)
    szLicenseFile = SUPPORTDIR ^ "License.rtf";
    //}}IS_SCRIPT_TAG(License_File_Path)
    //{{IS_SCRIPT_TAG(Dlg_SdLicense2)
    nResult = SdLicense2Rtf( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted );
    //}}IS_SCRIPT_TAG(Dlg_SdLicense2)
    if (nResult = BACK) then
        goto Dlg_SdWelcome;
    else
        bLicenseAccepted = TRUE;
    endif;
Dlg_SdRegisterUser:
    szMsg = "";
    szTitle = "";
    //{{IS_SCRIPT_TAG(Dlg_SdRegisterUser)
    nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
    //}}IS_SCRIPT_TAG(Dlg_SdRegisterUser)
    if (nResult = BACK) goto Dlg_SdLicense2;
Dlg_SetupType2:  
    szTitle = "";
    szMsg = "";
    nResult = CUSTOM;
    //{{IS_SCRIPT_TAG(Dlg_SetupType2)
    nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
    //}}IS_SCRIPT_TAG(Dlg_SetupType2)
    if (nResult = BACK) then
        goto Dlg_SdRegisterUser;
    else
        nSetupType = nResult;
        if (nSetupType != CUSTOM) then
            szTargetPath = TARGETDIR;
            nSize = 0;
            FeatureCompareSizeRequired( MEDIA, szTargetPath, nSize );
            if (nSize != 0) then     
                MessageBox( szSdStr_NotEnoughSpace, WARNING );
                goto Dlg_SetupType2;
            endif;
        endif;  
    endif;
Dlg_SdAskDestPath2:
    if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType2;
 szTitle = "";
    szMsg = "";
    if (nSetupType = CUSTOM) then
                //{{IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
  nResult = SdAskDestPath2( szTitle, szMsg, szDir );
                //}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
        TARGETDIR = szDir;
    endif;
    if (nResult = BACK) goto Dlg_SetupType2;
Dlg_SdFeatureTree:
    if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath2;
    szTitle = "";
    szMsg = "";
    szTargetdir = TARGETDIR;
    szFeatures = "";
    nLevel = 2;
    if (nSetupType = CUSTOM) then
        //{{IS_SCRIPT_TAG(Dlg_SdFeatureTree)
        nResult = SdFeatureTree( szTitle, szMsg, szTargetdir, szFeatures, nLevel );
        //}}IS_SCRIPT_TAG(Dlg_SdFeatureTree)
        if (nResult = BACK) goto Dlg_SdAskDestPath2; 
    endif;
Dlg_SQLServer:
    nResult = OnSQLServerInitialize( nResult );
    if( nResult = BACK ) goto Dlg_SdFeatureTree;
Dlg_ObjDialogs:
    nResult = ShowObjWizardPages( nResult );
    if (nResult = BACK) goto Dlg_SQLServer;
   
Dlg_SdStartCopy2:
    szTitle = "";
    szMsg = "";
    //{{IS_SCRIPT_TAG(Dlg_SdStartCopy2)
    nResult = SdStartCopy2( szTitle, szMsg );
    //}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
    if (nResult = BACK) goto Dlg_ObjDialogs;
    // Added in 11.0 - Set appropriate StatusEx static text.
    SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );

    return 0;
end;
//---------------------------------------------------------------------------
// OnMaintUIBefore
//
// Maintenance UI Sequence - Before Move Data
//
// The OnMaintUIBefore event is called by OnShowUI when the setup is
// running in maintenance mode. By default this event displays UI that
// allows the end user to add or remove features, repair currently
// installed features or uninstall the application.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnMaintUIBefore()
    number nResult, nType, nMediaFlags;
    string szTitle, szMsg, szIgnore;
begin

 // nType defaults to MODIFY.
 nType = MODIFY;
    //Initialize SQL
    OnSQLServerInitializeMaint();
// Beginning of UI Sequence
Dlg_Start:
    // Added in Version 9.5 - Support for REMOVEONLY option.
    if( !REMOVEONLY ) then
     // In standard mode show maintenance dialog
     Disable( BACKBUTTON );
     nType = SdWelcomeMaint( szTitle, szMsg, nType );
     Enable( BACKBUTTON );
        nResult = NEXT;
    else
        // Hide the initial progress dialog as otherwise the user can
        // click on it, and hide the MessageBox.
        Disable( DIALOGCACHE );
        // In RemoveOnly mode, set to remove.
        nType = REMOVEALL;
    endif;
 // Show Uninstall Confirmation Dialog
    if ( nType = REMOVEALL ) then
  nResult = MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO );
  if (nResult != IDYES ) then
           
            if( REMOVEONLY ) then
                // In REMOVEONLY mode, abort the setup.
                abort;
            else
                // In non-REMOVEONLY mode, redisplay the previous dialog.
       goto Dlg_Start;
            endif;
  endif;
 endif;
Dlg_SdFeatureTree:
 if ( nType = MODIFY ) then
  szTitle = "";
  szMsg = SdLoadString( SD_STR_COMPONENT_MAINT_MSG );
  nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, "", -1 );
  if ( nResult = BACK ) goto Dlg_Start;
    endif;
Dlg_ObjDialogs:
    nResult = ShowObjWizardPages( nResult );
    if ( ( nResult = BACK ) && ( nType != MODIFY ) ) goto Dlg_Start;
    if ( ( nResult = BACK ) && ( nType = MODIFY ) ) goto Dlg_SdFeatureTree;
 switch(nType)
        case REMOVEALL:
     
   // Ensure that all previously installed features are removed
   // for media that supports updating.
   MediaGetData( MEDIA, MEDIA_FIELD_MEDIA_FLAGS, nMediaFlags, szIgnore );
  
   if( nMediaFlags & MEDIA_FLAG_UPDATEMODE_SUPPORTED ) then
    FeatureRemoveAllInMediaAndLog();
   else
    FeatureRemoveAllInMedia();
   endif;
            // Added in 11.0 - Set appropriate StatusEx static text.
            SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REMOVEALL ) );
        case REPAIR:
   
   // Changed for DevStudio 9, Disk1 files are now always updated when installed
   // so when running from ADDREMOVE we need to prevent these files from being
   // updated since this will result in files being updated that are locked by the setup.
   // Updating these files when running from ADDREMOVE should not be needed since updates
   // are not run directly from Add/Remove.
            if( ADDREMOVE ) then
                // Reinstall all previously installed features, except
                // disk1 features.
                FeatureUpdate( "" );
            else
                // Reinstall all previously installed features.
                FeatureReinstall();
            endif;
            // Added in 11.0 - Set appropriate StatusEx static text.
            SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REPAIR ) );
        case MODIFY:
           
            // Added in 11.0 - Set appropriate StatusEx static text.
            SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_MODIFY ) );
    endswitch;

end;
//---------------------------------------------------------------------------
// OnFirstUIAfter
//
// First Install UI Sequence - After Move Data
//
// The OnFirstUIAfter event called by OnShowUI after the file transfer
// of the setup when the setup is running in first install mode. By default
// this event displays UI that informs the end user that the setup has been
// completed successfully.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnFirstUIAfter()
    STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
    NUMBER bvOpt1, bvOpt2;
 NUMBER bShowUpdateServiceDlg;
begin
    ShowObjWizardPages(NEXT);
   
    szTitle = "";
    szMsg1 = "";
    szMsg2 = "";
    szOpt1 = "";
    szOpt2 = "";
 bvOpt1   = FALSE;
    bvOpt2   = FALSE;   
 // Set this to true if you have the update service enabled, and if you want to check for updates.
 // Note: the ISUS Starter Edition does not support checking for updates programatically.  So,
 // only set this to true if you have at least the ISUS Professional Edition.
 bShowUpdateServiceDlg = FALSE;
   
    //{{IS_SCRIPT_TAG(Dlg_SdDinishEx)
   
    if ( BATCH_INSTALL ) then
     SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
    else
 
  // If the update service is enabled, show finish dialog that includes
  // update check option.
  if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then
   if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then
    // Don't check for updates in silent mode.
    if( MODE != SILENTMODE ) then
     UpdateServiceCheckForUpdates( "", FALSE );
    endif;
   endif;
  else
   SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
  endif;
    endif;
    //}}IS_SCRIPT_TAG(Dlg_SdDinishEx)
end;
//---------------------------------------------------------------------------
// OnMaintUIAfter
//
// The OnMaintUIAfter event called by OnShowUI after the file transfer
// of the setup when the setup is running in maintenance mode. By default
// this event displays UI that informs the end user that the maintenance setup
// has been completed successfully.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnMaintUIAfter()
    STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
    NUMBER bvOpt1, bvOpt2;
begin
    ShowObjWizardPages(NEXT);
   
    // Added - Version 9.5 - Use appropriate strings for complete
    // uninstall.
    if( REMOVEALLMODE ) then
        szTitle = SdLoadString(IFX_SDFINISH_REMOVE_TITLE);
        szMsg1  = SdLoadString(IFX_SDFINISH_REMOVE_MSG1);
    else
        szTitle = SdLoadString(IFX_SDFINISH_MAINT_TITLE);   
        szMsg1  = SdLoadString(IFX_SDFINISH_MAINT_MSG1);
    endif;
 szMsg2 = "";   
    szOpt1 = "";
    szOpt2 = "";
 bvOpt1   = FALSE;
    bvOpt2   = FALSE;   
    if ( BATCH_INSTALL ) then
     SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
    else   
        SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
    endif;
end;

create disk space

#include "Ifx.h"
 prototype Get_disk_Space();
function Get_disk_Space()
    STRING   szDrive,svResultPath;
    long freespace,i;
    NUMBER   nvResult;
    ///LIST     listInfo;
begin 
   freespace=0;
AskPath ("Select drive:", "C:\\", svResultPath);
   i=0;
   freespace= GetDiskSpace(szDrive);  
  
   if(freespace<i) then
  
   // MessageBox ("not enough space", SEVERE);
    //  Disable (NEXTBUTTON);
 
       endif;
       
         if(freespace>i) then
        Enable (NEXTBUTTON);
        // MessageBox ("enough space,go ahead", INFORMATION);
   
       
       endif;
        ///Enable (FINISHBUTTON);
   
      end;
  
  
  
    // Create a list for system information.
  //  listInfo = ListCreate (STRINGLIST);
    // Get the amount of extended memory.
   // if (GetSystemInfo (EXTENDEDMEMORY, nvResult, svResult) < 0) then
       // szInfo = "Couldn't get EXTENDEDMEMORY info.";
   // else
     //   Sprintf(szInfo, "Extended memory: %d K", nvResult);
 //   endif;
    // Add the information to the list.
  //  ListAddString(listInfo, szInfo, AFTER);
    // Get the boot drive.
   // if (GetSystemInfo (BOOTUPDRIVE, nvResult, svResult) < 0) then
       // szInfo = "Couldn't get BOOTUPDRIVE info.";
   // else
       // Sprintf(szInfo, "Boot drive: %s", svResult);
    //endif;
    // Add the information to the list.
  //  ListAddString(listInfo, szInfo, AFTER);
    // Get info about the CD-ROM.
   // if (GetSystemInfo (CDROM, nvResult, svResult) < 0) then
       // szInfo = "Couldn't get CD-ROM info.";
   // else
       // if (nvResult = 0) then
          //  svResult = "No";
       // else
          //  svResult = "Yes";
      //  endif;
       
       // Sprintf(szInfo, "CDROM: %s", svResult);
    //endif;
    // Add the information to the list.
   // ListAddString(listInfo, szInfo, AFTER);
    // Get the video adapter.
  //  if (GetSystemInfo (VIDEO, nvResult, svResult) < 0) then
       // szInfo = "Couldn't get VIDEO info.";
   // else
       // switch (nvResult)
          //  case IS_UNKNOWN:
            //    szInfo = "VIDEO: UNKNOWN";
          //  case IS_SVGA:
           //     szInfo = "VIDEO: SVGA";
           // case IS_XVGA:
               // szInfo = "VIDEO: XVGA";
           //// case IS_UVGA:
            //    szInfo = "VIDEO: UVGA";
       // endswitch;
   // endif;
    // Add the information to the list.
    //ListAddString(listInfo, szInfo, AFTER);
    // Get number of available colors.
    //if (GetSystemInfo (COLORS, nvResult, svResult) < 0) then
        //szInfo = "Couldn't get COLORS info.";
   // else
       // Sprintf(szInfo, "Number of colors: %d", nvResult);
    //endif;
    // Add the information to the list.
 //   ListAddString(listInfo, szInfo, AFTER);
    // Get the current date.
  //  if (GetSystemInfo (DATE, nvResult, svResult) < 0) then
  //      szInfo = "Couldn't get DATE info.";
   // else
     //   Sprintf(szInfo, "DATE: %s", svResult);
    //endif;
    // Add the information to the list.
    //ListAddString(listInfo, szInfo, AFTER);
    // Get the current time.
  //  if (GetSystemInfo (TIME, nvResult, svResult) < 0) then
      //  szInfo = "Couldn't get TIME info.";
   // else
      //  Sprintf(szInfo, "TIME: %s", svResult);
    //endif;
  //
  //  // Add the information to the list.
   // ListAddString(listInfo, szInfo, AFTER);
   // // Get the operating system.
  //  if (GetSystemInfo (OS, nvResult, svResult) < 0) then
       // szInfo = "Couldn't get Operating System info.";
    //else
        //switch (nvResult)
           // case IS_WINDOWSNT:
             //   szInfo = "OS: Windows NT";
          //  case IS_WINDOWS9X:
               // GetSystemInfo (WINMINOR, nvResult, svResult);
               
              //  if (nvResult < 10) then
                   //  szInfo = "OS: Windows 95";
              //  else
                  //   szInfo = "OS: Windows 98";
             //   endif;
      //  endswitch;
   // endif;
 //   // Add the information to the list.
//    ListAddString(listInfo, szInfo, AFTER);
//    // Display the information.
//    szTitle   = "System Information";
//    szMsg     = "The following is some information related to your system:\n";
   
  //  SdShowInfoList (szTitle, szMsg, listInfo);
 //   ListDestroy(listInfo);
//end;

readwrite text in installshield

     #include "Ifx.h" 
       #define read_dir  "C:\\"
    #define read_file "read.txt"
     prototype readandwrite();
    
     function readandwrite()
  
    NUMBER nvFileHandle; 
    STRING szMsg; 
    
begin  
   
     OpenFileMode (FILE_MODE_APPEND);
    
     if (CreateFile (nvFileHandle, read_dir, read_file
) < 0) then
    
       // MessageBox (failed to create file, SEVERE);
       
     else
     
        szMsg = "hello god is watching u";
               
 
       
        if (WriteLine(nvFileHandle, szMsg) < 0) then
           
            MessageBox ("error", SEVERE);
        else
         
            SprintfBox (INFORMATION,  szMsg, read_file);
        endif;
    endif;
    CloseFile(nvFileHandle);
end;
///////////////////////////////////////////
  
   prototype readline();
    function readline()
    STRING  szFileName, szPath, szText, svLine;
    NUMBER  nFlag, nFileHandle;
    LIST   listID;
begin
   
 
    listID = ListCreate (STRINGLIST);
   
   
    OpenFileMode (FILE_MODE_NORMAL);
   
  
    OpenFile (nFileHandle,read_dir, read_file);
   
 
    while (GetLine (nFileHandle, svLine) = 0)
        ListAddString (listID, svLine, AFTER);
    endwhile;
   
   
    CloseFile (nFileHandle);
   
   
   SdShowInfoList ("", read_file, listID);
   
 
    ListDestroy (listID);
end;

create list info

    #include "Ifx.h"
   prototype list_info();
function list_info()
   STRING  szTitle, szMsg, svReturn, szInfo;
   NUMBER  nvReturn;
   LIST    listInfo;
begin
   // Create a list to hold system information.
   listInfo = ListCreate (STRINGLIST);

   // Add the time to the list.
   ListAddString (listInfo, szInfo, AFTER);
  
    szInfo="apple";
   ListAddString (listInfo, szInfo, AFTER); 
   szInfo="orange";
    szInfo="pen";
     szInfo="software";
        ListAddString (listInfo, szInfo, AFTER);
          szInfo="pen";
              ListAddString (listInfo, szInfo, AFTER);
     szInfo="paper";
          ListAddString (listInfo, szInfo, AFTER);
      szInfo="keyboard"; 
          ListAddString (listInfo, szInfo, AFTER);
       szInfo="adapter";
            ListAddString (listInfo, szInfo, AFTER);
        szInfo="webpage";
   // Disable the Back button in setup dialogs.
   Disable (BACKBUTTON);
  
   szTitle  = "InfoList";
   szMsg    = "general information";

   // Display the information.
   SdShowInfoList (szTitle, szMsg, listInfo);
end;



 
   // Check if the system has a CD-ROM drive.
  // GetSystemInfo (CDROM, nvReturn, svReturn);
  // if (nvReturn = TRUE) then
      //szInfo = "Your machine has a CD-ROM Drive.";
  // else
     // szInfo = "Your machine does not have a CD-ROM drive.";
  // endif;
   // Add the CD-ROM info to the list.
 //  ListAddString (listInfo, szInfo, AFTER);
   // Check the time on the system.
  // GetSystemInfo (TIME, nvReturn, svReturn);
 //  Sprintf (szInfo, "The time now is %s.", svReturn);