高分请教高人,请教关于installshield问题?

老朱-yubing 2003-09-13 12:52:56
请问谁知道怎么制作安装文件,在某个安装程序中替换,非文本文件中的,字符串?

比如说有这个config.txt这个文件
文件中很多 c:\setup
我要把它替换成 <TARGETDIR>
也就是说,config.txt中有这个'c:\setup'
就把它替换成<TARGETDIR>
这个变量,情教高手怎么办?
参考函数FileInsertLine
语法:FileInsertLine (szFileName, szInsertLine, nLineNumber, nInsertFlag);
说明:FileInsertLine函数通过指定行号来插入或置换一行。你可以将FileInsertLine 和 FileGrep一起使用,
...全文
120 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
老朱-yubing 2003-10-19
  • 打赏
  • 举报
回复
问题已经解决
////////////////////////////////////////////////////////////////////////////////
//
// File Name: Setup.rul
//
// Description: InstallShield script
//
// Comments: This script was generated based on the selections you made in
// the Project Wizard. Refer to the help topic entitled "Modify
// the script that the Project Wizard generates" for information
// on possible next steps.
//
////////////////////////////////////////////////////////////////////////////////


// Include header files

#include "ifx.h"
prototype modifdbdir();

////////////////////// string defines ////////////////////////////

//////////////////// installation declarations ///////////////////

// ----- DLL function prototypes -----


// your DLL function prototypes


// ---- script function prototypes -----


// your script function prototypes

// your global variables



//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnFirstUIBefore
//
// EVENT: FirstUIBefore event is sent when installation is run for the first
// time on given machine. In the handler installation usually displays
// UI allowing end user to specify installation parameters. After this
// function returns, ComponentTransferData is called to perform file
// transfer.
//
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIBefore()
number nResult,nSetupType;
string szTitle, szMsg;
string szLicenseFile, szQuestion;
string szName, szCompany, szSerial;
string szTargetPath;
string szDir;
string szComponents, szTargetdir;
number nLevel;
LIST listStartCopy;
number nvSize;
begin
// TO DO: if you want to enable background, window title, and caption bar title
// SetTitle( @TITLE_MAIN, 24, WHITE );
// SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION );
// Enable( FULLWINDOWMODE );
// Enable( BACKGROUND );
// SetColor(BACKGROUND,RGB (0, 128, 128));

nSetupType = TYPICAL;
TARGETDIR = PROGRAMFILES ^@COMPANY_NAME;
szDir = TARGETDIR;
szName = "";
szCompany = "";
szSerial = "";

Dlg_Start:
// beginning of dialogs label

Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome( szTitle, szMsg );
if (nResult = BACK) goto Dlg_Start;

Dlg_SdLicense:
szLicenseFile = SUPPORTDIR ^ "license.txt";
szTitle = "";
szMsg = "";
szQuestion = "";
nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
if (nResult = BACK) goto Dlg_SdWelcome;

Dlg_SdAskDestPath:
szTitle = "";
szMsg = "";
nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
TARGETDIR = szDir;
if (nResult = BACK) goto Dlg_SdWelcome;

Dlg_SetupType:
szTitle = "";
szMsg = "";
nResult = SetupType ( szTitle , szMsg , "" , 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;
szTitle = "";
szMsg = "";
szTargetdir = TARGETDIR;
szComponents = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
nResult = SdComponentTree(szTitle, szMsg, szTargetdir, szComponents, nLevel);
if (nResult = BACK) goto Dlg_SetupType;
endif;

Dlg_ObjDialogs:
nResult = ShowObjWizardPages(nResult);
if (nResult = BACK) goto Dlg_SdComponentTree;

Dlg_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string(szName) to a list(listStartCopy).
//eg. ListAddString(listStartCopy,szName,AFTER);
nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
ListDestroy(listStartCopy);
if (nResult = BACK) goto Dlg_ObjDialogs;

// setup default status
SetStatusWindow(0, "");
Enable(STATUSEX);
StatusUpdate(ON, 100);

return 0;
end;

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoving
//
// EVENT: Moving event is sent when file transfer is started as a result of
// ComponentTransferData call, before any file transfer operations
// are performed.
//
///////////////////////////////////////////////////////////////////////////////

function OnMoving()
string szAppPath;
begin
// Set LOGO Compliance Application Path
// TO DO : if your application .exe is in a subfolder of TARGETDIR then add subfolder
szAppPath = TARGETDIR;
RegDBSetItem(REGDB_APPPATH, szAppPath);
RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY);
end;
function OnFirstUIAfter()
begin
modifdbdir();
end;
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnAppSearch
//
// EVENT: AppSearch event is used as an entry point to implement code to
// search for previous versions of the current application. This
// event is sent only for a first time installation.
//
///////////////////////////////////////////////////////////////////////////////
function modifdbdir()
STRING szinstallfile;
NUMBER nvResult,nvLineNumber;
STRING szwindir,svReturnLine;
NUMBER sn,nStartPos;
STRING sz1,sz2,sznewdir;
NUMBER nTemp;
begin
szinstallfile = TARGETDIR ^"conf\\my.txt";
while (nvResult != END_OF_FILE)
nvResult = FileGrep (szinstallfile, "c:/armsun", svReturnLine,nvLineNumber, RESTART);
sn=StrLength (svReturnLine);
nStartPos = StrFind(svReturnLine,"c:/armsun");
StrSub (sz1, svReturnLine, 0, nStartPos);
StrSub (sz2, svReturnLine, nStartPos+9, sn-nStartPos-9);
sznewdir=sz1+TARGETDIR ^sz2;
FileInsertLine(szinstallfile, sznewdir,nvLineNumber, REPLACE);
sz1="";
sz2="";
sznewdir="";
endwhile;
end;


//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnCCPSearch
//
// EVENT: CCPSearch event is used as an entry point to implement code to
// search for existing applications. This event is sent
// only for a first time installation.
//
///////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnBegin
//
// EVENT: Begin event is always sent as the first event during installation.
//
//////////////////////////////////////////////////////////////////////////////
function OnBegin()
begin
// TO DO: you may change default non-UI setting, for example
//
// Disable(SELFREGISTERBATCH)
// SetInstallationInfo with arguments other then default
//
// You may also perform your custom initialization steps, check requirements, etc.
end;

// --- include script file section ---
f3611018 2003-09-30
  • 打赏
  • 举报
回复
关注
老朱-yubing 2003-09-14
  • 打赏
  • 举报
回复
请问我照上面写代码有什么问题,
可是怎么安装完程序后,my.txt里面 的文字没有改变》?
老朱-yubing 2003-09-14
  • 打赏
  • 举报
回复

////////////////////////////////////////////////////////////////////////////////
//
// File Name: Setup.rul
//
// Description: InstallShield script
//
// Comments: This script was generated based on the selections you made in
// the Project Wizard. Refer to the help topic entitled "Modify
// the script that the Project Wizard generates" for information
// on possible next steps.
//
////////////////////////////////////////////////////////////////////////////////


// Include header files

#include "ifx.h"
prototype modifdbdir();

////////////////////// string defines ////////////////////////////

//////////////////// installation declarations ///////////////////

// ----- DLL function prototypes -----


// your DLL function prototypes


// ---- script function prototypes -----


// your script function prototypes

// your global variables



//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnFirstUIBefore
//
// EVENT: FirstUIBefore event is sent when installation is run for the first
// time on given machine. In the handler installation usually displays
// UI allowing end user to specify installation parameters. After this
// function returns, ComponentTransferData is called to perform file
// transfer.
//
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIBefore()
number nResult,nSetupType;
string szTitle, szMsg;
string szLicenseFile, szQuestion;
string szName, szCompany, szSerial;
string szTargetPath;
string szDir;
string szComponents, szTargetdir;
number nLevel;
LIST listStartCopy;
number nvSize;
begin
// TO DO: if you want to enable background, window title, and caption bar title
// SetTitle( @TITLE_MAIN, 24, WHITE );
// SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION );
// Enable( FULLWINDOWMODE );
// Enable( BACKGROUND );
// SetColor(BACKGROUND,RGB (0, 128, 128));

nSetupType = TYPICAL;
TARGETDIR = PROGRAMFILES ^@COMPANY_NAME ^@PRODUCT_NAME;
szDir = TARGETDIR;
szName = "";
szCompany = "";
szSerial = "";

Dlg_Start:
// beginning of dialogs label

Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome( szTitle, szMsg );
if (nResult = BACK) goto Dlg_Start;

Dlg_SdLicense:
szLicenseFile = SUPPORTDIR ^ "license.txt";
szTitle = "";
szMsg = "";
szQuestion = "";
nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
if (nResult = BACK) goto Dlg_SdWelcome;

Dlg_SdAskDestPath:
szTitle = "";
szMsg = "";
nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
TARGETDIR = szDir;
if (nResult = BACK) goto Dlg_SdWelcome;

Dlg_SetupType:
szTitle = "";
szMsg = "";
nResult = SetupType ( szTitle , szMsg , "" , 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;
szTitle = "";
szMsg = "";
szTargetdir = TARGETDIR;
szComponents = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
nResult = SdComponentTree(szTitle, szMsg, szTargetdir, szComponents, nLevel);
if (nResult = BACK) goto Dlg_SetupType;
endif;

Dlg_ObjDialogs:
nResult = ShowObjWizardPages(nResult);
if (nResult = BACK) goto Dlg_SdComponentTree;

Dlg_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string(szName) to a list(listStartCopy).
//eg. ListAddString(listStartCopy,szName,AFTER);
nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
ListDestroy(listStartCopy);
if (nResult = BACK) goto Dlg_ObjDialogs;

// setup default status
SetStatusWindow(0, "");
Enable(STATUSEX);
StatusUpdate(ON, 100);

return 0;
end;

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoving
//
// EVENT: Moving event is sent when file transfer is started as a result of
// ComponentTransferData call, before any file transfer operations
// are performed.
//
///////////////////////////////////////////////////////////////////////////////
function OnMoving()
string szAppPath;
begin
// Set LOGO Compliance Application Path
// TO DO : if your application .exe is in a subfolder of TARGETDIR then add subfolder
szAppPath = TARGETDIR;
RegDBSetItem(REGDB_APPPATH, szAppPath);
RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY);
end;
function modifdbdir()
STRING szinstallfile;
NUMBER nvResult,nvLineNumber;
STRING szwindir,svReturnLine;
NUMBER sn,nStartPos;
STRING sz1,sz2,sznewdir;
NUMBER nTemp;
begin
szinstallfile = TARGETDIR ^"conf\\my.txt";
while (nvResult != END_OF_FILE)
nvResult = FileGrep (szinstallfile, "c:/armsun", svReturnLine,nvLineNumber, RESTART);
sn=StrLength (svReturnLine);
nStartPos = StrFind(svReturnLine,"c:/armsun");
StrSub (sz1, svReturnLine, 0, nStartPos);
StrSub (sz2, svReturnLine, nStartPos+9, sn-nStartPos-9);
sznewdir=sz1+TARGETDIR ^sz2;
FileInsertLine(szinstallfile, sznewdir,nvLineNumber, REPLACE);
sz1="";
sz2="";
sznewdir="";
endwhile;

end;

//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnAppSearch
//
// EVENT: AppSearch event is used as an entry point to implement code to
// search for previous versions of the current application. This
// event is sent only for a first time installation.
//
///////////////////////////////////////////////////////////////////////////////
function OnAppSearch()
begin
end;

// --- include script file section ---


XACZ 2003-09-14
  • 打赏
  • 举报
回复
在程序启动时可以更新一次INi文件内容也不是很麻烦的事情,最多10行代码就搞定了
老朱-yubing 2003-09-14
  • 打赏
  • 举报
回复
你是说手工改写啊?
当然手工改写也可以的,
但是不是很麻烦啊,而且每次安装一次软件,
得重新修改配置文件的安装目录
这个不太方便没有体现installshied的强大功能来。
比如说金山词霸就是你可以随便安装在哪个目录但是配置文件不用自己手工改的。
jlsg 2003-09-14
  • 打赏
  • 举报
回复
难道必须替换config.txt中的文本吗,重写不也可以解决吗?
老朱-yubing 2003-09-14
  • 打赏
  • 举报
回复
不行啊,配置文件是ini文件,修改注册表没有用,
只能修改配置文件。
软件才能运行。
zhuma 2003-09-14
  • 打赏
  • 举报
回复
Faint
还用txt
操作注册表亚

wise是wiseinstall
一种比installshield更简单的工具
老朱-yubing 2003-09-14
  • 打赏
  • 举报
回复
请问是wise是什么?
如此成功过吗?
hurricane 2003-09-13
  • 打赏
  • 举报
回复
我用wise做过类似的东西,感觉是先找到包含c:\setup的行,再将该行以c:\setup为标记进行分割,然后用<TARGETDIR>将分割后的各段串起来。

1,265

社区成员

发帖
与我相关
我的任务
社区描述
软件工程/管理 管理版
社区管理员
  • 研发管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧