<head>
<title>WMI Query・テスト - HTA</title>
<script type="text/javascript">
//・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
var SWbemServices
function サービスの取得(){
try{ var ele, str = (ele= document.getElementById('text0')).value // 入力欄
SWbemServices = GetObject(str)
ele.parentNode.innerHTML = '<small>'+str+'</small>' ; return true;
}catch(e){ alert(e.description); return }
}///
function 実行(strQuery){
if( !strQuery){ alert('Query が空'); return }
if(!SWbemServices) if( !サービスの取得()) return
try{ var objSet = SWbemServices.ExecQuery(strQuery)
}catch(e){ alert(e.description); return }
try{ objSet.Count }catch(e){ alert(e.description); return }
// ↑ objSet は null でなく、typeof 'object' なのだが、エラーになる
if(objSet.Count==0) alert("なし、\n {SWbemObjectSet}.Count は、0")
else if( !objSet.Count) alert("なし、\n Count プロパティーがない")
else if(objSet.Count==1) 詳細のHTML表示( (new Enumerator(objSet)).item() )
else リストの作成(objSet)
}///
function リストの作成(objSet){
var 集 = new Enumerator(objSet);
var str = '', path
for(; ! 集.atEnd(); 集.moveNext()){
path = 集.item().Path_.RelPath
str += '<div class="pathLi" onclick="パスから詳細へ(\x27'
+ path.replace(/\\/g,'\\\\').replace(/\x22/g,'\\x22') +'\x27)">'
+ path +'</div>'
}///
document.getElementById('dispL').innerHTML = str
}///
function パスから詳細へ(path){
if(!SWbemServices) if( !サービスの取得()) return
try{ var obj = SWbemServices.Get(path)
}catch(e){ alert(e.description); return }
詳細のHTML表示(obj)
}///
function 詳細のHTML表示(obj){
var str = 詳細の作文(obj)
str = str.replace(/</g,'<').replace(/ /g,' ')
.replace(/\t/g,' ').replace(/\n/g,'<br>\n')
document.getElementById('dispR').innerHTML = str
}///
//・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
function 詳細の作文(obj, 再){
var str ='', s;
var プロパ又メソ = function(objSet, 標){
if( ! objSet.Count) return;
var 集 = new Enumerator(objSet)
for(; ! 集.atEnd(); 集.moveNext()){
str += (標=='p' ? '\t': '') + 集.item().Name
+(標=='p' && ! obj.Path_.IsClass ? ' : '+ 集.item().Value: '' ) +'\n'
if(標=='m') str += '\tInParameters' + ( 集.item().InParameters ?
'\n'+ 詳細の作文(集.item().InParameters, '再').replace(/^(.+)/mg,'\t\t$1') : ' -\n')
+ '\tOutParameters' + ( 集.item().OutParameters ?
'\n'+ 詳細の作文(集.item().OutParameters, '再').replace(/^(.+)/mg,'\t\t$1') : ' -\n')
}///
}///
if(!再) str += '■ '+ obj.Path_.RelPath +' ■'
+ (obj.Path_.IsClass ? ' IsClass':'')
+ (obj.Path_.IsSingleton ? ' IsSingleton':'') +'\n'
+ '\t'+ obj.Path_.Path +'\n'
str += (再 ? 'Properties_ ': '\n◆ Properties_ ') + obj.Properties_.Count +'\n'
プロパ又メソ(obj.Properties_, 'p')
if(!再){ str += '\n◆ Methods_ '+ obj.Methods_.Count +'\n'
プロパ又メソ(obj.Methods_, 'm') }///
if(s= obj.GetObjectText_() ){
var 置換関数2 = function(m, s1){
return '(\n' + s1.replace(/(\[.+?\])([^\[]+)/g,'\t\t$1\n\t\t$2\n') +'\t );' }///
var 置換関数1 = function(m, s1, s2){
return s1 +'\n\t' + s2.replace(/\((.+)\);$/g, 置換関数2) +'\n' }///
str += (再 ? '': '\n◆ ObjectText\n') + s.replace(/(\t\[.+?\])(.+)?\n/g, 置換関数1) +'';
}///
if(s= obj.Derivation_)str += ''+ s +'\n'
return str + (再 ? '': '\n')
}/////
//・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
function 入力欄へ(str){ textArea1.value += ' '+ str +' ' }///
//・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
</script>
<style type="text/css">
body{ margin:0; overflow:hidden; /*overflow:hidden; */
background-color:window; color:windowtext; }
.inputText{ font-weight:bolder; font-family:monospace; }
#textArea1{ font-weight:bolder; font-family:monospace;
line-height:1.5; font-size:small;/*中にする為*/ }
table{ margin-left:1em; margin-right:1em; }
/* 左面、右面 */
#dispL, #dispR{ position:absolute; top:expression(disp0.offsetTop);
height:expression(document.body.clientHeight-disp0.offsetTop); }
#dispL{ width:25%; overflow:auto; /* 左面、リスト */
border-right-style:outset;
padding:0.5em; padding-top:0; word-break:break-all; }
#dispR{ left:25%; width:75%; overflow:auto; /* 右面、詳細の表示 */
padding:0.5em; padding-top:0; white-space:nowrap; }
/* ボタン類 */
.btn{ font-weight:bolder; white-space:nowrap; /* 3Dボタン */
border-style:outset; border-color:threedlightshadow; cursor:pointer;
padding-left:2px; padding-top:2px; }
.pathLi{ margin-left:2em; text-indent:-2em; /* 左面のパス */
font-weight:bolder; cursor:pointer; }
.word{ cursor:pointer; text-decoration:underline; }
</style>
<!--・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・-->
</head><body>
<table style="width:95%; white-space:nowrap;">
<tr><td style="text-align:left;">
<input type="text" id="text0" size="40" class="inputText" value="winmgmts:root/cimv2">
<td style="text-align:right; ">
<input type="text" id="text1" size="40" class="inputText" value="" title="パスで調べる">
<span onclick="var p=text1.value; if(p)パスから詳細へ(p.replace(/^\s+|\s+$/g,' '));
else alert('欄が空');" class="btn" title="左欄のパスを調べる"
style="font-size:smaller;">詳細</span>
</table>
<table style="width:95%;">
<tr><td colspan="2">
<textarea id="textArea1" style="width:100%; height:3.5em; "></textarea>
<!-- textArea 中の改行や空白の連なりは、一つの空白に縮める -->
<tr style="height:2em;">
<td style="text-align:left; vertical-align:top; font-size:smaller;">
<span onclick="入力欄へ(this.innerHTML)" class="word">SELECT</span> プロパティ
<span onclick="入力欄へ(this.innerHTML)" class="word">FROM</span> クラス
<span onclick="入力欄へ(this.innerHTML)" class="word">WHERE</span> プロパティー = 値
<span onclick="入力欄へ(this.innerHTML)" class="word"></span>
<span onclick="入力欄へ(this.innerHTML)" class="word"></span>
<td style="text-align:right; line-height:2em; "> <small>Query</small>
<span onclick="実行( textArea1.value.replace(/\s+/g,' ') );" class="btn" title="">実行</span>
</table>
<div id="disp0"><!-- 結果の表示 -->
<div id="dispL"></div> <div id="dispR"></div>
</div>
<!--・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・-->