InstallShield高级应用--获取机机所有ORACLE服务列表

//=====================================================================//
// //
// function GetOracleServerList //
// 获取机机所有ORACLE服务列表//
// purpose get the local oracle servers from the tnsnames.ora //
// from the path %oraclepath%\nerwork\admin //
// //
// argment //
// //
// return local oracle server list //
// //
// author chenhuicong 2010-12-18 //
// //
//=====================================================================//


EXPORT prototype LIST GetOracleServerList();

function LIST GetOracleServerList()
NUMBER nvHomeCount,nKeyType, nvSize,nFileHandle;
LIST listID;
STRING svOraclePath,svLine,svOraFileName,svOracleItem;
INT iVal, iLength,iItemLen;
begin
//ora filename
svOraFileName = "tnsnames.ora";
// defaut regedit root
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

//oralce regedit path
if(RegDBGetKeyValueEx ("SOFTWARE\\ORACLE\\ALL_HOMES\\ID0", "PATH",nKeyType, svOraclePath, nvSize) = 0) then
//oracle path
svOraclePath= svOraclePath^"network\\admin\\";
// Create a list to store lines from the file.
listID = ListCreate (STRINGLIST);
// Set the file mode to normal.
OpenFileMode (FILE_MODE_NORMAL);
// Open the file for editing.
if(OpenFile (nFileHandle, svOraclePath, svOraFileName) = 0 ) then
try
// Get lines from the file into the list.
while (GetLine (nFileHandle, svLine) = 0)
if(svLine[0] != "#" && svLine[0] != " " && svLine[0] != "(") then
iVal = 0;
iLength = StrLength (svLine);
while (iVal <= iLength)
if(svLine[iVal] = "=" || svLine[iVal] = " ") then
svLine[iVal] = NOTHING;
endif;
iVal++;
endwhile;
if(iLength > 0 ) then
ListAddString (listID, svLine, AFTER);
endif;

endif;
endwhile;
// Close the file.
CloseFile (nFileHandle);
// Remove the list from memory.
//ListDestroy (listID);
catch
CloseFile (nFileHandle);
//ListDestroy (listID);
endcatch;
endif;
endif;

return listID;
end;

posted @ 2012-05-11 11:06  ☆会飞的鱼☆  阅读(431)  评论(0编辑  收藏  举报