Wednesday, July 15, 2009

InstallShield and Windows Services: ServiceExistsService doesn't work

So for me, ServiceExistsService didn't work at all.
There are some permission issues apparently (see http://community.acresso.com/archive/index.php?t-169135.html)
but the solution proposed there is a tad too heavy-weight for me.
Here's an alternative, use the Registry entry of a service to figure out if the service is installed or not:
// Indicates if the service with this key (e.g. myNewService) has been installed
function BOOL windowsServiceExists(serviceKey)
string szKey,szServiceName;
number nRootKey;
begin
nRootKey = HKEY_LOCAL_MACHINE;
if (RegDBSetDefaultRoot (nRootKey) <>
MessageBox ("Unable to set HKEY_LOCAL_MACHINE.", SEVERE);
return FALSE;
endif;
szKey = "SYSTEM\\CurrentControlSet\\Services\\" + serviceKey;
//MessageBox("Testing for service: " + serviceKey, INFORMATION);
if (RegDBKeyExist (szKey) = 1 )
then
//MessageBox("found service:" + szServiceName, INFORMATION);
return TRUE;
endif;
return FALSE;
end;

No comments:

Post a Comment