function BOOL DetectApacheServer(svPath, svFile, svService, svVer, bLog)
#define UKEY "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
#define UKEY20 "SOFTWARE\\Apache Group\\Apache"
#define UKEY22 "SOFTWARE\\Apache Software Foundation\\Apache"
BOOL bResult, bFind1, bFind2;
string RegPath,sKey,sFolder,sValue,sData,svVersionNumber,Path;
number nType,nSize,nReturn;
LIST listSubKeys;
int i;
begin
bResult = FALSE;
bFind1 = FALSE;
bFind2 = FALSE;
//Sprawdzenie w rejestrach do wersji Apache 2.0
if (bLog) then WriteLog(0,"* Sprawdzenie zainstalowanego serwera Apache 2.x"); endif;
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
if ( (RegDBKeyExist(UKEY20)==1)||(RegDBKeyExist(UKEY22)==1) ) then //Znaleziono w rejestrach
listSubKeys = ListCreate(STRINGLIST);
bFind1 = FALSE;
if (RegDBKeyExist(UKEY20)==1) then
nReturn = RegDBQueryKey(UKEY20, REGDB_KEYS, listSubKeys );
if (nReturn=0) then
if (ListCount(listSubKeys)>0) then
ListSetIndex(listSubKeys,LISTFIRST);
for i=0 to ListCount(listSubKeys)-1
ListCurrentString ( listSubKeys, sKey );
RegPath=UKEY20+"\\"+sKey;
svVer = sKey;
if (RegDBKeyExist(RegPath)==1) then
sValue="ServerRoot";
sKey = RegPath;
if (RegDBGetKeyValueEx( sKey, sValue, nType, sData, nSize )==0) then
svPath = sData;
bFind1 = TRUE;
endif; //ServerRoot;
endif; //Klucz rejestru
ListSetIndex ( listSubKeys, LISTNEXT );
endfor;
endif;
endif;
if ((bFind1)&&(Is(PATH_EXISTS,svPath))) then
if (bLog) then
WriteLog(1,"Znaleziono zainstalowany serwer Apache w wersji:"+svVer);
WriteLog(1,"- katalog serwera:\""+svPath+"\"");
endif;
else
bFind1 = FALSE;
endif;
endif; //UKEY20;
if (RegDBKeyExist(UKEY22)==1) then
ListDestroy( listSubKeys);
listSubKeys = ListCreate(STRINGLIST);
bFind2 = FALSE;
nReturn = RegDBQueryKey(UKEY22, REGDB_KEYS, listSubKeys );
if (nReturn=0) then
if (ListCount(listSubKeys)>0) then
ListSetIndex(listSubKeys,LISTFIRST);
for i=0 to ListCount(listSubKeys)-1
ListCurrentString ( listSubKeys, sKey );
RegPath=UKEY22+"\\"+sKey;
svVer = sKey;
if (RegDBKeyExist(RegPath)==1) then
sValue="ServerRoot";
sKey = RegPath;
if (RegDBGetKeyValueEx( sKey, sValue, nType, sData, nSize )==0) then
svPath = sData;
bFind2 = TRUE;
endif; //ServerRoot;
endif; //Klucz rejestru
ListSetIndex ( listSubKeys, LISTNEXT );
endfor;
endif;
endif;
if ((bFind2)&&(Is(PATH_EXISTS,svPath))) then
if (bLog) then
WriteLog(1,"Znaleziono zainstalowany serwer Apache w wersji:"+svVer);
WriteLog(1,"- katalog serwera:\""+svPath+"\"");
endif;
else
bFind2 = FALSE;
endif;
endif; //UKEY22;
endif;
//---------- Koniec sprawadzania po rejestrach windows
//***** Sprawdzenie po katalogach
if (! (bFind1 || bFind2)) then
if (Is(FILE_EXISTS, PROGRAMFILES^"Apache Group\\Apache2\\bin\\Apache.exe")) then
svPath = PROGRAMFILES^"Apache Group\\Apache2";
VerGetFileVersion(PROGRAMFILES^"Apache Group\\Apache2\\bin\\Apache.exe",svVer);
svFile = "Apache.exe";
svService = "Apache2";
if (bLog) then
WriteLog(1,"Znaleziono zainstalowany serwer Apache w wersji:"+svVer);
WriteLog(1,"- katalog serwera:\""+svPath+"\"");
endif;
bFind1 = TRUE;
endif;
if (Is(FILE_EXISTS, PROGRAMFILES^"Apache Software Foundation\\Apache2.2\\bin\\httpd.exe")) then
svPath = PROGRAMFILES^"Apache Software Foundation\\Apache2.2";
VerGetFileVersion(PROGRAMFILES^"Apache Software Foundation\\Apache2.2\\bin\\httpd.exe",svVer);
svFile = "httpd.exe";
svService = "Apache2.2";
if (bLog) then
WriteLog(1,"Znaleziono zainstalowany serwer Apache w wersji:"+svVer);
WriteLog(1,"- katalog serwera:\""+svPath+"\"");
endif;
bFind2 = TRUE;
endif;
if (Is(FILE_EXISTS, PROGRAMFILES^"Apache Software Foundation\\Apache2\\bin\\httpd.exe")) then
svPath = PROGRAMFILES^"Apache Software Foundation\\Apache2";
VerGetFileVersion(PROGRAMFILES^"Apache Software Foundation\\Apache2\\bin\\httpd.exe",svVer);
svFile = "httpd.exe";
svService = "Apache2";
if (bLog) then
WriteLog(1,"Znaleziono zainstalowany serwer Apache w wersji:"+svVer);
WriteLog(1,"- katalog serwera:\""+svPath+"\"");
endif;
bFind2 = TRUE;
endif;
endif;
if (bFind1)||(bFind2) then
bResult = TRUE;
else
if (bLog) then WriteLog(1," - brak zainstalowanego serwera Apache"); endif;
endif;
return bResult;
end;
Programowanie c++/c#/delphi/javas/php/installscript/nativescript
Przykłady - przydatne funkcje
środa, 21 kwietnia 2010
Detekcja zainstalowanego serwera Apache
Funkcja zwraca sciężkę instalacji, nazwę pliku serwisu, nazwę serwisu, wersję Apache
Etykiety:
InstallShield - Apache Serwer
Subskrybuj:
Komentarze do posta (Atom)
Brak komentarzy:
Prześlij komentarz