<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://w.atwiki.jp/lockerroom/">
    <title>lockerroom @ ウィキ</title>
    <link>http://w.atwiki.jp/lockerroom/</link>
    <atom:link href="https://w.atwiki.jp/lockerroom/rss10.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
    <description>lockerroom @ ウィキ</description>

    <dc:language>ja</dc:language>
    <dc:date>2010-11-11T01:14:39+09:00</dc:date>
    <utime>1289405679</utime>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/2.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/15.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/14.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/13.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/1.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/3.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/4.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/5.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/6.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/lockerroom/pages/7.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/2.html">
    <title>メニュー</title>
    <link>https://w.atwiki.jp/lockerroom/pages/2.html</link>
    <description>
      **メニュー
-[[トップページ]]
-[[プラグイン紹介&gt;プラグイン]]
-[[AuttoHotKey::ActiveX.ahk&gt;ActiveX.ahk]]
-[[                    ActiveXSample.ahk&gt;ActiveXSample.ahk]]
-[[メニュー]]
-[[メニュー2]]
----
// リンクを張るには &quot;[&quot; 2つで文字列を括ります。
// &quot;&gt;&quot; の左側に文字、右側にURLを記述するとリンクになります
//**更新履歴
//#recent(20)

&amp;link_editmenu(text=ここを編集)    </description>
    <dc:date>2010-11-11T01:14:39+09:00</dc:date>
    <utime>1289405679</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/15.html">
    <title>ActiveXSample.ahk</title>
    <link>https://w.atwiki.jp/lockerroom/pages/15.html</link>
    <description>
      /* Sample_IE.ahk */
#Persistent

#include %A_ScriptDir%¥ActiveX.ahk

;初期化
ActiveX()

;オブジェクト作成
ie:=CreateObject(&quot;InternetExplorer.Application&quot;)


;プロパティへの書き込み
pp(ie,&quot;Visible&quot;,&quot;true&quot;)

;メソッド呼び出し
inv(ie,&quot;Navigate&quot;,&quot;about:blank&quot;)

;プロパティオブジェクトの取得
doc:=gp(ie,&quot;Document&quot;)
win:=gp(doc,&quot;parentWindow&quot;)

inv(doc,&quot;write&quot;,&quot;Hello!&lt;br&gt;&lt;br&gt;&quot;)

;イベントの割り当て
ConnectObject(doc,&quot;Document_&quot;)
ConnectObject(win,&quot;Window_&quot;)

;オブジェクト解放
Release(doc)
Release(win)
Release(ie)
return

;イベントに割り当てられる関数
Document_onfocusin(this,prm,res){
	inv(this,&quot;write&quot;,&quot;focuse in&lt;br&gt;&quot;)
}
Document_onfocusout(this,prm,res){
	inv(this,&quot;write&quot;,&quot;focuse out&lt;br&gt;&quot;)
}
Window_onbeforeunload(this,prm,res){
	MsgBox,閉じます
	SetTimer,quit,-100
}
quit:
ExitApp


---------------------------
/* sample_JScript.ahk */

#include %A_ScriptDir%¥ActiveX.ahk
ActiveX()

;JScript のコードを埋め込み
script=
(
	for(var i=5;i&gt;0;i--){
		sapi.Speak(i+&quot;,&quot;);
	}
	sapi.Speak(&quot;0!&quot;);
)

sc:=CreateObject(&quot;MSScriptControl.ScriptControl.1&quot;)
pp(sc,&quot;Language&quot;,&quot;jscript&quot;)

sapi:=CreateObject(&quot;Sapi.SpVoice&quot;)
inv(sc,&quot;AddObject&quot;,&quot;sapi&quot;,vObj(sapi))

inv(sc,&quot;Eval&quot;,script)

---------------------------
/* sample_SpeechRecognition.ahk */

#Persistent
#include *i %A_ScriptDir%¥ActiveX.ahk
ActiveX()

sr:=CreateObject(&quot;SAPI.SpSharedRecognizer&quot;)

context:=inv(sr,&quot;CreateRecoContext&quot;)
grammar:=inv(context,&quot;CreateGrammar&quot;)
inv(grammar,&quot;DictationSetState&quot;,0)
rules:=gp(grammar,&quot;Rules&quot;)

rule:=inv(rules,&quot;Add&quot;,&quot;wordsRule&quot;,33,0)
inv(rule,&quot;Clear&quot;)

init:=gp(rule,&quot;InitialState&quot;)
AddWord(init,&quot;close&quot;)
AddWord(init,&quot;yes&quot;)
AddWord(init,&quot;no&quot;)
AddWord(init,&quot;ok&quot;)
AddWord(init,&quot;cancel&quot;)

inv(rules,&quot;Commit&quot;)
inv(grammar,&quot;CmdSetRuleState&quot;,&quot;wordsRule&quot;,1)
inv(rules,&quot;Commit&quot;)

ConnectObject(context,&quot;SR_&quot;)
ReleaseL(sr,context,grammar,rule,init)

AddWord(pState,word){
	inv(pState,&quot;AddWordTransition&quot;,vNull(),word)
}
SR_Recognition(this,prm,r){
	result:=evArgv(prm,3)
	pi:=gp(result,&quot;PhraseInfo&quot;)
	txt:=inv(pi,&quot;GetText&quot;)
	if txt=yes
		Send,!y
	else if txt=no
		Send,!n
	else if txt=ok
		ControlClick,OK,A
	else if txt=cancel
		ControlClick,キャンセル,A
	else if txt=close
		WinClose,A
	Release(pi)
}

---------------------------
/* sample_UsingAhkCommandsFromJscript.ahk */

#include *i %A_ScriptDir%¥ActiveX.ahk
ActiveX()

MyClass_WinMaximize(this,prm,res,flags){
	WinMaximize,% evArgv(prm,0)
}
MyClass_Send(this,prm,res,flags){
	Send,% evArgv(prm,0)
}

;JScript
script=
(
	AutoHotkey.WinMaximize(&quot;A&quot;);
	Send(&quot;abcd{Shift Down}{Left 4}{Shift Up}&quot;);
)


sc:=CreateObject(&quot;MSScriptControl.ScriptControl.1&quot;)
pp(sc,&quot;Language&quot;,&quot;jscript&quot;)
myobj:=CreateDispatchObject(&quot;MyClass_&quot;)
inv(sc,&quot;AddObject&quot;,&quot;AutoHotkey&quot;,vObj(myobj),&quot;true&quot;)
inv(sc,&quot;Eval&quot;,script)    </description>
    <dc:date>2010-11-11T01:14:02+09:00</dc:date>
    <utime>1289405642</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/14.html">
    <title>ActiveX.ahk</title>
    <link>https://w.atwiki.jp/lockerroom/pages/14.html</link>
    <description>
      /*
COM操作ライブラリ	by 流行らせるページ管理人
 Ver 3β
*/

ActiveX(){
	global
	IID_IDispatch:=GUID(&quot;{00020400-0000-0000-C000-000000000046}&quot;)
	IID_IUnknown:=GUID(&quot;{00000000-0000-0000-C000-000000000046}&quot;)
	IID_NULL:=GUID(&quot;{00000000-0000-0000-0000-000000000000}&quot;)
	IID_IConnectionPointContainer:=GUID(&quot;{B196B284-BAB4-101A-B69C-00AA00341D07}&quot;)
	IID_IProvideClassInfo:=GUID(&quot;{B196B283-BAB4-101A-B69C-00AA00341D07}&quot;)
	;IID_IProvideClassInfo2:=GUID(&quot;{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}&quot;)
	LOCALE_USER_DEFAULT:=DllCall(&quot;kernel32.dll¥GetUserDefaultLCID&quot;)
	CoInitialize()
}



/*
	**********************************
	汎用メモリ管理
	**********************************
*/

;メモリを確保しポインタを返す
Malloc(size,flag=0x40){
	return DllCall(&quot;kernel32.dll¥GlobalAlloc&quot;,&quot;UInt&quot;,flag,&quot;UInt&quot;,size,&quot;UInt&quot;)
}
;ポインタで指定されたメモリを解放する
Free(p){
	DllCall(&quot;kernel32.dll¥GlobalFree&quot;,UInt,p,UInt)
}


/*
	**********************************
	GUID関連
	**********************************
*/

;CLSID文字列からGUID構造体を生成しアドレスを得る(仮)
GUID(string){
	size:=DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,string,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0)
	wstr:=Malloc((size+1)*2)
	DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,string,&quot;Int&quot;,-1,&quot;UInt&quot;,wstr,&quot;Int&quot;,(size+1)*2)
	ptr:=Malloc(16)
	DllCall(&quot;ole32.dll¥CLSIDFromString&quot;,&quot;UInt&quot;,wstr,&quot;UInt&quot;,ptr)
	Free(wstr)
	return ptr 
}
;ProgID文字列からGUID構造体を生成しアドレスを得る(仮)
ProgID(string){
	size:=DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,string,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0)
	wstr:=Malloc((size+1)*2)
	DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,string,&quot;Int&quot;,-1,&quot;UInt&quot;,wstr,&quot;Int&quot;,(size+1)*2)
	ptr:=Malloc(16)
	DllCall(&quot;ole32.dll¥CLSIDFromProgID&quot;,&quot;UInt&quot;,wstr,&quot;UInt&quot;,ptr)
	Free(wstr)
	return ptr 
}

;GUID構造体を文字列に変換
fromGUID(ByRef guid){
	ptr:=Malloc(80)
	DllCall(&quot;ole32.dll¥StringFromGUID2&quot;,&quot;UInt&quot;,guid,&quot;UInt&quot;,ptr,&quot;Int&quot;,80)
	res:=wc2mb(ptr)
	Free(ptr)
	return res
}

/*
	**********************************
	Unicode関連
	**********************************
*/

;文字列からにUnicodeへの変換を行う
;返り値はUnicode文字列へのポインタ
mb2wc(mbstr){
	size:=(DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,mbstr,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0)+1)*2
	wstr:=Malloc(size)
	DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,mbstr,&quot;Int&quot;,-1,&quot;UInt&quot;,wstr,&quot;Int&quot;,size)
	return wstr
}
mb2wc_ref(ByRef mbstr){
	size:=(DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,mbstr,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0)+1)*2
	wstr:=Malloc(size)
	DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,mbstr,&quot;Int&quot;,-1,&quot;UInt&quot;,wstr,&quot;Int&quot;,size)
	return wstr
}
;UnicodeからAnsi文字列への変換を行う
;返り値は文字列
wc2mb(wstr){
	size:=DllCall(&quot;kernel32.dll¥WideCharToMultiByte&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,wstr,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,0)
	VarSetCapacity(mbstr,size)
	DllCall(&quot;kernel32.dll¥WideCharToMultiByte&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,wstr,&quot;Int&quot;,-1,&quot;Str&quot;,mbstr,&quot;Int&quot;,size,&quot;UInt&quot;,0,&quot;UInt&quot;,0)
	return mbstr
}

wc2mb_ref(wstr,ByRef mbstr){
	size:=DllCall(&quot;kernel32.dll¥WideCharToMultiByte&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,wstr,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,0)
	VarSetCapacity(mbstr,size)
	DllCall(&quot;kernel32.dll¥WideCharToMultiByte&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,wstr,&quot;Int&quot;,-1,&quot;Str&quot;,mbstr,&quot;Int&quot;,size,&quot;UInt&quot;,0,&quot;UInt&quot;,0)
	return size
}


/*
	**********************************
	COM汎用
	**********************************
*/

CoInitialize(){
	return DllCall(&quot;ole32.dll¥CoInitialize&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;)
}
CoUninitialize(){
	return DllCall(&quot;ole32.dll¥CoUninitialize&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;)
}
OleInitialize(){
	return DllCall(&quot;ole32.dll¥OleInitialize&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;)
}
OleUninitialize(){
	return DllCall(&quot;ole32.dll¥OleUninitialize&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;)
}
CoTaskMemAlloc(size){
 	return DllCall(&quot;ole32.dll¥CoTaskMemAlloc&quot;,&quot;UInt&quot;,size,&quot;UInt&quot;)
}
CoTaskMemFree(ptr){
 	return DllCall(&quot;ole32.dll¥CoTaskMemFree&quot;,&quot;UInt&quot;,ptr,&quot;UInt&quot;)
}
M(ByRef ip,idx=0){
	return NumGet(NumGet(ip+0)+4*idx)
}
QueryInterface(pObj,strIID=&quot;&quot;){
	global IID_IDispatch
	guid:=0
	if(strIID=&quot;&quot;){
		IID:=IID_IDispatch
	}else if(StrLen(strIID)=38){
		IID:=GUID(strIID)
	}else{
		IID:=strIID
	}
	res:=0
	ErrorLevel:=DllCall(M(pObj,0),&quot;UInt&quot;,pObj,&quot;UInt&quot;,IID,&quot;UIntP&quot;,res)
	return res
}
AddRef(pObj){
	if(pObj){
		DllCall(M(pObj,1),&quot;UInt&quot;,pObj)
	}
	return pObj
}
Release(pObj){
	if(pObj){
		return DllCall(M(pObj,2),&quot;UInt&quot;,pObj)
	}
}
ReleaseL(p1,p2=-1,p3=-1,p4=-1,p5=-1,p6=-1,p7=-1,p8=-1,p9=-1){
	format:=A_FormatInteger
	SetFormat,Integer,D
	Loop,10{
		if(p%A_Index%!=-1){
			Release(p%A_Index%)
		}
	}
	SetFormat,Integer,%format%
}

/*
	**********************************
	VARIANT関連
	**********************************
*/

;Ansi文字列をBSTR形式に変換する
toBSTR(str){
	oc:=mb2wc(str)
	res:=DllCall(&quot;oleaut32.dll¥SysAllocString&quot;,&quot;UInt&quot;,oc,&quot;UInt&quot;)
	Free(oc)
	return res
}
;BSTRをAnsi文字列に変換する
fromBSTR(bstr){
	return wc2mb(bstr)
}

;BSTRを解放する(VariantClear内でやってくれるはずなので多分不要)
freeBSTR(bstr,get=0){
	if(get!=0){
		wc2mb_ref(bstr,res)
	}else{
		res=
	}
	DllCall(&quot;oleaut32.dll¥SysFreeString&quot;,&quot;UInt&quot;,bstr)
	return res
}

vNull(){
	return 0x7FFFFFFF00000000
}
vObj(obj){
	return 0x7FFFFFFF00000000 | obj
}
;VARIANTに変換(typeには変換したい型を指定
;settypeを指定すると、型変換した上で、型を示す値としてsettypeで指定した型を格納する
toVariant(value,variant=0,type=0x08,settype=-1){
	global LOCALE_USER_DEFAULT
	;格納先初期化
	if(variant=0){
		dest:=Malloc(16)
	}else{
		dest:=variant
	}
	DllCall(&quot;oleaut32.dll¥VariantInit&quot;,&quot;UInt&quot;,dest)
	if(type=0x08){
		if(value &gt;&gt; 32 = 0x7FFFFFFF){
			if(value-0x7FFFFFFF00000000=0){
				;VT_NULL
				NumPut(0x01,dest+0,0,&quot;UShort&quot;)
			}else{
				;VT_DISPATCH
				NumPut(0x09,dest+0,0,&quot;UShort&quot;)
				NumPut(value - 0x7FFFFFFF00000000,dest+8,0)
			}
		}else{
			;文字列の場合
			NumPut(0x08,dest+0,0,&quot;UShort&quot;)
			NumPut(toBSTR(value),dest+8,0)
		}
	}else{
		;それ以外の型の場合
		tmp:=toVariant(value)
		DllCall(&quot;oleaut32.dll¥VariantChangeTypeEx&quot;,&quot;UInt&quot;,dest,&quot;UInt&quot;,tmp,&quot;UInt&quot;,LOCALE_USER_DEFAULT,&quot;UShort&quot;,0,&quot;UShort&quot;,type)
		if(settype!=-1){
			NumPut(settype,dest+0,0,&quot;UShort&quot;)
		}
		vFree(tmp)
	}
	return dest
}

;VARIANTに格納された内容を通常のAutoHotkey変数として取得
;rawsizeが1,2,4の場合、格納されている生の値を取得
;rawsizeが0の場合、文字列に変換して取得
fromVariant(var,rawsize=0){
	global LOCALE_USER_DEFAULT
	if(rawsize=0){
		type:=NumGet(var+0,0,&quot;UShort&quot;)
		if((type=9)||(type=13)){
			;COMオブジェクト
			pObj:=NumGet(var+8)
			AddRef(pObj)
			return pObj
		}else if(type&gt;0xFF){
			;ポインタもしくは配列		(暫定)
			return NumGet(var+8)
		}else{
			;VT_BSTRに変換
			var2:=Malloc(16)
			DllCall(&quot;oleaut32.dll¥VariantInit&quot;,&quot;UInt&quot;,var2)
			DllCall(&quot;oleaut32.dll¥VariantChangeTypeEx&quot;,&quot;UInt&quot;,var2,&quot;UInt&quot;,var,&quot;UInt&quot;,LOCALE_USER_DEFAULT,&quot;UShort&quot;,0,&quot;UShort&quot;,0x8)
			;値をAnsiに変換
			wc2mb_ref(NumGet(var2+8),res)
			vFree(var2)
			return res
		}
	}else if(rawsize=1){
		return NumGet(var+8,0,&quot;UChar&quot;)
	}else if(rawsize=2){
		return NumGet(var+8,0,&quot;UShort&quot;)
	}else if(rawsize=4){
		return NumGet(var+8)
	}else{
		return fromVariant(var,0)
	}
}

;VARIANTを解放(getに-1以外を指定すると、値を取得して返す)
vFree(ByRef var,get=-1){
	if(get!=-1){
		res:=fromVariant(var,get)
	}else{
		res:=0
	}
	DllCall(&quot;oleaut32.dll¥VariantClear&quot;,&quot;UInt&quot;,var)
	Free(var)
	return res
}


/*
	**********************************
	IDispatch用
	**********************************
*/
;オブジェクトを生成する
CreateObject(clsid,iid=&quot;&quot;,CLSCTX=5){	;CLSCTX_SERVER
	global IID_IDispatch
	if(!IID_IDispatch){
		ActiveX()
	}
	guid:=0
	if(RegExMatch(clsid,&quot;^¥{[¥-0-9a-fA-F]{36}¥}$&quot;)){
		guid:=GUID(clsid)
	}else{
		guid:=ProgID(clsid)
	}
	if(iid=&quot;&quot;){
		iid2:=IID_IDispatch
	}else{
		iid2:=GUID(iid)
	}
	ppRes:=0
	el:=DllCall(&quot;ole32.dll¥CoCreateInstance&quot;,&quot;UInt&quot;,guid,&quot;UInt&quot;,0,&quot;UInt&quot;,CLSCTX,&quot;UInt&quot;,iid2,&quot;UIntP&quot;,ppRes,&quot;UInt&quot;)
	Free(guid)
	if(iid2!=IID_IDispatch){
		Free(iid2)
	}
	ErrorLevel:=el
	return ppRes
}


;objが持つnameメンバのDispatchIDを得る
GetDispID(ByRef obj,name){
	global IID_NULL,LOCALE_USER_DEFAULT
	wName:=mb2wc_ref(name)
	dispid:=0
	DllCall(M(obj,5),&quot;UInt&quot;,obj,&quot;UInt&quot;,IID_NULL,&quot;UIntP&quot;,wName,&quot;UInt&quot;,1,&quot;UInt&quot;,LOCALE_USER_DEFAULT,&quot;UIntP&quot;,dispid,&quot;UInt&quot;)
	Free(wName)
	return dispid
}
;引数からDISPPARAMSを生成
CreateParam(ByRef p1, ByRef p2, ByRef p3, ByRef p4, ByRef p5, ByRef p6, ByRef p7, ByRef p8, ByRef p9, ByRef p10){
	;引数を数える(0xFFFFFFFFFFFFFFFFの前までが与えられた引数)
	num:=0
	format:=A_FormatInteger
	SetFormat,Integer,D
	Loop,10{
		if(p%A_Index%=0xFFFFFFFFFFFFFFFF){
			break
		}
		num++
	}
	;num個のVARIANTARG配列を作成
	if(num=0){
		pvArgs:=0
	}else{
		pvArgs:=Malloc(16*num)
		ptr:=pvArgs+16*(num-1)
		;引数をセットしていく
		Loop,%num%{
			toVariant(p%A_Index%,ptr)
			ptr-=16
		}
	}
	SetFormat,Integer,%format%
	
	;DISPPARAMS作成
	res:=Malloc(16)
	NumPut(pvArgs,	res+0)
	NumPut(num,		res+8)
	return res
}
;DISPPARAMSを解放
FreeParam(ByRef params){
	num:=NumGet(params+8)
	pvArgs:=NumGet(params+0)
	pvNArgs:=NumGet(params+4)
	;VARIANTARGの解放処理
	ptr:=pvArgs
	Loop,%num%{
		vFree(ptr)
		ptr+=16
	}
	;VARIANTARG自体の解放
	Free(ptr)
	;rgdispidNamedArgsの解放
	if(pvNArgs!=0){
		Free(pvNArgs)
	}
	;本体メモリ解放
	Free(params)
}
Invoke(ByRef pObj,ByRef dispid,mode,ByRef params){
	global IID_NULL,LOCALE_USER_DEFAULT
	pvRes:=Malloc(16)
	DllCall(&quot;oleaut32.dll¥VariantInit&quot;,UInt,pvRes)
	DllCall(M(pObj,6),UInt,pObj,UInt,dispid,UInt,IID_NULL,UInt,LOCALE_USER_DEFAULT,UInt,mode,UInt,params,UInt,pvRes,UInt,0,UInt,0,UInt)
	return pvRes
}

inv(obj,name,p1=0xFFFFFFFFFFFFFFFF,p2=0xFFFFFFFFFFFFFFFF,p3=0xFFFFFFFFFFFFFFFF,p4=0xFFFFFFFFFFFFFFFF,p5=0xFFFFFFFFFFFFFFFF,p6=0xFFFFFFFFFFFFFFFF,p7=0xFFFFFFFFFFFFFFFF,p8=0xFFFFFFFFFFFFFFFF,p9=0xFFFFFFFFFFFFFFFF,p10=0xFFFFFFFFFFFFFFFF){
	if((dispid:=GetDispID(obj,name))!=0){
		params:=CreateParam(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
		pvRes:=Invoke(obj,dispid,1,params)
		FreeParam(params)
		return vFree(pvRes,0)
	}
}

gp(obj,name,p1=0xFFFFFFFFFFFFFFFF,p2=0xFFFFFFFFFFFFFFFF,p3=0xFFFFFFFFFFFFFFFF,p4=0xFFFFFFFFFFFFFFFF,p5=0xFFFFFFFFFFFFFFFF,p6=0xFFFFFFFFFFFFFFFF,p7=0xFFFFFFFFFFFFFFFF,p8=0xFFFFFFFFFFFFFFFF,p9=0xFFFFFFFFFFFFFFFF,p10=0xFFFFFFFFFFFFFFFF){
	if((dispid:=GetDispID(obj,name))!=0){
		params:=CreateParam(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
		pvRes:=Invoke(obj,dispid,2,params)
		FreeParam(params)
		return vFree(pvRes,0)
	}
}

pp(obj,name,p1=0xFFFFFFFFFFFFFFFF,p2=0xFFFFFFFFFFFFFFFF,p3=0xFFFFFFFFFFFFFFFF,p4=0xFFFFFFFFFFFFFFFF,p5=0xFFFFFFFFFFFFFFFF,p6=0xFFFFFFFFFFFFFFFF,p7=0xFFFFFFFFFFFFFFFF,p8=0xFFFFFFFFFFFFFFFF,p9=0xFFFFFFFFFFFFFFFF,p10=0xFFFFFFFFFFFFFFFF){
	if((dispid:=GetDispID(obj,name))!=0){
		params:=CreateParam(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
		;rgdispidNamedArgsのセット
		namedArgs:=Malloc(4)
		NumPut(namedArgs,	params+4)
		NumPut(0xFFFFFFFD,	namedArgs+0)
		NumPut(1,			params+12)
		pvRes:=Invoke(obj,dispid,4,params)
		FreeParam(params)
		return vFree(pvRes)
	}
}

/*
	**********************************
	イベントシンク用コールバック関数
	**********************************
*/
GuidIsEqual(guid1,guid2){
	return DllCall(&quot;MSVCRT.dll¥memcmp&quot;,&quot;UInt&quot;,guid1,&quot;UInt&quot;,guid2,&quot;UInt&quot;,16)=0
}
EVENTSINK_QueryInterface(pEv,iid,ppv){
	global
	if(GuidIsEqual(iid,NumGet(pEv+8))||GuidIsEqual(iid,IID_IDispatch)||GuidIsEqual(iid,IID_IUnknown)){
		NumPut(pEv,ppv+0)
		DllCall(M(pEv,1),&quot;UInt&quot;,pEv)
		return 0
	}
	NumPut(0,ppv+0)
	return 0x80004002
}
EVENTSINK_AddRef(pEv){
	cRef:=NumGet(pEv+4)
	cRef++
	NumPut(cRef,pEv+4)
	return cRef
}
EVENTSINK_Release(pEv){
	cRef:=NumGet(pEv+4)
	cRef--
	NumPut(cRef,pEv+4)
	if(cRef==0){
		EVENTSINK_Destructor(pEv)
	}
	return cRef
}
EVENTSINK_GetTypeInfoCount(pEv,pct){
	NumPut(0,pct+0)
	return 0
}
EVENTSINK_GetTypeInfo(pEv,info,lcid,pInfo){
	return 0x8002000B	;DISP_E_BADINDEX
}
EVENTSINK_GetIDsOfNames(pEv,riid,szNames,cNames,lcid,pDispID){
	return 0x80020006	;DISP_E_UNKNOWNNAME
}
EVENTSINK_Invoke(pEv,dispid,riid,lcid,wFlags,params,pvRes,exinf,argerr){
	pTypeInfo:=NumGet(pEv+24)
	;GetNames
	hr:=DllCall(M(pTypeInfo,7),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,dispid, &quot;UIntP&quot;,bstr, &quot;UInt&quot;,1, &quot;UIntP&quot;,count)
	if(hr!=0){
		return 0
	}
	wc2mb_ref(bstr,ev)
	
	cb:=GetOleEventCallback(NumGet(pEv+12),ev)
	if(cb){
		DllCall(cb,&quot;UInt&quot;,NumGet(pEv+28), &quot;UInt&quot;,params, &quot;UInt&quot;,pvRes)
	}
}
EVENTSINK_Constructor(){
	static vtEventSink
	if(!vtEventSink){
		vtEventSink:=Malloc(28)
		NumPut(RegisterCallback(&quot;EVENTSINK_QueryInterface&quot;),	vtEventSink+0)
		NumPut(RegisterCallback(&quot;EVENTSINK_AddRef&quot;),			vtEventSink+4)
		NumPut(RegisterCallback(&quot;EVENTSINK_Release&quot;),			vtEventSink+8)
		NumPut(RegisterCallback(&quot;EVENTSINK_GetTypeInfoCount&quot;),	vtEventSink+12)
		NumPut(RegisterCallback(&quot;EVENTSINK_GetTypeInfo&quot;),		vtEventSink+16)
		NumPut(RegisterCallback(&quot;EVENTSINK_GetIDsOfNames&quot;),		vtEventSink+20)
		NumPut(RegisterCallback(&quot;EVENTSINK_Invoke&quot;),			vtEventSink+24)
	}
	pEv:=Malloc(32)
	NumPut(vtEventSink,pEv+0)
	return pEv
}
EVENTSINK_Destructor(pEv){
	Release(NumGet(pEv+28))
	Free(pEv)
}






/*
	**********************************
	コネクト用のインターフェイスIDを検索
	**********************************
*/
find_iid(ByRef obj,ByRef itf,ByRef iid,ByRef refPTypeInfo=0xFFFFFFFFFFFFFFFF){
	global LOCALE_USER_DEFAULT
	;GetTypeInfo
	hr:=DllCall(M(disp,4),&quot;UInt&quot;,obj, &quot;UInt&quot;,0, &quot;UInt&quot;,LOCALE_USER_DEFAULT, &quot;UIntP&quot;,pTypeInfo)
	if(hr!=0){
		return hr
	}
	;GetContainingTypeLib
	hr:=DllCall(M(pTypeInfo,18),&quot;UInt&quot;,pTypeInfo, &quot;UIntP&quot;,pTypeLib, &quot;UIntP&quot;,index)
	Release(pTypeInfo)
	if(hr!=0){
		return hr
	}
	if(!itf){
		;GetTypeInfoOfGuid
		hr:=DllCall(M(pTypeLib,5),&quot;UInt&quot;,pTypeLib, &quot;UIntP&quot;,iid, &quot;UIntP&quot;,refPTypeInfo)
		Release(pTypeLib)
		return hr
	}
	count:=DllCall(M(pTypeLib,3),&quot;UInt&quot;,pTypeLib)										;GetTypeInfoCount
	found:=0
	index:=0
	Loop,%count%{
		hr:=DllCall(M(pTypeLib,4),&quot;UInt&quot;,pTypeLib, &quot;UInt&quot;,index, &quot;UIntP&quot;,pTypeInfo)		;GetTypeInfo
		if(hr!=0){
			break
		}
		hr:=DllCall(M(pTypeInfo,3),&quot;UInt&quot;,pTypeInfo, &quot;UIntP&quot;,pTypeAttr)					;GetTypeAttr
		if(hr!=0){
			Release(pTypeInfo)
			break
		}
		if(NumGet(pTypeAttr+40)==5){													;typekind==TKIND_COCLASS
			cTypes:=NumGet(pTypeAttr+48,&quot;UShort&quot;)												;cImplTypes
			type:=0
			Loop,%cTypes%{
				hr:=DllCall(M(pTypeInfo,8),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,type, &quot;UIntP&quot;,RefType)	;GetRefTypeOfImplType
				if(hr!=0){
					break
				}
				hr:=DllCall(M(pTypeInfo,14),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,RefType, &quot;UIntP&quot;,pImplTypeInfo)	;GetRefTypeInfo
				if(hr!=0){
					break
				}
				;GetDocumentation
				hr:=DllCall(M(pImplTypeInfo,12),&quot;UInt&quot;,pImplTypeInfo, &quot;Int&quot;,-1, &quot;UIntP&quot;,bstr, &quot;UInt&quot;,0, &quot;UInt&quot;,0, &quot;UInt&quot;,0)
				if(hr!=0){
					Release(pImplTypeInfo)
					break
				}
				wc2mb_ref(bstr,str)
				if(str==itf){
					;GetTypeAttr
					if(DllCall(M(pImplTypeInfo,3),&quot;UInt&quot;,pImplTypeInfo, &quot;UIntP&quot;,pImplTypeAttr)=0){
						found:=1
						iid:=Malloc(16)
						DllCall(&quot;kernel32.dll¥RtlMoveMemory&quot;, &quot;UInt&quot;,iid, &quot;UInt&quot;,pImplTypeAttr, &quot;UInt&quot;,16)
						if(refPTypeInfo!=0xFFFFFFFFFFFFFFFF){
							refPTypeInfo:=pImplTypeInfo
							AddRef(pImplTypeInfo)
						}
						;ReleaseTypeAttr
						DllCall(M(pImplTypeInfo,3),&quot;UInt&quot;,pImplTypeInfo, &quot;UInt&quot;,pImplTypeAttr)
					}
				}
				Release(pImplTypeInfo)
				if(found||(hr!=0)){
					break
				}
				type++
			}
		}
		hr:=DllCall(M(pTypeInfo,3),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,pTypeAttr)	;ReleaseTypeAttr
		Release(pTypeInfo)
		if(found||(hr!=0)){
			break
		}
		index++
	}
	Release(pTypeLib)
	if(!found){
		return 0x80004002
	}else{
		return hr
	}
}
find_default_source(ByRef obj,ByRef iid,ByRef refPTypeInfo){
	global IID_IProvideClassInfo	;,IID_IProvideClassInfo2
/*
	pProvideClassInfo2:=QueryInterface(obj,IID_IProvideClassInfo2)
	if(ErrorLevel________==0){
		;GetGUID
		hr:=DllCall(M(pProvideClassInfo2,4),&quot;UInt&quot;,pProvideClassInfo2, &quot;UInt&quot;,1, &quot;UIntP&quot;,iid)
		Release(pProvideClassInfo2)
		return find_iid(obj,&quot;&quot;,iid,refPTypeInfo)
	}
*/
	pProvideClassInfo:=QueryInterface(obj,IID_IProvideClassInfo)
	if(ErrorLevel!=0){
		return ErrorLevel
	}
	;GetClassInfo
	hr:=DllCall(M(pProvideClassInfo,3),&quot;UInt&quot;,pProvideClassInfo, &quot;UIntP&quot;,pTypeInfo)
	Release(pProvideClassInfo)
	if(hr!=0){
		return hr
	}
	;GetTypeAttr
	hr:=DllCall(M(pTypeInfo,3),&quot;UInt&quot;,pTypeInfo, &quot;UIntP&quot;,pTypeAttr)
	if(hr!=0){
		Release(pTypeInfo)
		return hr
	}
	cTypes:=NumGet(pTypeAttr+48,&quot;UShort&quot;)						;cImplTypes
	type:=0
	Loop,%cTypes%{
		hr:=DllCall(M(pTypeInfo,9),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,type, &quot;UIntP&quot;,iFlags)	;GetImplTypeFlags
		if(hr!=0){
			continue
		}
		if((iFlags&amp;0x3)=0x3){				;((iFlags &amp; IMPLTYPEFLAG_FDEFAULT)&amp;&amp;(iFlags &amp; IMPLTYPEFLAG_FSOURCE))
			hr:=DllCall(M(pTypeInfo,8),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,type, &quot;UIntP&quot;,RefType)			;GetRefTypeOfImplType
			if(hr!=0){
				continue
			}
			hr:=DllCall(M(pTypeInfo,14),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,RefType, &quot;UIntP&quot;,refPTypeInfo)	;GetRefTypeInfo
			if(hr!=0){
				break
			}
		}
		type++
	}
	DllCall(M(pTypeInfo,3),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,pTypeAttr)	;ReleaseTypeAttr
	Release(pTypeInfo)
	if(!refPTypeInfo){
		if(hr==0){
			return 0x8000FFFF
		}else{
			return hr
		}
	}
	if(DllCall(M(refPTypeInfo,3),&quot;UInt&quot;,refPTypeInfo, &quot;UIntP&quot;,pTypeAttr)=0){			;GetTypeAttr
		iid:=Malloc(16)
		DllCall(&quot;kernel32.dll¥RtlMoveMemory&quot;, &quot;UInt&quot;,iid, &quot;UInt&quot;,pTypeAttr, &quot;UInt&quot;,16)
		DllCall(M(refPTypeInfo,3),&quot;UInt&quot;,refPTypeInfo, &quot;UInt&quot;,pTypeAttr)				;ReleaseTypeAttr
	}else{
		Release(refPTypeInfo)
		refPTypeInfo:=&quot;&quot;
	}
	return hr
}
EntryOleEventPrefix(ByRef prefix){
	global
	static OleEventCount=0
	if(OleEventID_%prefix%){
		return OleEventID_%prefix%
	}else{
		OleEventID_%prefix%:=OleEventCount
		OleEventPrefix_%OleEventCount%:=prefix
		return OleEventCount++
	}
}
GetOleEventCallback(id,ByRef evt){
	global
	local prefix,cb
	prefix:=OleEventPrefix_%id%
	if(prefix){
		if(OleEventCallback_%prefix%%evt%){
			return OleEventCallback_%prefix%%evt%
		}
		cb:=RegisterCallback(prefix . evt)
		if(cb){
			OleEventCallback_%prefix%%evt%:=cb
			return cb
		}
	}
}
ConnectObject(obj,prefix,itf=0xFFFFFFFFFFFFFFFF){
	global IID_IConnectionPointContainer
	
	if(itf==0xFFFFFFFFFFFFFFFF){
		hr:=find_default_source(obj,iid,pTypeInfo)
	}else{
		hr:=find_iid(obj,itf,iid,pTypeInfo)
	}
	if(hr!=0){
		ErrorLevel:=hr
		return 0
	}
	pContainer:=QueryInterface(obj,IID_IConnectionPointContainer)
	if(ErrorLevel!=0){
		Release(pTypeInfo)
		return 0
	}
	;FindConnectionPoint
	hr:=DllCall(M(pContainer,4),&quot;UInt&quot;,pContainer, &quot;UInt&quot;,iid, &quot;UIntP&quot;,pConnectionPoint)
	Release(pContainer)
	if(hr!=0){
		Release(pTypeInfo)
		return 0
	}
	pIEV:=EVENTSINK_Constructor()
	NumPut(iid,				pIEV+8)
	;Advise
	hr:=DllCall(M(pConnectionPoint,5),&quot;UInt&quot;,pConnectionPoint, &quot;UInt&quot;,pIEV, &quot;UIntP&quot;,dwCookie)
	if(hr!=0){
		return 0
	}
	AddRef(obj)
	evid:=EntryOleEventPrefix(prefix)
	NumPut(evid,			pIEV+12)
	NumPut(dwCookie,		pIEV+16)
	NumPut(pConnectionPoint,pIEV+20)
	NumPut(pTypeInfo,		pIEV+24)
	NumPut(obj,				pIEV+28)
}
evArgc(ByRef para){
	return NumGet(para+8)
}
evArgv(ByRef para,idx){
	num:=NumGet(para+8)
	if(idx&lt;num){
		return fromVariant(NumGet(para+0)+(num-1-idx)*16)
	}
}
evReturn(ByRef res,value){
	toVariant(value,res)
}









/*
	**********************************
	ディスパッチオブジェクト作成
	**********************************
*/


DISPATCH_QueryInterface(ptr,iid,ppv){
	global
	if(GuidIsEqual(iid,IID_IDispatch)||GuidIsEqual(iid,IID_IUnknown)){
		NumPut(ptr,ppv+0)
		DllCall(M(ptr,1),&quot;UInt&quot;,ptr)
		return 0
	}else{
		NumPut(0,ppv+0)
		return 0x80004002
	}
}
DISPATCH_AddRef(ptr){
	cRef:=NumGet(ptr+4)
	cRef++
	NumPut(cRef,ptr+4)
	return cRef
}
DISPATCH_Release(ptr){
	cRef:=NumGet(ptr+4)
	cRef--
	NumPut(cRef,ptr+4)
	if(cRef==0){
		Free(ptr)
	}
	return cRef
}
DISPATCH_GetTypeInfoCount(ptr,pct){
	NumPut(0,pct+0)
	return 0
}
DISPATCH_GetTypeInfo(ptr,info,lcid,pInfo){
	return 0x8002000B	;DISP_E_BADINDEX
}
DISPATCH_GetIDsOfNames(ptr,riid,pszNames,cNames,lcid,pDispID){
	wc2mb_ref(NumGet(pszNames+0),name)
	hr:=GetOleMethodCallback(NumGet(ptr+12),name,cb)
	NumPut(cb,pDispID+0)
	return hr
}
DISPATCH_Invoke(ptr,dispid,riid,lcid,wFlags,params,pvRes,exinf,argerr){
	DllCall(dispid,&quot;UInt&quot;,ptr, &quot;UInt&quot;,params, &quot;UInt&quot;,pvRes, &quot;UInt&quot;,wFlags)
	return 0
}



EntryOleMethodsPrefix(ByRef prefix,ByRef id){
	global
	static OleMethodsCount=0
	if(OleMethodsID_%prefix%){
		id:=OleMethodsID_%prefix%
	}else{
		OleMethodsID_%prefix%:=OleMethodsCount
		OleMethodsPrefix_%OleMethodsCount%:=prefix
		id:=OleMethodsCount++
	}
}
GetOleMethodCallback(id,ByRef name,ByRef cb){
	global
	local prefix
	cb:=0
	prefix:=OleMethodsPrefix_%id%
	if(prefix){
		if(OleMethodCallback_%prefix%%name%){
			cb:=OleMethodCallback_%prefix%%name%
			return 0
		}else{
			cb:=RegisterCallback(prefix . name)
			if(cb){
				OleMethodCallback_%prefix%%name%:=cb
				return 0
			}else{
				return 0x80020006
			}
		}
	}
}

CreateDispatchObject(prefix,exsize=0){
	global IID_IDispatch
	static vtDispatch
	if(!vtDispatch){
		vtDispatch:=Malloc(28)
		NumPut(RegisterCallback(&quot;DISPATCH_QueryInterface&quot;),		vtDispatch+0)
		NumPut(RegisterCallback(&quot;DISPATCH_AddRef&quot;),				vtDispatch+4)
		NumPut(RegisterCallback(&quot;DISPATCH_Release&quot;),			vtDispatch+8)
		NumPut(RegisterCallback(&quot;DISPATCH_GetTypeInfoCount&quot;),	vtDispatch+12)
		NumPut(RegisterCallback(&quot;DISPATCH_GetTypeInfo&quot;),		vtDispatch+16)
		NumPut(RegisterCallback(&quot;DISPATCH_GetIDsOfNames&quot;),		vtDispatch+20)
		NumPut(RegisterCallback(&quot;DISPATCH_Invoke&quot;),				vtDispatch+24)
	}
	EntryOleMethodsPrefix(prefix,id)
	ptr:=Malloc(12+exsize)
	NumPut(vtDispatch		,ptr+0)
	NumPut(IID_IDispatch	,ptr+8)
	NumPut(id				,ptr+12)
	return ptr
}    </description>
    <dc:date>2010-11-11T01:07:00+09:00</dc:date>
    <utime>1289405220</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/13.html">
    <title>AutoHotKey</title>
    <link>https://w.atwiki.jp/lockerroom/pages/13.html</link>
    <description>
      [[ActiveX.ahk]]
--------------
/*
COM操作ライブラリ	by 流行らせるページ管理人
 Ver 3β
*/

ActiveX(){
	global
	IID_IDispatch:=GUID(&quot;{00020400-0000-0000-C000-000000000046}&quot;)
	IID_IUnknown:=GUID(&quot;{00000000-0000-0000-C000-000000000046}&quot;)
	IID_NULL:=GUID(&quot;{00000000-0000-0000-0000-000000000000}&quot;)
	IID_IConnectionPointContainer:=GUID(&quot;{B196B284-BAB4-101A-B69C-00AA00341D07}&quot;)
	IID_IProvideClassInfo:=GUID(&quot;{B196B283-BAB4-101A-B69C-00AA00341D07}&quot;)
	;IID_IProvideClassInfo2:=GUID(&quot;{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}&quot;)
	LOCALE_USER_DEFAULT:=DllCall(&quot;kernel32.dll¥GetUserDefaultLCID&quot;)
	CoInitialize()
}



/*
	**********************************
	汎用メモリ管理
	**********************************
*/

;メモリを確保しポインタを返す
Malloc(size,flag=0x40){
	return DllCall(&quot;kernel32.dll¥GlobalAlloc&quot;,&quot;UInt&quot;,flag,&quot;UInt&quot;,size,&quot;UInt&quot;)
}
;ポインタで指定されたメモリを解放する
Free(p){
	DllCall(&quot;kernel32.dll¥GlobalFree&quot;,UInt,p,UInt)
}


/*
	**********************************
	GUID関連
	**********************************
*/

;CLSID文字列からGUID構造体を生成しアドレスを得る(仮)
GUID(string){
	size:=DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,string,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0)
	wstr:=Malloc((size+1)*2)
	DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,string,&quot;Int&quot;,-1,&quot;UInt&quot;,wstr,&quot;Int&quot;,(size+1)*2)
	ptr:=Malloc(16)
	DllCall(&quot;ole32.dll¥CLSIDFromString&quot;,&quot;UInt&quot;,wstr,&quot;UInt&quot;,ptr)
	Free(wstr)
	return ptr 
}
;ProgID文字列からGUID構造体を生成しアドレスを得る(仮)
ProgID(string){
	size:=DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,string,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0)
	wstr:=Malloc((size+1)*2)
	DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,string,&quot;Int&quot;,-1,&quot;UInt&quot;,wstr,&quot;Int&quot;,(size+1)*2)
	ptr:=Malloc(16)
	DllCall(&quot;ole32.dll¥CLSIDFromProgID&quot;,&quot;UInt&quot;,wstr,&quot;UInt&quot;,ptr)
	Free(wstr)
	return ptr 
}

;GUID構造体を文字列に変換
fromGUID(ByRef guid){
	ptr:=Malloc(80)
	DllCall(&quot;ole32.dll¥StringFromGUID2&quot;,&quot;UInt&quot;,guid,&quot;UInt&quot;,ptr,&quot;Int&quot;,80)
	res:=wc2mb(ptr)
	Free(ptr)
	return res
}

/*
	**********************************
	Unicode関連
	**********************************
*/

;文字列からにUnicodeへの変換を行う
;返り値はUnicode文字列へのポインタ
mb2wc(mbstr){
	size:=(DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,mbstr,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0)+1)*2
	wstr:=Malloc(size)
	DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,mbstr,&quot;Int&quot;,-1,&quot;UInt&quot;,wstr,&quot;Int&quot;,size)
	return wstr
}
mb2wc_ref(ByRef mbstr){
	size:=(DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,mbstr,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0)+1)*2
	wstr:=Malloc(size)
	DllCall(&quot;kernel32.dll¥MultiByteToWideChar&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;Str&quot;,mbstr,&quot;Int&quot;,-1,&quot;UInt&quot;,wstr,&quot;Int&quot;,size)
	return wstr
}
;UnicodeからAnsi文字列への変換を行う
;返り値は文字列
wc2mb(wstr){
	size:=DllCall(&quot;kernel32.dll¥WideCharToMultiByte&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,wstr,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,0)
	VarSetCapacity(mbstr,size)
	DllCall(&quot;kernel32.dll¥WideCharToMultiByte&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,wstr,&quot;Int&quot;,-1,&quot;Str&quot;,mbstr,&quot;Int&quot;,size,&quot;UInt&quot;,0,&quot;UInt&quot;,0)
	return mbstr
}

wc2mb_ref(wstr,ByRef mbstr){
	size:=DllCall(&quot;kernel32.dll¥WideCharToMultiByte&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,wstr,&quot;Int&quot;,-1,&quot;UInt&quot;,0,&quot;Int&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,0)
	VarSetCapacity(mbstr,size)
	DllCall(&quot;kernel32.dll¥WideCharToMultiByte&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;,0,&quot;UInt&quot;,wstr,&quot;Int&quot;,-1,&quot;Str&quot;,mbstr,&quot;Int&quot;,size,&quot;UInt&quot;,0,&quot;UInt&quot;,0)
	return size
}


/*
	**********************************
	COM汎用
	**********************************
*/

CoInitialize(){
	return DllCall(&quot;ole32.dll¥CoInitialize&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;)
}
CoUninitialize(){
	return DllCall(&quot;ole32.dll¥CoUninitialize&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;)
}
OleInitialize(){
	return DllCall(&quot;ole32.dll¥OleInitialize&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;)
}
OleUninitialize(){
	return DllCall(&quot;ole32.dll¥OleUninitialize&quot;,&quot;UInt&quot;,0,&quot;UInt&quot;)
}
CoTaskMemAlloc(size){
 	return DllCall(&quot;ole32.dll¥CoTaskMemAlloc&quot;,&quot;UInt&quot;,size,&quot;UInt&quot;)
}
CoTaskMemFree(ptr){
 	return DllCall(&quot;ole32.dll¥CoTaskMemFree&quot;,&quot;UInt&quot;,ptr,&quot;UInt&quot;)
}
M(ByRef ip,idx=0){
	return NumGet(NumGet(ip+0)+4*idx)
}
QueryInterface(pObj,strIID=&quot;&quot;){
	global IID_IDispatch
	guid:=0
	if(strIID=&quot;&quot;){
		IID:=IID_IDispatch
	}else if(StrLen(strIID)=38){
		IID:=GUID(strIID)
	}else{
		IID:=strIID
	}
	res:=0
	ErrorLevel:=DllCall(M(pObj,0),&quot;UInt&quot;,pObj,&quot;UInt&quot;,IID,&quot;UIntP&quot;,res)
	return res
}
AddRef(pObj){
	if(pObj){
		DllCall(M(pObj,1),&quot;UInt&quot;,pObj)
	}
	return pObj
}
Release(pObj){
	if(pObj){
		return DllCall(M(pObj,2),&quot;UInt&quot;,pObj)
	}
}
ReleaseL(p1,p2=-1,p3=-1,p4=-1,p5=-1,p6=-1,p7=-1,p8=-1,p9=-1){
	format:=A_FormatInteger
	SetFormat,Integer,D
	Loop,10{
		if(p%A_Index%!=-1){
			Release(p%A_Index%)
		}
	}
	SetFormat,Integer,%format%
}

/*
	**********************************
	VARIANT関連
	**********************************
*/

;Ansi文字列をBSTR形式に変換する
toBSTR(str){
	oc:=mb2wc(str)
	res:=DllCall(&quot;oleaut32.dll¥SysAllocString&quot;,&quot;UInt&quot;,oc,&quot;UInt&quot;)
	Free(oc)
	return res
}
;BSTRをAnsi文字列に変換する
fromBSTR(bstr){
	return wc2mb(bstr)
}

;BSTRを解放する(VariantClear内でやってくれるはずなので多分不要)
freeBSTR(bstr,get=0){
	if(get!=0){
		wc2mb_ref(bstr,res)
	}else{
		res=
	}
	DllCall(&quot;oleaut32.dll¥SysFreeString&quot;,&quot;UInt&quot;,bstr)
	return res
}

vNull(){
	return 0x7FFFFFFF00000000
}
vObj(obj){
	return 0x7FFFFFFF00000000 | obj
}
;VARIANTに変換(typeには変換したい型を指定
;settypeを指定すると、型変換した上で、型を示す値としてsettypeで指定した型を格納する
toVariant(value,variant=0,type=0x08,settype=-1){
	global LOCALE_USER_DEFAULT
	;格納先初期化
	if(variant=0){
		dest:=Malloc(16)
	}else{
		dest:=variant
	}
	DllCall(&quot;oleaut32.dll¥VariantInit&quot;,&quot;UInt&quot;,dest)
	if(type=0x08){
		if(value &gt;&gt; 32 = 0x7FFFFFFF){
			if(value-0x7FFFFFFF00000000=0){
				;VT_NULL
				NumPut(0x01,dest+0,0,&quot;UShort&quot;)
			}else{
				;VT_DISPATCH
				NumPut(0x09,dest+0,0,&quot;UShort&quot;)
				NumPut(value - 0x7FFFFFFF00000000,dest+8,0)
			}
		}else{
			;文字列の場合
			NumPut(0x08,dest+0,0,&quot;UShort&quot;)
			NumPut(toBSTR(value),dest+8,0)
		}
	}else{
		;それ以外の型の場合
		tmp:=toVariant(value)
		DllCall(&quot;oleaut32.dll¥VariantChangeTypeEx&quot;,&quot;UInt&quot;,dest,&quot;UInt&quot;,tmp,&quot;UInt&quot;,LOCALE_USER_DEFAULT,&quot;UShort&quot;,0,&quot;UShort&quot;,type)
		if(settype!=-1){
			NumPut(settype,dest+0,0,&quot;UShort&quot;)
		}
		vFree(tmp)
	}
	return dest
}

;VARIANTに格納された内容を通常のAutoHotkey変数として取得
;rawsizeが1,2,4の場合、格納されている生の値を取得
;rawsizeが0の場合、文字列に変換して取得
fromVariant(var,rawsize=0){
	global LOCALE_USER_DEFAULT
	if(rawsize=0){
		type:=NumGet(var+0,0,&quot;UShort&quot;)
		if((type=9)||(type=13)){
			;COMオブジェクト
			pObj:=NumGet(var+8)
			AddRef(pObj)
			return pObj
		}else if(type&gt;0xFF){
			;ポインタもしくは配列		(暫定)
			return NumGet(var+8)
		}else{
			;VT_BSTRに変換
			var2:=Malloc(16)
			DllCall(&quot;oleaut32.dll¥VariantInit&quot;,&quot;UInt&quot;,var2)
			DllCall(&quot;oleaut32.dll¥VariantChangeTypeEx&quot;,&quot;UInt&quot;,var2,&quot;UInt&quot;,var,&quot;UInt&quot;,LOCALE_USER_DEFAULT,&quot;UShort&quot;,0,&quot;UShort&quot;,0x8)
			;値をAnsiに変換
			wc2mb_ref(NumGet(var2+8),res)
			vFree(var2)
			return res
		}
	}else if(rawsize=1){
		return NumGet(var+8,0,&quot;UChar&quot;)
	}else if(rawsize=2){
		return NumGet(var+8,0,&quot;UShort&quot;)
	}else if(rawsize=4){
		return NumGet(var+8)
	}else{
		return fromVariant(var,0)
	}
}

;VARIANTを解放(getに-1以外を指定すると、値を取得して返す)
vFree(ByRef var,get=-1){
	if(get!=-1){
		res:=fromVariant(var,get)
	}else{
		res:=0
	}
	DllCall(&quot;oleaut32.dll¥VariantClear&quot;,&quot;UInt&quot;,var)
	Free(var)
	return res
}


/*
	**********************************
	IDispatch用
	**********************************
*/
;オブジェクトを生成する
CreateObject(clsid,iid=&quot;&quot;,CLSCTX=5){	;CLSCTX_SERVER
	global IID_IDispatch
	if(!IID_IDispatch){
		ActiveX()
	}
	guid:=0
	if(RegExMatch(clsid,&quot;^¥{[¥-0-9a-fA-F]{36}¥}$&quot;)){
		guid:=GUID(clsid)
	}else{
		guid:=ProgID(clsid)
	}
	if(iid=&quot;&quot;){
		iid2:=IID_IDispatch
	}else{
		iid2:=GUID(iid)
	}
	ppRes:=0
	el:=DllCall(&quot;ole32.dll¥CoCreateInstance&quot;,&quot;UInt&quot;,guid,&quot;UInt&quot;,0,&quot;UInt&quot;,CLSCTX,&quot;UInt&quot;,iid2,&quot;UIntP&quot;,ppRes,&quot;UInt&quot;)
	Free(guid)
	if(iid2!=IID_IDispatch){
		Free(iid2)
	}
	ErrorLevel:=el
	return ppRes
}


;objが持つnameメンバのDispatchIDを得る
GetDispID(ByRef obj,name){
	global IID_NULL,LOCALE_USER_DEFAULT
	wName:=mb2wc_ref(name)
	dispid:=0
	DllCall(M(obj,5),&quot;UInt&quot;,obj,&quot;UInt&quot;,IID_NULL,&quot;UIntP&quot;,wName,&quot;UInt&quot;,1,&quot;UInt&quot;,LOCALE_USER_DEFAULT,&quot;UIntP&quot;,dispid,&quot;UInt&quot;)
	Free(wName)
	return dispid
}
;引数からDISPPARAMSを生成
CreateParam(ByRef p1, ByRef p2, ByRef p3, ByRef p4, ByRef p5, ByRef p6, ByRef p7, ByRef p8, ByRef p9, ByRef p10){
	;引数を数える(0xFFFFFFFFFFFFFFFFの前までが与えられた引数)
	num:=0
	format:=A_FormatInteger
	SetFormat,Integer,D
	Loop,10{
		if(p%A_Index%=0xFFFFFFFFFFFFFFFF){
			break
		}
		num++
	}
	;num個のVARIANTARG配列を作成
	if(num=0){
		pvArgs:=0
	}else{
		pvArgs:=Malloc(16*num)
		ptr:=pvArgs+16*(num-1)
		;引数をセットしていく
		Loop,%num%{
			toVariant(p%A_Index%,ptr)
			ptr-=16
		}
	}
	SetFormat,Integer,%format%
	
	;DISPPARAMS作成
	res:=Malloc(16)
	NumPut(pvArgs,	res+0)
	NumPut(num,		res+8)
	return res
}
;DISPPARAMSを解放
FreeParam(ByRef params){
	num:=NumGet(params+8)
	pvArgs:=NumGet(params+0)
	pvNArgs:=NumGet(params+4)
	;VARIANTARGの解放処理
	ptr:=pvArgs
	Loop,%num%{
		vFree(ptr)
		ptr+=16
	}
	;VARIANTARG自体の解放
	Free(ptr)
	;rgdispidNamedArgsの解放
	if(pvNArgs!=0){
		Free(pvNArgs)
	}
	;本体メモリ解放
	Free(params)
}
Invoke(ByRef pObj,ByRef dispid,mode,ByRef params){
	global IID_NULL,LOCALE_USER_DEFAULT
	pvRes:=Malloc(16)
	DllCall(&quot;oleaut32.dll¥VariantInit&quot;,UInt,pvRes)
	DllCall(M(pObj,6),UInt,pObj,UInt,dispid,UInt,IID_NULL,UInt,LOCALE_USER_DEFAULT,UInt,mode,UInt,params,UInt,pvRes,UInt,0,UInt,0,UInt)
	return pvRes
}

inv(obj,name,p1=0xFFFFFFFFFFFFFFFF,p2=0xFFFFFFFFFFFFFFFF,p3=0xFFFFFFFFFFFFFFFF,p4=0xFFFFFFFFFFFFFFFF,p5=0xFFFFFFFFFFFFFFFF,p6=0xFFFFFFFFFFFFFFFF,p7=0xFFFFFFFFFFFFFFFF,p8=0xFFFFFFFFFFFFFFFF,p9=0xFFFFFFFFFFFFFFFF,p10=0xFFFFFFFFFFFFFFFF){
	if((dispid:=GetDispID(obj,name))!=0){
		params:=CreateParam(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
		pvRes:=Invoke(obj,dispid,1,params)
		FreeParam(params)
		return vFree(pvRes,0)
	}
}

gp(obj,name,p1=0xFFFFFFFFFFFFFFFF,p2=0xFFFFFFFFFFFFFFFF,p3=0xFFFFFFFFFFFFFFFF,p4=0xFFFFFFFFFFFFFFFF,p5=0xFFFFFFFFFFFFFFFF,p6=0xFFFFFFFFFFFFFFFF,p7=0xFFFFFFFFFFFFFFFF,p8=0xFFFFFFFFFFFFFFFF,p9=0xFFFFFFFFFFFFFFFF,p10=0xFFFFFFFFFFFFFFFF){
	if((dispid:=GetDispID(obj,name))!=0){
		params:=CreateParam(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
		pvRes:=Invoke(obj,dispid,2,params)
		FreeParam(params)
		return vFree(pvRes,0)
	}
}

pp(obj,name,p1=0xFFFFFFFFFFFFFFFF,p2=0xFFFFFFFFFFFFFFFF,p3=0xFFFFFFFFFFFFFFFF,p4=0xFFFFFFFFFFFFFFFF,p5=0xFFFFFFFFFFFFFFFF,p6=0xFFFFFFFFFFFFFFFF,p7=0xFFFFFFFFFFFFFFFF,p8=0xFFFFFFFFFFFFFFFF,p9=0xFFFFFFFFFFFFFFFF,p10=0xFFFFFFFFFFFFFFFF){
	if((dispid:=GetDispID(obj,name))!=0){
		params:=CreateParam(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
		;rgdispidNamedArgsのセット
		namedArgs:=Malloc(4)
		NumPut(namedArgs,	params+4)
		NumPut(0xFFFFFFFD,	namedArgs+0)
		NumPut(1,			params+12)
		pvRes:=Invoke(obj,dispid,4,params)
		FreeParam(params)
		return vFree(pvRes)
	}
}

/*
	**********************************
	イベントシンク用コールバック関数
	**********************************
*/
GuidIsEqual(guid1,guid2){
	return DllCall(&quot;MSVCRT.dll¥memcmp&quot;,&quot;UInt&quot;,guid1,&quot;UInt&quot;,guid2,&quot;UInt&quot;,16)=0
}
EVENTSINK_QueryInterface(pEv,iid,ppv){
	global
	if(GuidIsEqual(iid,NumGet(pEv+8))||GuidIsEqual(iid,IID_IDispatch)||GuidIsEqual(iid,IID_IUnknown)){
		NumPut(pEv,ppv+0)
		DllCall(M(pEv,1),&quot;UInt&quot;,pEv)
		return 0
	}
	NumPut(0,ppv+0)
	return 0x80004002
}
EVENTSINK_AddRef(pEv){
	cRef:=NumGet(pEv+4)
	cRef++
	NumPut(cRef,pEv+4)
	return cRef
}
EVENTSINK_Release(pEv){
	cRef:=NumGet(pEv+4)
	cRef--
	NumPut(cRef,pEv+4)
	if(cRef==0){
		EVENTSINK_Destructor(pEv)
	}
	return cRef
}
EVENTSINK_GetTypeInfoCount(pEv,pct){
	NumPut(0,pct+0)
	return 0
}
EVENTSINK_GetTypeInfo(pEv,info,lcid,pInfo){
	return 0x8002000B	;DISP_E_BADINDEX
}
EVENTSINK_GetIDsOfNames(pEv,riid,szNames,cNames,lcid,pDispID){
	return 0x80020006	;DISP_E_UNKNOWNNAME
}
EVENTSINK_Invoke(pEv,dispid,riid,lcid,wFlags,params,pvRes,exinf,argerr){
	pTypeInfo:=NumGet(pEv+24)
	;GetNames
	hr:=DllCall(M(pTypeInfo,7),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,dispid, &quot;UIntP&quot;,bstr, &quot;UInt&quot;,1, &quot;UIntP&quot;,count)
	if(hr!=0){
		return 0
	}
	wc2mb_ref(bstr,ev)
	
	cb:=GetOleEventCallback(NumGet(pEv+12),ev)
	if(cb){
		DllCall(cb,&quot;UInt&quot;,NumGet(pEv+28), &quot;UInt&quot;,params, &quot;UInt&quot;,pvRes)
	}
}
EVENTSINK_Constructor(){
	static vtEventSink
	if(!vtEventSink){
		vtEventSink:=Malloc(28)
		NumPut(RegisterCallback(&quot;EVENTSINK_QueryInterface&quot;),	vtEventSink+0)
		NumPut(RegisterCallback(&quot;EVENTSINK_AddRef&quot;),			vtEventSink+4)
		NumPut(RegisterCallback(&quot;EVENTSINK_Release&quot;),			vtEventSink+8)
		NumPut(RegisterCallback(&quot;EVENTSINK_GetTypeInfoCount&quot;),	vtEventSink+12)
		NumPut(RegisterCallback(&quot;EVENTSINK_GetTypeInfo&quot;),		vtEventSink+16)
		NumPut(RegisterCallback(&quot;EVENTSINK_GetIDsOfNames&quot;),		vtEventSink+20)
		NumPut(RegisterCallback(&quot;EVENTSINK_Invoke&quot;),			vtEventSink+24)
	}
	pEv:=Malloc(32)
	NumPut(vtEventSink,pEv+0)
	return pEv
}
EVENTSINK_Destructor(pEv){
	Release(NumGet(pEv+28))
	Free(pEv)
}






/*
	**********************************
	コネクト用のインターフェイスIDを検索
	**********************************
*/
find_iid(ByRef obj,ByRef itf,ByRef iid,ByRef refPTypeInfo=0xFFFFFFFFFFFFFFFF){
	global LOCALE_USER_DEFAULT
	;GetTypeInfo
	hr:=DllCall(M(disp,4),&quot;UInt&quot;,obj, &quot;UInt&quot;,0, &quot;UInt&quot;,LOCALE_USER_DEFAULT, &quot;UIntP&quot;,pTypeInfo)
	if(hr!=0){
		return hr
	}
	;GetContainingTypeLib
	hr:=DllCall(M(pTypeInfo,18),&quot;UInt&quot;,pTypeInfo, &quot;UIntP&quot;,pTypeLib, &quot;UIntP&quot;,index)
	Release(pTypeInfo)
	if(hr!=0){
		return hr
	}
	if(!itf){
		;GetTypeInfoOfGuid
		hr:=DllCall(M(pTypeLib,5),&quot;UInt&quot;,pTypeLib, &quot;UIntP&quot;,iid, &quot;UIntP&quot;,refPTypeInfo)
		Release(pTypeLib)
		return hr
	}
	count:=DllCall(M(pTypeLib,3),&quot;UInt&quot;,pTypeLib)										;GetTypeInfoCount
	found:=0
	index:=0
	Loop,%count%{
		hr:=DllCall(M(pTypeLib,4),&quot;UInt&quot;,pTypeLib, &quot;UInt&quot;,index, &quot;UIntP&quot;,pTypeInfo)		;GetTypeInfo
		if(hr!=0){
			break
		}
		hr:=DllCall(M(pTypeInfo,3),&quot;UInt&quot;,pTypeInfo, &quot;UIntP&quot;,pTypeAttr)					;GetTypeAttr
		if(hr!=0){
			Release(pTypeInfo)
			break
		}
		if(NumGet(pTypeAttr+40)==5){													;typekind==TKIND_COCLASS
			cTypes:=NumGet(pTypeAttr+48,&quot;UShort&quot;)												;cImplTypes
			type:=0
			Loop,%cTypes%{
				hr:=DllCall(M(pTypeInfo,8),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,type, &quot;UIntP&quot;,RefType)	;GetRefTypeOfImplType
				if(hr!=0){
					break
				}
				hr:=DllCall(M(pTypeInfo,14),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,RefType, &quot;UIntP&quot;,pImplTypeInfo)	;GetRefTypeInfo
				if(hr!=0){
					break
				}
				;GetDocumentation
				hr:=DllCall(M(pImplTypeInfo,12),&quot;UInt&quot;,pImplTypeInfo, &quot;Int&quot;,-1, &quot;UIntP&quot;,bstr, &quot;UInt&quot;,0, &quot;UInt&quot;,0, &quot;UInt&quot;,0)
				if(hr!=0){
					Release(pImplTypeInfo)
					break
				}
				wc2mb_ref(bstr,str)
				if(str==itf){
					;GetTypeAttr
					if(DllCall(M(pImplTypeInfo,3),&quot;UInt&quot;,pImplTypeInfo, &quot;UIntP&quot;,pImplTypeAttr)=0){
						found:=1
						iid:=Malloc(16)
						DllCall(&quot;kernel32.dll¥RtlMoveMemory&quot;, &quot;UInt&quot;,iid, &quot;UInt&quot;,pImplTypeAttr, &quot;UInt&quot;,16)
						if(refPTypeInfo!=0xFFFFFFFFFFFFFFFF){
							refPTypeInfo:=pImplTypeInfo
							AddRef(pImplTypeInfo)
						}
						;ReleaseTypeAttr
						DllCall(M(pImplTypeInfo,3),&quot;UInt&quot;,pImplTypeInfo, &quot;UInt&quot;,pImplTypeAttr)
					}
				}
				Release(pImplTypeInfo)
				if(found||(hr!=0)){
					break
				}
				type++
			}
		}
		hr:=DllCall(M(pTypeInfo,3),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,pTypeAttr)	;ReleaseTypeAttr
		Release(pTypeInfo)
		if(found||(hr!=0)){
			break
		}
		index++
	}
	Release(pTypeLib)
	if(!found){
		return 0x80004002
	}else{
		return hr
	}
}
find_default_source(ByRef obj,ByRef iid,ByRef refPTypeInfo){
	global IID_IProvideClassInfo	;,IID_IProvideClassInfo2
/*
	pProvideClassInfo2:=QueryInterface(obj,IID_IProvideClassInfo2)
	if(ErrorLevel________==0){
		;GetGUID
		hr:=DllCall(M(pProvideClassInfo2,4),&quot;UInt&quot;,pProvideClassInfo2, &quot;UInt&quot;,1, &quot;UIntP&quot;,iid)
		Release(pProvideClassInfo2)
		return find_iid(obj,&quot;&quot;,iid,refPTypeInfo)
	}
*/
	pProvideClassInfo:=QueryInterface(obj,IID_IProvideClassInfo)
	if(ErrorLevel!=0){
		return ErrorLevel
	}
	;GetClassInfo
	hr:=DllCall(M(pProvideClassInfo,3),&quot;UInt&quot;,pProvideClassInfo, &quot;UIntP&quot;,pTypeInfo)
	Release(pProvideClassInfo)
	if(hr!=0){
		return hr
	}
	;GetTypeAttr
	hr:=DllCall(M(pTypeInfo,3),&quot;UInt&quot;,pTypeInfo, &quot;UIntP&quot;,pTypeAttr)
	if(hr!=0){
		Release(pTypeInfo)
		return hr
	}
	cTypes:=NumGet(pTypeAttr+48,&quot;UShort&quot;)						;cImplTypes
	type:=0
	Loop,%cTypes%{
		hr:=DllCall(M(pTypeInfo,9),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,type, &quot;UIntP&quot;,iFlags)	;GetImplTypeFlags
		if(hr!=0){
			continue
		}
		if((iFlags&amp;0x3)=0x3){				;((iFlags &amp; IMPLTYPEFLAG_FDEFAULT)&amp;&amp;(iFlags &amp; IMPLTYPEFLAG_FSOURCE))
			hr:=DllCall(M(pTypeInfo,8),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,type, &quot;UIntP&quot;,RefType)			;GetRefTypeOfImplType
			if(hr!=0){
				continue
			}
			hr:=DllCall(M(pTypeInfo,14),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,RefType, &quot;UIntP&quot;,refPTypeInfo)	;GetRefTypeInfo
			if(hr!=0){
				break
			}
		}
		type++
	}
	DllCall(M(pTypeInfo,3),&quot;UInt&quot;,pTypeInfo, &quot;UInt&quot;,pTypeAttr)	;ReleaseTypeAttr
	Release(pTypeInfo)
	if(!refPTypeInfo){
		if(hr==0){
			return 0x8000FFFF
		}else{
			return hr
		}
	}
	if(DllCall(M(refPTypeInfo,3),&quot;UInt&quot;,refPTypeInfo, &quot;UIntP&quot;,pTypeAttr)=0){			;GetTypeAttr
		iid:=Malloc(16)
		DllCall(&quot;kernel32.dll¥RtlMoveMemory&quot;, &quot;UInt&quot;,iid, &quot;UInt&quot;,pTypeAttr, &quot;UInt&quot;,16)
		DllCall(M(refPTypeInfo,3),&quot;UInt&quot;,refPTypeInfo, &quot;UInt&quot;,pTypeAttr)				;ReleaseTypeAttr
	}else{
		Release(refPTypeInfo)
		refPTypeInfo:=&quot;&quot;
	}
	return hr
}
EntryOleEventPrefix(ByRef prefix){
	global
	static OleEventCount=0
	if(OleEventID_%prefix%){
		return OleEventID_%prefix%
	}else{
		OleEventID_%prefix%:=OleEventCount
		OleEventPrefix_%OleEventCount%:=prefix
		return OleEventCount++
	}
}
GetOleEventCallback(id,ByRef evt){
	global
	local prefix,cb
	prefix:=OleEventPrefix_%id%
	if(prefix){
		if(OleEventCallback_%prefix%%evt%){
			return OleEventCallback_%prefix%%evt%
		}
		cb:=RegisterCallback(prefix . evt)
		if(cb){
			OleEventCallback_%prefix%%evt%:=cb
			return cb
		}
	}
}
ConnectObject(obj,prefix,itf=0xFFFFFFFFFFFFFFFF){
	global IID_IConnectionPointContainer
	
	if(itf==0xFFFFFFFFFFFFFFFF){
		hr:=find_default_source(obj,iid,pTypeInfo)
	}else{
		hr:=find_iid(obj,itf,iid,pTypeInfo)
	}
	if(hr!=0){
		ErrorLevel:=hr
		return 0
	}
	pContainer:=QueryInterface(obj,IID_IConnectionPointContainer)
	if(ErrorLevel!=0){
		Release(pTypeInfo)
		return 0
	}
	;FindConnectionPoint
	hr:=DllCall(M(pContainer,4),&quot;UInt&quot;,pContainer, &quot;UInt&quot;,iid, &quot;UIntP&quot;,pConnectionPoint)
	Release(pContainer)
	if(hr!=0){
		Release(pTypeInfo)
		return 0
	}
	pIEV:=EVENTSINK_Constructor()
	NumPut(iid,				pIEV+8)
	;Advise
	hr:=DllCall(M(pConnectionPoint,5),&quot;UInt&quot;,pConnectionPoint, &quot;UInt&quot;,pIEV, &quot;UIntP&quot;,dwCookie)
	if(hr!=0){
		return 0
	}
	AddRef(obj)
	evid:=EntryOleEventPrefix(prefix)
	NumPut(evid,			pIEV+12)
	NumPut(dwCookie,		pIEV+16)
	NumPut(pConnectionPoint,pIEV+20)
	NumPut(pTypeInfo,		pIEV+24)
	NumPut(obj,				pIEV+28)
}
evArgc(ByRef para){
	return NumGet(para+8)
}
evArgv(ByRef para,idx){
	num:=NumGet(para+8)
	if(idx&lt;num){
		return fromVariant(NumGet(para+0)+(num-1-idx)*16)
	}
}
evReturn(ByRef res,value){
	toVariant(value,res)
}









/*
	**********************************
	ディスパッチオブジェクト作成
	**********************************
*/


DISPATCH_QueryInterface(ptr,iid,ppv){
	global
	if(GuidIsEqual(iid,IID_IDispatch)||GuidIsEqual(iid,IID_IUnknown)){
		NumPut(ptr,ppv+0)
		DllCall(M(ptr,1),&quot;UInt&quot;,ptr)
		return 0
	}else{
		NumPut(0,ppv+0)
		return 0x80004002
	}
}
DISPATCH_AddRef(ptr){
	cRef:=NumGet(ptr+4)
	cRef++
	NumPut(cRef,ptr+4)
	return cRef
}
DISPATCH_Release(ptr){
	cRef:=NumGet(ptr+4)
	cRef--
	NumPut(cRef,ptr+4)
	if(cRef==0){
		Free(ptr)
	}
	return cRef
}
DISPATCH_GetTypeInfoCount(ptr,pct){
	NumPut(0,pct+0)
	return 0
}
DISPATCH_GetTypeInfo(ptr,info,lcid,pInfo){
	return 0x8002000B	;DISP_E_BADINDEX
}
DISPATCH_GetIDsOfNames(ptr,riid,pszNames,cNames,lcid,pDispID){
	wc2mb_ref(NumGet(pszNames+0),name)
	hr:=GetOleMethodCallback(NumGet(ptr+12),name,cb)
	NumPut(cb,pDispID+0)
	return hr
}
DISPATCH_Invoke(ptr,dispid,riid,lcid,wFlags,params,pvRes,exinf,argerr){
	DllCall(dispid,&quot;UInt&quot;,ptr, &quot;UInt&quot;,params, &quot;UInt&quot;,pvRes, &quot;UInt&quot;,wFlags)
	return 0
}



EntryOleMethodsPrefix(ByRef prefix,ByRef id){
	global
	static OleMethodsCount=0
	if(OleMethodsID_%prefix%){
		id:=OleMethodsID_%prefix%
	}else{
		OleMethodsID_%prefix%:=OleMethodsCount
		OleMethodsPrefix_%OleMethodsCount%:=prefix
		id:=OleMethodsCount++
	}
}
GetOleMethodCallback(id,ByRef name,ByRef cb){
	global
	local prefix
	cb:=0
	prefix:=OleMethodsPrefix_%id%
	if(prefix){
		if(OleMethodCallback_%prefix%%name%){
			cb:=OleMethodCallback_%prefix%%name%
			return 0
		}else{
			cb:=RegisterCallback(prefix . name)
			if(cb){
				OleMethodCallback_%prefix%%name%:=cb
				return 0
			}else{
				return 0x80020006
			}
		}
	}
}

CreateDispatchObject(prefix,exsize=0){
	global IID_IDispatch
	static vtDispatch
	if(!vtDispatch){
		vtDispatch:=Malloc(28)
		NumPut(RegisterCallback(&quot;DISPATCH_QueryInterface&quot;),		vtDispatch+0)
		NumPut(RegisterCallback(&quot;DISPATCH_AddRef&quot;),				vtDispatch+4)
		NumPut(RegisterCallback(&quot;DISPATCH_Release&quot;),			vtDispatch+8)
		NumPut(RegisterCallback(&quot;DISPATCH_GetTypeInfoCount&quot;),	vtDispatch+12)
		NumPut(RegisterCallback(&quot;DISPATCH_GetTypeInfo&quot;),		vtDispatch+16)
		NumPut(RegisterCallback(&quot;DISPATCH_GetIDsOfNames&quot;),		vtDispatch+20)
		NumPut(RegisterCallback(&quot;DISPATCH_Invoke&quot;),				vtDispatch+24)
	}
	EntryOleMethodsPrefix(prefix,id)
	ptr:=Malloc(12+exsize)
	NumPut(vtDispatch		,ptr+0)
	NumPut(IID_IDispatch	,ptr+8)
	NumPut(id				,ptr+12)
	return ptr
}    </description>
    <dc:date>2010-11-11T01:02:50+09:00</dc:date>
    <utime>1289404970</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/1.html">
    <title>トップページ</title>
    <link>https://w.atwiki.jp/lockerroom/pages/1.html</link>
    <description>
      **閉鎖された空間　プログラム分室

**memo
-[[@wikiの基本操作&gt;http://atwiki.jp/guide/category2.html]]
-[[用途別のオススメ機能紹介&gt;http://atwiki.jp/guide/category22.html]]
-[[@wikiの設定/管理&gt;http://atwiki.jp/guide/category6.html]]
-[[@wiki ご利用ガイド&gt;http://atwiki.jp/guide/]]
-[[よくある質問&gt;http://atwiki.jp/guide/category1.html]]

-[[@wikiプラグイン&gt;http://atwiki.jp/guide/category17.html]]
-[[@wiki便利ツール&gt;http://atwiki.jp/guide/category32.html]]
-[[@wiki構文&gt;http://atwiki.jp/guide/category16.html]]
-[[@wikiプラグイン一覧&gt;http://www1.atwiki.jp/guide/pages/264.html]]
-[[まとめサイト作成支援ツール&gt;http://atwiki.jp/matome/]]    </description>
    <dc:date>2010-11-11T00:54:48+09:00</dc:date>
    <utime>1289404488</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/3.html">
    <title>右メニュー</title>
    <link>https://w.atwiki.jp/lockerroom/pages/3.html</link>
    <description>
      **更新履歴
#recent(20)


&amp;link_editmenu2(text=ここを編集)
    </description>
    <dc:date>2010-11-11T00:43:55+09:00</dc:date>
    <utime>1289403835</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/4.html">
    <title>プラグイン/ニュース</title>
    <link>https://w.atwiki.jp/lockerroom/pages/4.html</link>
    <description>
      * ニュース
@wikiのwikiモードでは
 #news(興味のある単語)
と入力することで、あるキーワードに関連するニュース一覧を表示することができます
詳しくはこちらをご覧ください。
＝＞http://atwiki.jp/guide/17_174_ja.html


-----


たとえば、#news(wiki)と入力すると以下のように表示されます。


#news(wiki)
    </description>
    <dc:date>2010-11-11T00:43:55+09:00</dc:date>
    <utime>1289403835</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/5.html">
    <title>まとめサイト作成支援ツール</title>
    <link>https://w.atwiki.jp/lockerroom/pages/5.html</link>
    <description>
      * まとめサイト作成支援ツールについて
@wikiには[[まとめサイト作成を支援するツール&gt;&gt;http://atwiki.jp/matome/]]があります。
また、
 #matome_list
と入力することで、注目の掲示板が一覧表示されます。

利用例）#matome_listと入力すると下記のように表示されます
#matome_list
    </description>
    <dc:date>2010-11-11T00:43:55+09:00</dc:date>
    <utime>1289403835</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/6.html">
    <title>プラグイン/編集履歴</title>
    <link>https://w.atwiki.jp/lockerroom/pages/6.html</link>
    <description>
      * 更新履歴
@wikiのwikiモードでは
 #recent(数字)
と入力することで、wikiのページ更新履歴を表示することができます。
詳しくはこちらをご覧ください。
＝＞http://atwiki.jp/guide/17_117_ja.html


-----


たとえば、#recent(20)と入力すると以下のように表示されます。


#recent(20)
    </description>
    <dc:date>2010-11-11T00:43:55+09:00</dc:date>
    <utime>1289403835</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/lockerroom/pages/7.html">
    <title>プラグイン/アーカイブ</title>
    <link>https://w.atwiki.jp/lockerroom/pages/7.html</link>
    <description>
      * アーカイブ
@wikiのwikiモードでは
 #archive_log()
と入力することで、特定のウェブページを保存しておくことができます。
詳しくはこちらをご覧ください。
＝＞http://atwiki.jp/guide/25_171_ja.html


-----


たとえば、#archive_log()と入力すると以下のように表示されます。
保存したいURLとサイト名を入力して&quot;アーカイブログ&quot;をクリックしてみよう


#archive_log()
    </description>
    <dc:date>2010-11-11T00:43:55+09:00</dc:date>
    <utime>1289403835</utime>
  </item>
  </rdf:RDF>
