|
今天在csdn上发的帖子,但等了一下午也没人能回答,贴到这里,哪位大虾指教一下。 from:http://community.csdn.net/Expert/topic/4237/4237815.xml?temp=5.045718E-02 日前做一个安装程序,要一起安装数据库。 程序写到了这里,可以得到局域网内的所有服务器的列表,但是怎么也得不到每个sqlserver服务器上的SqlServer Group,请高手指教,是不是这个ServerGroup声明错误? /// <summary> /// 获得局域网可用服务器列表 /// </summary> /// <returns>局域网可用服务器列表</returns> public ArrayList GetServerList() { SQLDMO.ApplicationClass oApp = new SQLDMO.ApplicationClass(); ArrayList alTemp = new ArrayList(); try { SQLDMO.NameList iServerList = oApp.ListAvailableSQLServers(); //ServerGroups 对象 //这个对象的声明不知有没有错误 SQLDMO.ServerGroups group = oApp.ServerGroups ; if( iServerList != null ) { for( int i = 1; i <= iServerList.Count; i++ ) { //加入局域网sql服务器列表到ArrayList中 alTemp.Add( iServerList.Item(i).ToString() ); // group = oApp.ServerGroups try { // SQLDMO.GroupClass groups = new SQLDMO.GroupClass(); // SQLDMO.ServerGroups iGroup = groups.ListUsers(); foreach(char s in group) { alTemp.Add(s); } } catch{} } } return alTemp; } catch { return null; } } 另外,该如何取得IIS的版本号?察看DirectoryEntry 对象的属性,没有找到关于IIS版本号的。是不是每个系统只能安装特定的版本吗?比如win2000安装IIS5.0,XP-IIS5.1, win2003-IIS6? XP一定不能安装IIS6?win2k,2k3都能创建站点,2k3还能创建appPool,所以这个安装程序要根据IIS版本号或系统OS来安装相应的虚拟目录或站点,以及创建appPool。是不是只需判断OS就行了? string metabasepath = "IIS://localhost/W3SVC/1"; // or "IIS://localhost/W3SVC/1/root" // or "IIS://localhost/W3SVC" try { DirectoryEntry entry = new DirectoryEntry(metabasePath); PropertyCollection props = entry.Properties; Console.WriteLine(" Total properties = {0}", props.Count); foreach (string propName in props.PropertyNames) { PropertyValueCollection propValues = entry.Properties[propName]; Console.WriteLine("PropertyValueCollection Type: \t" + propValues.Value.GetType().ToString()); Console.WriteLine("\nPropertyValueCollection Value: \t" + propValues.Value.ToString()); Console.Write("{0} =", propName); foreach (object value in entry.Properties[propName]) { Console.WriteLine("\t{0} \t({1})", value.ToString(), value.GetType()); } } Console.WriteLine(" Done."); } catch (Exception ex) { Console.WriteLine("Failed in EnumeratePath with the following exception: \n{0}", ex.Message); }
|