Showing posts with label InstallShield Script. Show all posts
Showing posts with label InstallShield Script. Show all posts

Monday, April 12, 2010

Delete Registry key using Install Script

Delete Registry key using Install Script.

Here is the function you can use to delete a registry key in InstallShield project.


function DeleteRegisrtyKey(szKey)

STRING szClass;

begin

try

RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );

szKey="SOFTWARE\\"+szKey;

WriteLog("Trying to delete registry value for "+szKey);

szClass = "FPClass";

if (RegDBKeyExist(szKey) < 0) then

WriteLog(szKey +" can not be located in the registry. Deletion failed.");

MessageBox("Unable to delete the registry "+szKey,INFORMATION);

else

if (RegDBDeleteKey (szKey) < 0) then

WriteLog("Failed to delete the Registry.");

else

WriteLog("Registry successfully deleted.");

endif;

endif;

catch

WriteErrorLog("Exception during deleting the registry key. The key is: "+szKey);

endcatch;

end;

Monday, February 15, 2010

Check if a String contains a substring using InstallScript

Check if a String contains a substring.

If you want to check whether a string contains a specific substring or not, it's quite easy in .net or Java or any other OO language. But when it comes to InstallScript it's not that straight forward. In spent little time on InstallShield help but could not manage anything usual. And then finally google help me to reach some example on that. Here is a function I wrote to use in my project:


prototype BOOL IsStringContains(STRING,STRING);

function BOOL IsStringContains(szSource, szArgs)

BOOL bIsContains;

begin

if(szSource % szArgs) then

bIsContains = TRUE;

else

bIsContains = FALSE;

endif;

return bIsContains;

end;


And then I use this call this function like this:


if(IsStringContains("This is Zakirul","Zakirul")) then

MessageBox("String match found.", INFORMATION);

else

MessageBox("String doesn't found",INFORMATION);

endif;


Hope this will help you.

Thanks,

Zakirul

Sunday, October 26, 2008

Creating a Windows Registry entry in InstallShield script

Hi,

Now we will try to create a Registry entry from Installshield script. Here I am giving a function which I have used in my projects and its worked fine.

function CreateRegistry(sKey, sKeyName, sKeyValue)

int iResult;

STRING sClass;

begin

Disable(LOGGING);

WriteLog("Trying to create registry. Reg Key: "+sKey+ " ,KeyName: "+sKeyName+" ,KeyValue: "+sKeyValue);

try

sKey="SOFTWARE\\"+sKey;

RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );

sClass = "FPClass";

if( RegDBCreateKeyEx(sKey,sClass)< 0 ) then

WriteLog("Failed to create registry key.");

MessageBox("Fail to create key for application",INFORMATION);

else

WriteLog("Registry Key successfully created. Trying to create Registry Value.");

iResult = RegDBSetKeyValueEx(sKey,sKeyName,REGDB_STRING_EXPAND,sKeyValue,-1);

if(iResult > 0) then

WriteLog("Failed to creat Registry value");

MessageBox("Unable to create Registry",INFORMATION);

else

WriteLog("Registry value successfully created.");

endif ;

endif;

catch

WriteErrorLog("Unable to create registry key. The key is "+sKey+" and name is "+sKeyName);

MessageBox("Unable to create Registry", INFORMATION);

endcatch;

Enable(LOGGING);

end;


Hope this will help someone somewhereJ.