goo

HSP3x64

環境
os: Windows10 x64
__hspver__: 0x3507
64ビット アプリケーションの作成
デフォルトでは32bitアプリが作成されますが、ランタイムをhsp3_64にすることで64bitアプリを作成することができます。
詳細は、Helpで#runtime を参照。
#runtime "hsp3_64"
	dialog "64bit",, "HSP3_64"
	stop
注意点
現在、64bitランタイムはβテスト版です。64ビット整数が扱えないので関連する命令等は使用できません。
詳細は、プログラミング・マニュアル(hspprog.htm)の2.25. 64bit(x64)対応版ランタイムの利用について を参照。
mod_x64
正式版がでるまでの代替モジュール mod_x64を作成。 64ビット整数の代わりとして、doubleを使用。
x64(p1, p2)
64ビット値の作成 p1は下位32ビット値、p2は上位32ビット値。 戻り値はdouble型の64ビット値。
x64varptr(p1)
変数p1のポインタ取得。戻り値はdouble。
x64func p1, p2, p3, p4, p5
関数呼び出し用の変数を作成。 p1はDLL名、p2は関数名。p3は関数の引数の数、p4は、関数の戻り値が整数の場合0、doubleの場合1を指定。 p5は、関数呼び出し用配列変数を指定。 戻り値は成功1、失敗0。
x64call(p1, p2)
関数呼び出し。 p1はx64funcで作成した変数(p5)、p2は引数用のdouble型配列。 戻り値は関数の戻り値(double型)。
x64dcall(p1, p2, p3, ...)
define定義の関数呼び出し。 p1は、x64funcかx64methodで作成した変数、 x64funcの場合、p2から引数を指定。 x64methodの場合、p2はx64newcomで作成した変数(p3)、p3から引数を指定。 p17まで指定可能。 戻り値は関数、メソッドの戻り値(double型)。
x64newcom p1, p2, p3
COMオブジェクトの作成。 p1はCLSID文字列、p2は、IID文字列、p3は、COMオブジェクト用変数。 戻り値は成功1、失敗0。
x64method p1, p2, p3, p4, p5
メソッド呼び出し用の変数を作成。 p1は、x64newcomで作成した変数(p3)、p2は、メソッドindex値、p3は、メソッドの引数の数、p4は、関数の戻り値が整数の場合0、doubleの場合1を指定。 p5は、メソッド呼び出し用配列変数を指定。 戻り値は成功1、失敗0。
x64ccall(p1, p2, p3)
メソッド呼び出し。 p1はx64methodで作成した変数(p5)、p2は、x64newcomで作成した変数(p3)。 p3は、引数用のdouble型配列。 戻り値はメソッドの戻り値(double型)。
x64query p1, p2, p3
QueryInterface呼び出し。 p1は、x64newcomで作成した変数(p3)、p2は、IID文字列、p3は、COMオブジェクト用変数。 戻り値はHRESULT。
x64release p1
Release呼び出し。 p1は、x64newcomで作成した変数(p3)。 戻り値はリファレンスカウント。
x64proc p1
ウィンドウプロシージャの変更。 HWND, uMsg, wParam, lParamを取得できるようにします。 p1は、プロシージャ用の変数(実数型配列)。 HWNDは、p1(0) または、x64proc_hwnd(p1)。 uMsgは、p1(1) または、x64proc_msg(p1)。 wParamは、p1(2) または、x64proc_wp(p1)。 lParamは、p1(3) または、x64proc_lp(p1)。 戻り値は無し。
サンプル 関数呼び出し
#include "mod_x64.hsp"

x64func "kernel32.dll", "GetCommandLineA", 0, 0, dGetCommandLineA
x64func "kernel32.dll", "lstrcpyA", 2, 0, dlstrcpyA

	ddim dArgs, 4
	dRet = 0.0
	sdim dst, 1024

	dRet = x64call(dGetCommandLineA, dArgs)
	dArgs = x64varptr(dst), dRet
	dRet = x64call(dlstrcpyA, dArgs)
	mes strf("GetCommandLine: [%s]", dst)
	stop
サンプル wParamの取得
#include "mod_x64.hsp"

x64func "shell32.dll", "DragAcceptFiles", 2, 0, dDragAcceptFiles
x64func "shell32.dll", "DragQueryFileA", 4, 0, dDragQueryFileA
x64func "shell32.dll", "DragFinish", 1, 0, dDragFinish
#define global ctype DragAcceptFiles(%1, %2) x64dcall(dDragAcceptFiles, %1, %2)
#define global ctype DragQueryFileA(%1, %2, %3, %4) x64dcall(dDragQueryFileA, %1, %2, %3, %4)
#define global ctype DragFinish(%1) x64dcall(dDragFinish, %1)

#define global WM_DROPFILES 0x0233

	sdim mb, 1024

	screen 0
	mesbox mb, ginfo_winx, ginfo_winy
	x64proc proc
	oncmd gosub *DropFiles, WM_DROPFILES
	dRet = DragAcceptFiles(x64(hwnd, 0), x64(1, 0))
	stop

*DropFiles
	// if ( x64low(x64proc_msg(proc)) != WM_DROPFILES ){ return }
	buf = ""
	hDrop = x64proc_wp(proc)
	dRet = DragQueryFileA(hDrop, x64(-1, -1), x64(0, 0), x64(0, 0))
	n = x64low(dRet)
	sdim fileName, 260
	repeat n
		dRet = DragQueryFileA(hDrop, x64(cnt, 0), x64varptr(fileName), x64(260, 0))
		buf += fileName + "\n"
	loop
	dRet = DragFinish(hDrop)
	title strf("ファイル数 %d", n)
	objprm 0, buf
	return
サンプル COMオブジェクト
#include "mod_x64.hsp"

x64func "kernel32.dll", "lstrcpyW", 2, 0, dlstrcpyW
x64func "Oleaut32.dll", "SysAllocString", 1, 0, dSysAllocString
x64func "Oleaut32.dll", "SysReAllocString", 2, 0, dSysReAllocString
x64func "Oleaut32.dll", "SysFreeString", 1, 0, dSysFreeString

#define global CLSID_DOMDocument30 "{f5078f32-c551-11d3-89b9-0000f81fe221}"
#define global IID_IXMLDOMDocument "{2933BF81-7B36-11d2-B20E-00C04F983E60}"

	bufXml = {"<html>
		<body>
			<div id=¥"id1¥">hsp2</div>
			<div id=¥"id2¥">hsp3</div>
		</body>
	</html>"}
	mes strf("dXmlDoc.loadXML({¥"%s¥"})¥n", bufXml)
	sdim wBufXml, 1024
	ddim args, 4
	dRet = 0.0 : dRet2 = 0.0 : dNode = 0.0
	dBstr = 0.0 : dBstr2 = 0.0
	x64newcom CLSID_DOMDocument30, IID_IXMLDOMDocument, dXmlDoc
	x64method dXmlDoc, 37, 2, 0, selectSingleNode
	x64method dXmlDoc, 65, 2, 0, loadXML
	sdim wBufXml, (strlen(bufXml) + 1) * 2
	cnvstow wBufXml, bufXml
	dBstr = x64dcall(dSysAllocString, x64varptr(wBufXml))
	dRet = x64dcall(loadXML, dXmlDoc, dBstr, x64varptr(dRet2))
	xpath = "//div[@id='id2']"
	cnvstow wBufXml, xpath
	dRet = x64dcall(dSysReAllocString, x64varptr(dBstr), x64varptr(wBufXml))
	dRet = x64dcall(selectSingleNode, dXmlDoc, dBstr, x64varptr(dNode))
	x64method dNode, 26, 1, 0, get_text
	dRet = x64dcall(get_text, dNode, x64varptr(dBstr2))
	dRet = x64dcall(dlstrcpyW, x64varptr(wBufXml), dBstr2)
	mes strf("dXmlDoc.selectSingleNode(¥"%s¥").get_text(): [%s]", xpath, cnvwtos(wBufXml))
	dRet = x64dcall(dSysFreeString, dBstr2)
	dRet = x64dcall(dSysFreeString, dBstr)
	x64release dNode
	x64release dXmlDoc
	stop
mod_x64.hsp
#ifndef MOD_X64_HSP_
#define global MOD_X64_HSP_

#include "hsp3_64.as"

#define global ctype x64dcall(%1, %2 = 0, %3 = 0, %4 = 0, ¥
	%5 = 0, %6 = 0, %7 = 0, %8 = 0, %9 = 0, %10 = 0, %11 = 0, ¥
	%12 = 0, %13 = 0, %14 = 0, %15 = 0, %16 = 0, %17 = 0) ¥
	x64dcall_(%1, %2, %3, %4, %5, %6, %7, %8, %9, ¥
	%10, %11, %12, %13, %14, %15, %16, %17)

#define global ctype x64proc_hwnd(%1) %1(0)
#define global ctype x64proc_msg(%1) %1(1)
#define global ctype x64proc_wp(%1) %1(2)
#define global ctype x64proc_lp(%1) %1(3)

#module mod_x64

#define X64_Call LoadModule_
#define X64_CallName "LoadModule"

#uselib "user32.dll"
#func wsprintfA_         "wsprintfA"         var,str,var
#func SetWindowLongPtrA_ "SetWindowLongPtrA" int,int,double
#uselib "kernel32.dll"
#func X64_Call          X64_CallName       int,var,var,var
#func GetModuleHandle_  "GetModuleHandleA" double
#func LoadLibrary_      "LoadLibraryA"     double
#func GetProcAddress_   "GetProcAddress"   double,double
#func RtlMoveMemory_    "RtlMoveMemory"    double,double,int
#func VirtualProtect_   "VirtualProtect"   var,int,int,var
#func lstrcmp_          "lstrcmpA"         double,double

#deffunc x64err str errMsg
	dialog "Error: " + errMsg, , "mod_x64"
	end
	return

#deffunc x64init
	d = 0.0 : d2 = 0.0
	ddim dArgs, 8
	ddim dRet, 2
	if ( 0 ){
		x64_Call 0, d, d2, ret
		LoadLibrary_ 0
		GetProcAddress_ 0, 0
	}
	GetModuleHandle_ x64(0, 0)
	if ( stat == 0x400000 ){
		x64err "Not 64bit runntime"
	}
	if ( x64funcst(X64_CallName, 4, 0, d, d2) == 0 ){ x64err X64_CallName }
	dim code, 40
	code(0) = $244C894C, $8B485508, $D28548EC, $8B486B74, $C0854802, $C9856374, $854D3D74, $485A74C0
	code(8) = $E2C1D18B, $20EA8303, $DAF7047D, $E28303EB, $E22B4808, $41C9FF48, $7FC834FF, $415A59F7
	code(16) = $66594158, $C16E0F48, $6E0F4866, $0F4966CA, $4966D06E, $48D96E0F, $FF20EC83, $8B48C9D0
	code(24) = $4808244C, $0974C985, $66018948, $417E0F48, $C0C74808, $00000001, $C03348C3, $0000C3C9
	VirtualProtect_ code, 40 * 4, 0x40, i1
	dCode = x64varptr(code)
	x64copy x64move(d2, 24), x64varptr(dCode), 8
	dim codeProc, 20
	codeProc(0) = $aaaab848, $aaaaaaaa, $8948aaaa, $48082444, $a348c18b, $bbbbbbbb, $bbbbbbbb, $cca3c28b
	codeProc(8) = $cccccccc, $49cccccc, $a348c08b, $dddddddd, $dddddddd, $48c18b49, $eeeeeea3, $eeeeeeee
	codeProc(16) = $448b48ee, $ff480824, $000000e0
	buf = "LoadLibraryA"
	if ( x64funcst(buf, 1, 0, dLoad, d) == 0 ){ x64err buf }
	buf = "GetProcAddress"
	if ( x64funcst(buf, 2, 0, dProc, d) == 0 ){ x64err buf }
	buf = "IIDFromString"
	x64func "ole32.dll", buf, 2, 0, dIidStr
	if ( stat == 0 ){ x64err buf }
	buf = "CoCreateInstance"
	x64func "ole32.dll", buf, 5, 0, dCoInst
	if ( stat == 0 ){ x64err buf }
	x64func "user32.dll", "GetWindowLongPtrA", 2, 0, dGetWindowLongPtrA
	return

#defcfunc x64 int lp, int hp
	dMake = 0.0
	lpoke dMake, 0, lp
	lpoke dMake, 4, hp
	return dMake

#defcfunc x64zero double src
	dSrc = src
	if ( lpeek(dSrc, 0) == 0 && lpeek(dSrc, 4) == 0 ){
		return 1
	}
	return 0

#defcfunc x64low double src
	dSrc = src
	return lpeek(dSrc, 0)

#defcfunc x64high double src
	dSrc = src
	return lpeek(dSrc, 4)

#defcfunc x64varptr var v
	bufV = ""
	wsprintfA_ bufV, "%p", v
	l = strlen(bufV)
	if ( l > 8 ){
		i1 = int("$"+strmid(bufV, -1, 8))
		i2 = int("$"+strmid(bufV, 0, l - 8))
	}
	else {
		i1 = int("$"+strmid(bufV, 0, l))
		i2 = 0
	}
	return x64(i1, i2)

#defcfunc x64move double src, int nPos
	if ( nPos == 0 ){ return src }
	dSrc = src
	i1 = lpeek(dSrc, 0)
	i2 = lpeek(dSrc, 4)
	i = i1 + nPos
	if ( nPos > 0 ){
		if ( i1 < 0 && i > 0 ) { i2++ }
	}
	else {
		if ( i1 > 0 && i < 0 ){ i2-- }
	}
	i1 = i
	return x64(i1, i2)

#deffunc x64copy double dst, double src, int nSize
	if ( nSize <= 0 ){ return 0 }
	RtlMoveMemory_ dst, src, nSize
	return nSize

#defcfunc x64funcst str funcName, int len, int bRetd, array dFunc, var dstdat
	ret = 0
	if ( ctx == 0 ){
		mref ctx, 68
		dHed = x64(ctx(0), ctx(1))
		dim aHed, 28
		x64copy x64varptr(aHed), dHed, 112
		dFInfo = x64(ctx(342), ctx(343))
		dMds = x64(ctx(6), ctx(7))
		dim stdat, 10
	}
	name = funcName
	dName = x64varptr(name)
	repeat aHed(15) / 40
		x64copy x64varptr(stdat), x64move(dFInfo, cnt * 40), 40
		if ( wpeek(stdat, 2) == 0xfffc ){
			lstrcmp_ dName, x64move(dMds, stdat(3))
			if ( stat == 0 ){
				ddim dFunc, 3
				dFunc = x64(stdat(6), stdat(7)), x64(len, 0)
				if ( bRetd ){ dFunc(2) = 1.0 }
				dstdat = x64move(dFInfo, cnt * 40)
				ret = 1
				break
			}
		}
	loop
	return ret

#deffunc x64func str libName, str funcName, int len, int bRetd, array dFunc
	ddim dFunc, 3
	dFunc(1) = x64(len, 0)
	if ( bRetd ){ dFunc(2) = 1.0 }
	buf = libName
	dArgs = x64varptr(buf)
	dLib = x64call(dLoad, dArgs)
	if ( x64zero(dLib) != 0 ){ return 0 }
	buf = funcName
	dArgs = dLib, x64varptr(buf)
	dCall = x64call(dProc, dArgs)
	if ( x64zero(dCall) != 0 ){ return 0 }
	dFunc(0) = dCall
	return 1

#defcfunc x64dcall_ array dFunc, ¥
	double p1, double p2, double p3, double p4, ¥
	double p5, double p6, double p7, double p8, ¥
	double p9, double p10, double p11, double p12, ¥
	double p13, double p14, double p15, double p16

	i1 = lpeek(dFunc, 8)
	if ( i1 > 16 ){ return x64(0, 0) }
	ddim dcallArgs, 16
	if ( i1 > 0 ){ dcallArgs(0) = p1, p2, p3, p4, p5 }
	if ( i1 > 5 ){ dcallArgs(5) = p6, p7, p8, p9, p10 }
	if ( i1 > 10 ){ dcallArgs(10) = p11, p12, p13, p14, p15, p16 }
	x64_Call i1, dFunc, dcallArgs, dRet
	if ( dFunc(2) == 1.0 ){ return dRet(1) }
	return dRet(0)

#defcfunc x64call array dFunc, array aArgs
	i1 = lpeek(dFunc, 8)
	if ( i1 > length(aArgs) ){ return x64(0, 0) }
	x64_Call i1, dFunc, aArgs, dRet
	if ( dFunc(2) == 1.0 ){ return dRet(1) }
	return dRet(0)

#defcfunc x64iidstr str iid, array aIid
	i1 = strlen(iid)
	sdim wStrIid, (i1 + 1) * 2
	cnvstow wStrIid, iid
	dim aIid, 4
	dArgs = x64varptr(wStrIid), x64varptr(aIid)
	d = x64call(dIidStr, dArgs)
	if ( x64zero(d) == 0 ){ return 0 }
	return 1

#deffunc x64newcom str classid, str iid, var dCom
	if ( x64iidstr(classid, aIid1) == 0 ){ return 0 }
	if ( x64iidstr(iid, aIid2) == 0 ){ return 0 }
	dCom = x64(0, 0)
	dArgs = x64varptr(aIid1), x64(0, 0), x64(15, 0), x64varptr(aIid2), x64varptr(dCom)
	d = x64call(dCoInst, dArgs)
	if ( x64zero(d) == 0 ){ return 0 }
	return 1

#deffunc x64method double dCom, int cID, int len, int bRetd, array dMethod
	if ( x64zero(dCom) ){ return 0 }
	ddim dMethod, 3
	ddim dVT, 1
	x64copy x64varptr(dVT), dCom, 8
	if ( x64zero(dVT) ){ return 0 }
	x64copy x64varptr(dMethod), x64move(dVT, cID * 8), 8
	dMethod(1) = x64(len + 1, 0)
	if ( bRetd ){ dMethod(2) = 1.0 }
	return 1

#defcfunc x64ccall array dMethod, double dCom, array aArgs
	i1 = lpeek(dMethod, 8)
	ddim dcArgs, i1
	dcArgs(0) = dCom
	repeat i1 - 1 : dcArgs(cnt + 1) = aArgs(cnt) : loop
	return x64call(dMethod, dcArgs)

#deffunc x64query double dCom, str iid, var dComq
	x64method dCom, 0, 2, 0, dQuery
	if ( stat == 0 ){ return 0 }
	if ( x64iidstr(iid, aIid1) == 0 ){ return 0 }
	ddim queryArgs, 2
	ddim dComq, 1
	queryArgs = x64varptr(aIid1), x64varptr(dComq)
	return x64ccall(dQuery, dCom, queryArgs)

#deffunc x64release double dCom
	x64method dCom, 2, 0, 0, aRelease
	if ( stat == 0 ){ return 0 }
	return x64ccall(aRelease, dCom, dRet)

#deffunc x64proc array procInfo
	// procInfo(0): hWnd   procInfo(1): uMsg
	// procInfo(2): wParam procInfo(3): lParam
	ddim procInfo, 16
	repeat 19
		lpoke procInfo, cnt * 4 + 48, codeProc(cnt)
	loop
	dRet = x64varptr(procInfo(0))
	lpoke procInfo, 68, lpeek(dRet, 0) : lpoke procInfo, 72, lpeek(dRet, 4)
	dRet = x64varptr(procInfo(1))
	lpoke procInfo, 79, lpeek(dRet, 0) : lpoke procInfo, 83, lpeek(dRet, 4)
	dRet = x64varptr(procInfo(2))
	lpoke procInfo, 92, lpeek(dRet, 0) : lpoke procInfo, 96, lpeek(dRet, 4)
	dRet = x64varptr(procInfo(3))
	lpoke procInfo, 105, lpeek(dRet, 0) : lpoke procInfo, 109, lpeek(dRet, 4)
	dArgs = x64(hwnd, 0), x64(-4, 0)
	dRet = x64call(dGetWindowLongPtrA, dArgs)
	lpoke procInfo, 50, lpeek(dRet, 0) : lpoke procInfo, 54, lpeek(dRet, 4)
	VirtualProtect_ procInfo, 16 * 8, 0x40, i1
	SetWindowLongPtrA_ hwnd, -4, x64varptr(procInfo(6))
	return

#global

	x64init

#endif // MOD_X64_HSP_
コメント ( 0 ) | Trackback ( 0 )

HSP UWP OCR

Sample_WindowsMediaOcr.hsp


#uselib "combase.dll"
#func global RoInitialize              "RoInitialize"              int
#func global RoUninitialize            "RoUninitialize"
#func global RoActivateInstance        "RoActivateInstance"        int,var
#func global RoGetActivationFactory    "RoGetActivationFactory"    int,var,var
#func global WindowsCreateString       "WindowsCreateString"       wptr,int,var
#func global WindowsDeleteString       "WindowsDeleteString"       int
#func global WindowsGetStringLen       "WindowsGetStringLen"       int
#func global WindowsGetStringRawBuffer "WindowsGetStringRawBuffer" int,var
#func global WindowsConcatString       "WindowsConcatString"       int,int,var

#define global UWP_IID_IRandomAccessStream "{905A0FE1-BC53-11DF-8C49-001E4FC686DA}"
#usecom global UWP_IRandomAccessStream UWP_IID_IRandomAccessStream "{}"
#comfunc global UWP_IRandomAccessStream_GetOutputStreamAt  9 int,int,var

#define global UWP_IID_IDataWriter "{64B89265-D341-4922-B38A-DD4AF8808C4E}"
#usecom global UWP_IDataWriter UWP_IID_IDataWriter "{}"
#comfunc global UWP_IDataWriter_WriteBytes  12 int,var
#comfunc global UWP_IDataWriter_StoreAsync  29 var

#define global UWP_IID_IDataWriterFactory "{338C67C2-8B84-4C2B-9C50-7B8767847A1F}"
#usecom global UWP_IDataWriterFactory UWP_IID_IDataWriterFactory "{}"
#comfunc global UWP_IDataWriterFactory_CreateDataWriter  6 int,var

#define global UWP_IID_IBitmapDecoder "{ACEF22BA-1D74-4C91-9DFC-9620745233E6}"
#usecom global UWP_IBitmapDecoder UWP_IID_IBitmapDecoder "{}"

#define global UWP_IID_IBitmapDecoderStatics "{438CCB26-BCEF-4E95-BAD6-23A822E58D01}"
#usecom global UWP_IBitmapDecoderStatics UWP_IID_IBitmapDecoderStatics "{}"
#comfunc global UWP_IBitmapDecoderStatics_CreateAsync  14 int,var

#define global UWP_IID_IBitmapFrameWithSoftwareBitmap "{FE287C9A-420C-4963-87AD-691436E08383}"
#usecom global UWP_IBitmapFrameWithSoftwareBitmap UWP_IID_IBitmapFrameWithSoftwareBitmap "{}"
#comfunc global UWP_IBitmapFrameWithSoftwareBitmap_GetSoftwareBitmapAsync  6 var

#define global UWP_IID_ISoftwareBitmap "{689E0708-7EEF-483F-963F-DA938818E073}"
#usecom global UWP_ISoftwareBitmap UWP_IID_ISoftwareBitmap "{}"
#comfunc global UWP_ISoftwareBitmap_get_BitmapPixelFormat  6 var
#comfunc global UWP_ISoftwareBitmap_get_BitmapAlphaMode    7 var
#comfunc global UWP_ISoftwareBitmap_get_PixelWidth         8 var
#comfunc global UWP_ISoftwareBitmap_get_PixelHeight        9 var

#define global UWP_IID_ILanguageFactory "{9B0252AC-0C27-44F8-B792-9793FB66C63E}"
#usecom global UWP_ILanguageFactory UWP_IID_ILanguageFactory "{}"
#comfunc global UWP_ILanguageFactory_CreateLanguage  6 int,var

#define global UWP_IID_ILanguage "{EA79A752-F7C2-4265-B1BD-C4DEC4E4F080}"
#usecom global UWP_ILanguage UWP_IID_ILanguage "{}"

#define global UWP_IID_IOcrEngineStatics "{5BFFA85A-3384-3540-9940-699120D428A8}"
#usecom global UWP_IOcrEngineStatics UWP_IID_IOcrEngineStatics "{}"
#comfunc global UWP_IOcrEngineStatics_TryCreateFromLanguage  9 int,var

#define global UWP_IID_IOcrEngine "{5A14BC41-5B76-3140-B680-8825562683AC}"
#usecom global UWP_IOcrEngine UWP_IID_IOcrEngine "{}"
#comfunc global UWP_IOcrEngine_RecognizeAsync  6 int,var

#define global UWP_IID_IOcrResult "{9BD235B2-175B-3D6A-92E2-388C206E2F63}"
#usecom global UWP_IOcrResult UWP_IID_IOcrResult "{}"
#comfunc global UWP_IOcrResult_get_Lines      6 var
#comfunc global UWP_IOcrResult_get_TextAngle  7 var
#comfunc global UWP_IOcrResult_get_Text       8 var

#define global UWP_IID_IOcrLine "{0043A16F-E31F-3A24-899C-D444BD088124}"
#usecom global UWP_IOcrLine UWP_IID_IOcrLine "{}"
#comfunc global UWP_IOcrLine_get_Words  6 var
#comfunc global UWP_IOcrLine_get_Text   7 var

#define global UWP_IID_IVectorViewOcrLine "{60c76eac-8875-5ddb-a19b-65a3936279ea}"
#usecom global UWP_IVectorViewOcrLine UWP_IID_IVectorViewOcrLine "{}"
#comfunc global UWP_IVectorViewOcrLine_GetAt     6 int,var
#comfunc global UWP_IVectorViewOcrLine_get_Size  7 var
#comfunc global UWP_IVectorViewOcrLine_IndexOf   8 int,var,var
#comfunc global UWP_IVectorViewOcrLine_GetMany   9 int,int,var,var

#define global UWP_IID_IOcrWord "{3C2A477A-5CD9-3525-BA2A-23D1E0A68A1D}"
#usecom global UWP_IOcrWord UWP_IID_IOcrWord "{}"
#comfunc global UWP_IOcrWord_get_BoundingRect  6 var
#comfunc global UWP_IOcrWord_get_Text          7 var

#define global UWP_IID_IVectorViewOcrWord "{805a60c7-df4f-527c-86b2-e29e439a83d2}"
#usecom global UWP_IVectorViewOcrWord UWP_IID_IVectorViewOcrWord "{}"
#comfunc global UWP_IVectorViewOcrWord_GetAt     6 int,var
#comfunc global UWP_IVectorViewOcrWord_get_Size  7 var
#comfunc global UWP_IVectorViewOcrWord_IndexOf   8 int,var,var
#comfunc global UWP_IVectorViewOcrWord_GetMany   9 int,int,var,var

#define global UWP_IID_IAsyncInfo "{00000036-0000-0000-C000-000000000046}"
#usecom global UWP_IAsyncInfo UWP_IID_IAsyncInfo "{}"
#comfunc global UWP_IAsyncInfo_get_Status  7 var

#define global UWP_IID_IAsyncOperation_1_UINT32 "{ef60385f-be78-584b-aaef-7829ada2b0de}"
#usecom global UWP_IAsyncOperation_1_UINT32 UWP_IID_IAsyncOperation_1_UINT32 "{}"
#comfunc global UWP_IAsyncOperation_1_UINT32_GetResults  8 var

#define global UWP_IID_IAsyncOperationBitmapDecoder "{aa94d8e9-caef-53f6-823d-91b6e8340510}"
#usecom global UWP_IAsyncOperationBitmapDecoder UWP_IID_IAsyncOperationBitmapDecoder "{}"
#comfunc global UWP_IAsyncOperationBitmapDecoder_GetResults  8 var

#define global UWP_IID_IAsyncOperationSoftwareBitmap "{c4a10980-714b-5501-8da2-dbdacce70f73}"
#usecom global UWP_IAsyncOperationSoftwareBitmap UWP_IID_IAsyncOperationSoftwareBitmap "{}"
#comfunc global UWP_IAsyncOperationSoftwareBitmap_GetResults  8 var

#define global UWP_IID_IAsyncOperationOcrResult "{c7d7118e-ae36-59c0-ac76-7badee711c8b}"
#usecom global UWP_IAsyncOperationOcrResult UWP_IID_IAsyncOperationOcrResult "{}"
#comfunc global UWP_IAsyncOperationOcrResult_GetResults  8 var

#module

#uselib "ole32.dll"
#func IIDFromString "IIDFromString" wptr,var

#defcfunc RoapiGetInstance str classId
	p = 0
	WindowsCreateString classId, strlen(classId), p2
	if ( stat == 0 ){
		RoActivateInstance p2, p
		WindowsDeleteString p2
	}
	return p

#defcfunc RoapiGetFactory str classId, str iid
	p = 0
	WindowsCreateString classId, strlen(classId), p2
	if ( stat == 0 ){
		dim iid_, 4
		IIDFromString iid, iid_
		RoGetActivationFactory p2, iid_, p
		WindowsDeleteString p2
	}
	return p

#defcfunc WinStringNew str strBuf
	WindowsCreateString strBuf, strlen(strBuf), p
	if ( stat ){ return 0 }
	return p

#deffunc WinStringDel int h
	WindowsDeleteString h
	if ( stat ){ return 0 }
	return 1

#defcfunc WinStringGet int hStr
	if ( hStr == 0 ){ return "" }
	WindowsGetStringLen hStr
	if ( stat == 0 ){ return "" }
	WindowsGetStringRawBuffer hStr, l
	p = stat
	if ( p == 0 || l == 0 ){ return "" }
	dupptr dp, p, (l + 1) * 2, 2
	return cnvwtos(dp)

#defcfunc UWP_IAsyncInfoWait int pv, int awaitTime
	if ( pv == 0 ){ return 0 }
	s = 0
	newcom ca, UWP_IAsyncInfo, -2, pv
	if ( vartype(ca) != 6 ){ return 0 }
	if ( varuse(ca) == 0 ){ return 0 }
	repeat
		UWP_IAsyncInfo_get_Status ca, s
		if ( stat != 0 || s != 0 ){ break }
		if ( awaitTime ){ await awaitTime }
	loop
	delcom ca
	if ( s != 1 ){ return 0 }
	return 1

#global

#include "user32.as"

#define CHKHR(%1, %2) if ( %1 ){ dialog %2, , "Error" : end }
#define CHKRET(%1, %2) if ( %1 == 0 ){ dialog %2, , "Error" : end }

#define LANGUAGETAG "ja"

	//  1. Windows Runtimeの初期化
	RoInitialize 1
	//  2. 画像ファイル読み込み
	dialog "", 16 : if ( stat == 0 ){ end } : fileName = refstr
	exist fileName : len = strsize : if ( len == -1 ){ end }
	sdim buf, len : bload fileName, buf, len
	screen 0 : picload fileName : title fileName
	//  3. InMemoryRandomAccessStream(IRandomAccessStream)作成
	name = "Windows.Storage.Streams.InMemoryRandomAccessStream"
	pStream = RoapiGetInstance(name) : CHKRET pStream, "3a"
	newcom cStream, UWP_IRandomAccessStream, -1, pStream
	//  4. IRandomAccessStream.GetOutputStreamAtからDataWriter作成
	name = "Windows.Storage.Streams.DataWriter"
	p1 = RoapiGetFactory(name, UWP_IID_IDataWriterFactory) : CHKRET "4a", p1
	newcom cDataFactory, UWP_IDataWriterFactory, -1, p1
	UWP_IRandomAccessStream_GetOutputStreamAt cStream, 0, 0, p1 : CHKHR stat, "4b"
	UWP_IDataWriterFactory_CreateDataWriter cDataFactory, p1, p2 : CHKHR stat, "4c"
	newcom cDataWriter, UWP_IDataWriter, -1, p2
	delcom cDataFactory
	//  5. DataWriter.WriteBytesで、2の画像バッファ書き込み
	UWP_IDataWriter_WriteBytes cDataWriter, len, buf : CHKHR stat, "5a"
	UWP_IDataWriter_StoreAsync cDataWriter, p1 : CHKHR stat, "5b"
	p2 = UWP_IAsyncInfoWait(p1, 0) : CHKRET p2, "5c"
	newcom cTmp, UWP_IAsyncOperation_1_UINT32, -1, p1
	delcom cTmp : delcom cDataWriter
	//  6. 3のpStreamから、BitmapDecoder作成
	name = "Windows.Graphics.Imaging.BitmapDecoder"
	p1 = RoapiGetFactory(name, UWP_IID_IBitmapDecoderStatics) : CHKRET p1, "6a"
	newcom cTmp, UWP_IBitmapDecoderStatics, -1, p1
	UWP_IBitmapDecoderStatics_CreateAsync cTmp, pStream, p1 : CHKHR stat, "6b"
	p2 = UWP_IAsyncInfoWait(p1, 0) : CHKRET p2, "6c"
	newcom cTmp2, UWP_IAsyncOperationBitmapDecoder, -1, p1
	UWP_IAsyncOperationBitmapDecoder_GetResults cTmp2, p1 : CHKHR stat, "6c"
	newcom cDecoder, UWP_IBitmapDecoder, -1, p1
	delcom cTmp2 : delcom cTmp : delcom cStream
	//  7. 6のBitmapDecoderから、SoftwareBitmap取得
	querycom cTmp, cDecoder, UWP_IBitmapFrameWithSoftwareBitmap
	UWP_IBitmapFrameWithSoftwareBitmap_GetSoftwareBitmapAsync cTmp, p1 : CHKHR stat, "7a"
	p2 = UWP_IAsyncInfoWait(p1, 0) : CHKRET p2, "7b"
	newcom cTmp2, UWP_IAsyncOperationSoftwareBitmap, -1, p1
	UWP_IAsyncOperationSoftwareBitmap_GetResults cTmp2, pSoftBitmap : CHKHR stat, "7c"
	newcom cSoftBitmap, UWP_ISoftwareBitmap, -1, pSoftBitmap
	delcom cTmp2 : delcom cTmp : delcom cDecoder
	//  8. Language作成
	name = "Windows.Globalization.Language"
	p1 = RoapiGetFactory(name, UWP_IID_ILanguageFactory) : CHKRET p1, "8a"
	newcom cTmp, UWP_ILanguageFactory, -1, p1
	p1 = WinStringNew(LANGUAGETAG)
	UWP_ILanguageFactory_CreateLanguage cTmp, p1, pLang : CHKHR stat, "8b"
	WinStringDel p1
	newcom cLang, UWP_ILanguage, -1, pLang
	delcom cTmp
	//  9. 8のpLangから、OcrEngine作成
	name = "Windows.Media.Ocr.OcrEngine"
	p1 = RoapiGetFactory(name, UWP_IID_IOcrEngineStatics) : CHKRET p1, "9a"
	newcom cTmp, UWP_IOcrEngineStatics, -1, p1
	UWP_IOcrEngineStatics_TryCreateFromLanguage cTmp, pLang, p1 : CHKHR stat, "9b"
	newcom cOcrEngine, UWP_IOcrEngine, -1, p1
	delcom cTmp : delcom cLang
	// 10. 7のpSoftBitmapから、OcrEngine.RecognizeAsyncでOcrResult作成
	UWP_IOcrEngine_RecognizeAsync cOcrEngine, pSoftBitmap, p1 : CHKHR stat, "10a"
	p2 = UWP_IAsyncInfoWait(p1, 0) : CHKRET p2, "10b"
	newcom cTmp, UWP_IAsyncOperationOcrResult, -1, p1
	UWP_IAsyncOperationOcrResult_GetResults cTmp, p1 : CHKHR stat, "10c"
	newcom cOcrResult, UWP_IOcrResult, -1, p1
	delcom cTmp : delcom cSoftBitmap : delcom cOcrEngine
	// 11. OcrResultからテキスト取得
	hsResult = WinStringNew("") : hsCrlf = WinStringNew("\n")
	UWP_IOcrResult_get_Lines cOcrResult, p1 : CHKHR stat, "11a"
	newcom cVecLine, UWP_IVectorViewOcrLine, -1, p1
	UWP_IVectorViewOcrLine_get_Size cVecLine, lenLine : CHKHR stat, "11b"
	repeat lenLine
		UWP_IVectorViewOcrLine_GetAt cVecLine, cnt, p1
		if ( stat ){ break }
		newcom cTmp, UWP_IOcrLine, -1, p1
		UWP_IOcrLine_get_Text cTmp, p1
		WindowsConcatString hsResult, p1, p2
		WinStringDel p1 : WinStringDel hsResult : hsResult = p2
		WindowsConcatString hsResult, hsCrlf, p2
		WinStringDel hsResult : hsResult = p2
		delcom cTmp
	loop
	WinStringDel hsCrlf
	delcom cVecLine : delcom cOcrResult
	// 12. Windows Runtimeの終了
	RoUninitialize
	// 13. 結果表示 hsResult
	screen 1
	title strf("Windows.Media.Ocr [%s]", LANGUAGETAG)
	objmode 2 : font "メイリオ", 13
	mbTmp = ""
	mesbox mbTmp, ginfo_winx, ginfo_winy
	hMB = objinfo(stat, 2)
	WindowsGetStringRawBuffer hsResult, p1
	SendMessageW hMB, 0x000C, 0, stat
	WinStringDel hsResult
	stop
コメント ( 0 ) | Trackback ( 0 )

HSP+C#

HSP+C#
関連資料
使用モジュール
HSPからC#を実行
#include "mod_CSharp.hsp"
	src = {"
		using System;
		using System.Windows.Forms;
		class Test1 {
			static void Main(string[] args){
				MessageBox.Show(\"Main()\", \"C#\");
			}
			public void Func1(){
				MessageBox.Show(¥"Hello HSP!¥", ¥"C#¥");
			}
		}
	"}

	screen 0, 300, 40 : font "メイリオ", 12
	title "mod_CSharp.hsp"
	if ( CSMakeMod(modCS) == 0 ){ dialog "err" : end }
	if ( CSCAddRef(modCS, "System.dll") == 0 ){ dialog "err2" : end }
	if ( CSCAddRef(modCS, "System.Windows.Forms.dll") == 0 ){ dialog "err3" : end }
	if ( CSCl2(modCS, src, cAsm, cErr) ){
		if ( CSCInstance(modCS, "Test1", cAsm, cObj) ){
			mes "Test1.Func1()"
			ret = CSCall(cObj, "Func1")
		}
	}
	mes "OK"
	stop
コンパイル(インスタンス作成、エラー取得、メソッド実行)
#include "user32.as"
#include "mod_CSharp.hsp"

#module mod_Main mID, mhWnd, mBmscr

#modinit int id, int x, int y, int w, int h, str titleName
	mID = id
	screen mID, ginfo_dispx, ginfo_dispy, 2, x, y, w, h
	mhWnd = hwnd
	ret = Main_AddStyle(thismod, 0x00070000)
	title titleName : objmode 2 : mref mBmscr, 67
	return 1

#modcfunc Main_SetFont str fontName, int fontSize
	font fontName, fontSize
	return 1

#modcfunc Main_Show int nShow
	ShowWindow mhWnd, nShow
	return 1

#modcfunc Main_AddStyle int nLong
	GetWindowLong mhWnd, -16
	SetWindowLong mhWnd, -16, stat | nLong
	SetWindowPos mhWnd, 0, 0, 0, 0, 0, 0x23
	return 1

#modcfunc Main_WM_SIZE label lMsg
	gsel mID : oncmd gosub lMsg, 0x0005
	return 1

#modcfunc Button_Make str btnName, label lBtn
	gsel mID : objsize 0, 0
	button gosub btnName, lBtn
	return objinfo(stat, 2)

#modcfunc MesBox_Make var bufMB, int nStyle
	gsel mID : objsize 0, 0
	mesbox bufMB, 0, 0, nStyle, 0
	return objinfo(stat, 2)

#modcfunc MesBox_Add int hMB, str sTxt
	buf = sTxt
	sendmsg hMB, 0x0e, 0, 0
	sendmsg hMB, 0xb1, stat, stat
	sendmsg hMB, 0xc2, 0, varptr(buf)
	return 1

#modcfunc ListBox_Make
	CreateWindowEx 0, "ListBox", "", 0x50300100, 0, 0, 0, 0, mhWnd, 0, hinstance, 0
	ret = stat
	sendmsg ret, 0x0030, mBmscr(38), 1
	return ret

#modcfunc ListBox_GetSel int hLB
	sendmsg hLB, 0x0188, 0, 0
	return stat

#modcfunc ListBox_SetSel int hLB, int nID
	sendmsg hLB, 0x0186, nID, nID
	return stat

#modcfunc ListBox_GetStr int hLB, int nID
	sdim buf, 260
	sendmsg hLB, 0x0189, nID, varptr(buf)
	return buf

#modcfunc ListBox_Add int hLB, int nID, str sData
	buf = sData
	sendmsg hLB, 0x0180, nID, varptr(buf)
	return stat

#modcfunc ListBox_Clear int hLB
	sendmsg hLB, 0x018B, 0, 0
	repeat stat
		sendmsg hLB, 0x0182, 0, 0
	loop
	return 1

#global

	ret = CSMakeMod(cs)
	newmod m, mod_Main, 0, -1, -1, 600, 400, "mod_CSharp.hsp"
	ret = Main_SetFont(m, "メイリオ", 11)
	ret = Main_WM_SIZE(m, *WM_SIZE)
	gosub *MAKE_CHILD
	ret = Main_Show(m, 1)
	stop

*WM_SIZE
	x = ginfo_winx / 4 : h = ginfo_winy / 2
	MoveWindow hBtnCL, 0, 0, x, 30, 1
	MoveWindow hBtnMI, 0, 30, x, 30, 1
	MoveWindow hLBCL, 0, 60, x, h - 60, 1
	MoveWindow hBtnIV, 0, h, x, 30, 1
	MoveWindow hLBMT, 0, h + 30, x, h - 30, 1
	x2 = x * 3 : h = ginfo_winy / 3 : h2 = h * 2
	MoveWindow hEditSrc, x, 0, x2, h2, 1
	x3 = x2 / 3
	MoveWindow hEditRef, x, h2, x3, h, 1
	MoveWindow hEditOut, x + x3, h2, x3 * 2, h, 1
	return

*MAKE_CHILD
	x = 1024 * 64
	sdim mbSrc, x : sdim mbRef, x : sdim mbOut, z
	ret = Main_SetFont(m, "メイリオ", 12)
	hBtnCl = Button_Make(m, "コンパイル", *BTN_CL)
	hBtnMI = Button_Make(m, "インスタンス作成", *BTN_MI)
	hBtnIV = Button_Make(m, "メソッド実行", *BTN_IV)
	ret = Main_SetFont(m, "Consolas", 14)
	hEditSrc = MesBox_Make(m, mbSrc, 5)
	objskip 3, 2
	ret = Main_SetFont(m, "メイリオ", 11)
	hEditRef = MesBox_Make(m, mbRef, 5)
	hEditOut = MesBox_Make(m, mbOut, 4)
	hLBCL = ListBox_Make(m)
	hLBMT = ListBox_Make(m)
	return

*BTN_CL
	cs = 0 : cAsm = 0 : cObj = 0 : cErr = 0
	ret = CSMakeMod(cs)
	ret = ListBox_Clear(m, hLBCL)
	ret = ListBox_Clear(m, hLBMT)
	if ( CSCClearRef(cs) ){
		notesel mbRef : sdim buf, 260
		repeat notemax
			noteget buf, cnt
			if ( buf != "" ){ ret = CSCAddRef(cs, buf) }
		loop
	}
	if ( CSCl2(cs, mbSrc, cAsm, cErr) ){
		len = CSCErrLen(cs, cErr)
		if ( len == 0 ){
			buf2 = "成功:エラー 0"
			len = CSGetClassList(cAsm, list)
			repeat len
				ret = ListBox_Add(m, hLBCL, cnt, list(cnt))
			loop
			ret = ListBox_SetSel(m, hLBCL, 0)
		}
		else {
			buf2 = strf("失敗:エラー %d\n", len)
			if ( CSCErrList(cs, cErr, list) ){
				repeat len
					buf2 += strf("%4d行 : [%s] %s\n", int(list(2, cnt)), list(3, cnt), list(4, cnt))
				loop
			}
			else {
				buf2 += "エラー取得失敗"
			}
		}
		cErr = 0
	}
	else {
		buf2 = "コンパイル失敗"
	}
	buf2 += "\n-------------------------------\n"
	ret = MesBox_Add(m, hEditOut, buf2)
	return

*BTN_MI
	sel = ListBox_GetSel(m, hLBCL)
	if ( sel == -1 ){
		dialog "クラスが選択されていません"
		return
	}
	buf = ListBox_GetStr(m, hLBCL, sel)
	if ( CSCInstance(cs, buf, cAsm, cObj) == 0 ){
		dialog "インスタンスの作成失敗 [" + buf+"] " +sel
		return
	}
	ret = ListBox_Clear(m, hLBMT)
	len = CSGetMethodList(cObj, listMethod)
	buf2 = "" : buf3 = ""
	repeat len
		buf2 = strf("%s(%s)", listMethod(0, cnt), listMethod(2, cnt))
		buf3 += strf("%s %s\n", listMethod(1, cnt), buf2)
		ret = ListBox_Add(m, hLBMT, cnt, buf2)
	loop
	ret = ListBox_SetSel(m, hLBMT, 0)
	buf3 += strf("成功:%sのインスタンス作成\nメソッド数 : %d", buf, len)
	buf3 += "\n-------------------------------\n"
	ret = MesBox_Add(m, hEditOut, buf3)
	return

*BTN_IV
	sel = ListBox_GetSel(m, hLBMT)
	if ( sel == -1 ){
		dialog "メソッドが選択されていません"
		return
	}
	if ( listMethod(2, sel) != "" ){
		dialog "引数が無いメソッドを選択してください"
		return
	}
	buf = listMethod(0, sel)
	ret = MesBox_Add(m, hEditOut, strf("%s 実行\n", buf))
	ret = CSCall(cObj, buf)
	if ( vartype(ret) == 2 ){ buf = strf("戻り値:%s", ret) }
	else {
		if ( vartype(ret) == 3 ){ buf = strf("戻り値:%f", ret) }
		else { buf = strf("戻り値:%d", ret) }
	}
	buf += "\n-------------------------------\n"
	ret = MesBox_Add(m, hEditOut, buf)
	return
EXE作成
#include "mod_CSharp.hsp"
	src = {"
		using System;
		using System.Windows.Forms;
		class Test1 {
			static void Main(string[] args){
				MessageBox.Show(\"Main()\", \"C#\");
			}
			public void Func1(){
				MessageBox.Show(\"Hello HSP!\", \"C#\");
			}
		}
	"}
	fileName = "CSTest.exe"

	screen 0, 300, 40 : font "メイリオ", 12
	title "mod_CSharp.hsp"
	if ( CSMakeMod(modCS) == 0 ){ dialog "err" : end }
	if ( CSCAddRef(modCS, "System.dll") == 0 ){ dialog "err2" : end }
	if ( CSCAddRef(modCS, "System.Windows.Forms.dll") == 0 ){ dialog "err3" : end }
	if ( CSCMakeWin(modCS, src, fileName) == 0 ){ dialog "err4" : end }
	mes strf("OK %s を作成しました", fileName)
	stop
DLL作成
#include "mod_CSharp.hsp"
	src = {"
		using System;
		using System.Windows.Forms;
		class Test1 {
			static void Main(string[] args){
				MessageBox.Show(\"Main()\", \"C#\");
			}
			public void Func1(){
				MessageBox.Show(\"Hello HSP!\", \"C#\");
			}
		}
	"}
	fileName = "CSTest.dll"

	screen 0, 300, 40 : font "メイリオ", 12
	title "mod_CSharp.hsp"
	if ( CSMakeMod(modCS) == 0 ){ dialog "err" : end }
	if ( CSCAddRef(modCS, "System.dll") == 0 ){ dialog "err2" : end }
	if ( CSCAddRef(modCS, "System.Windows.Forms.dll") == 0 ){ dialog "err3" : end }
	if ( CSCMakeDll(modCS, src, fileName) == 0 ){ dialog "err4" : end }
	mes strf("OK %s を作成しました", fileName)
	stop
DLLをロード
#include "mod_CSharp.hsp"
	moduleName = "CSTest"

	screen 0, 300, 40 : font "メイリオ", 12
	title "mod_CSharp.hsp"
	if ( CSMakeMod(modCS) == 0 ){ dialog "err" : end }
	if ( CSCLoad(modCS, moduleName, cAsm) == 0 ){ dialog "err2" : end }
	if ( CSCInstance(modCS, "Test1", cAsm, cObj) ){
		mes "Test1.Func1()"
		ret = CSCall(cObj, "Func1")
	}
	mes strf("OK %s", moduleName)
	stop
データグリッドビューの作成
#include "user32.as"
#include "mod_CSharp.hsp"
src = {"
using System;
using System.IO;
using System.Data;
using System.Xml;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;
using System.Reflection;

[StructLayout(LayoutKind.Sequential)]
struct COPYDATASTRUCT {
	public IntPtr		dwData;
	public int			cbData;
	public IntPtr       lpData;
}

[StructLayout(LayoutKind.Sequential)]
struct COL_ROW {
	public int colIndex;
	public int rowIndex;
}

class Dgv : Form {
	[DllImport(¥"user32.dll¥", CharSet = CharSet.Auto)]
	public static extern int SendMessage(IntPtr hWnd, int uMsg, IntPtr wParam, ref COPYDATASTRUCT lParam);
	public const int WM_COPYDATA = 0x004A;
	[DllImport(¥"user32.dll¥", CharSet = CharSet.Auto)]
	public static extern int ShowWindow(IntPtr hWnd, int nCmdShow);

	IntPtr          hTarget;
	Thread			thread;
	Form			form;
	DataGridView    dgv;
	BindingSource   bSrc;
	DataTable		table;
	TextBox			textFilter;
	int             rowHeight;
	static string[]	tagNames = {
			¥"index¥", ¥"prm¥", ¥"inst¥", ¥"sample¥", ¥"href¥", ¥"dll¥", ¥"ver¥", ¥"date¥",
			¥"author¥", ¥"url¥", ¥"note¥", ¥"type¥", ¥"group¥", ¥"port¥", ¥"portinfo¥"
	};
	static string[]	colNames = {
			¥"シンボル名¥", ¥"見出し¥", ¥"パラメータリスト¥", ¥"パラメータ説明文¥",
			¥"解説文¥", ¥"サンプルスクリプト¥", ¥"関連項目¥", ¥"使用プラグイン¥",
			¥"バージョン¥", ¥"日付¥", ¥"著作者¥", ¥"関連URL¥", ¥"備考¥", ¥"タイプ¥",
			¥"グループ¥", ¥"対応環境¥", ¥"移植のヒント¥", ¥"hsファイル¥"
	};
	int[] colWidth = {
		120, 200, 200, 200, 200, 200, 100, 100, 100, 100,
		100, 100, 100, 100, 100, 100, 100, 200
	};

	public Dgv(){
		hTarget = IntPtr.Zero;
		rowHeight = 52;
		bSrc = new BindingSource();
		dgv = new DataGridView();
		dgv.ReadOnly = true;
		dgv.MultiSelect = false;
		dgv.AutoGenerateColumns = false;
		dgv.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
		dgv.AllowUserToAddRows = false;
		dgv.BackgroundColor = Color.Snow;
		dgv.RowsDefaultCellStyle.BackColor = Color.Snow;
		dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.LightCyan;
		dgv.EnableHeadersVisualStyles = false;
		dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.LightBlue;
		dgv.RowHeadersDefaultCellStyle.BackColor = Color.LightBlue;
		dgv.DefaultCellStyle.Font = new Font(¥"メイリオ¥", 8);
		dgv.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
		dgv.ColumnHeadersDefaultCellStyle.Font = new Font(¥"メイリオ¥", 9, FontStyle.Bold);
		dgv.RowTemplate.Height = rowHeight;
		dgv.Dock = DockStyle.Fill;
		table = new DataTable(¥"HS¥");
		table.CaseSensitive = false;
		DataColumn col;
		int len = colNames.Length;
		for ( int i = 0; i <  len; i++ ){
			col = new DataColumn(); col.ColumnName = colNames[i]; table.Columns.Add(col);
			DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn();
			c.DataPropertyName = colNames[i]; c.Name = colNames[i]; c.HeaderText = colNames[i]; c.Width = colWidth[i];
			if ( i == 0 ) { c.Frozen = true; }
			dgv.Columns.Add(c);
		}
		dgv.CellMouseClick += Dgv_CellMouseClick;
		dgv.CurrentCellChanged += Dgv_CurrentCellChanged;
//		dgv.DataError += Dgv_DataError;
		form = new Form();
		form.FormBorderStyle = FormBorderStyle.None;
		form.Controls.Add(dgv);
		thread = new Thread(ThreadProc);
		thread.SetApartmentState(ApartmentState.STA);
		thread.Start(form);
	}

	public static void ThreadProc(Object obj){
		Form f = (Form)obj;
		Application.Run(f);
	}

	private void Dgv_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
		DataGridView d = (DataGridView)sender;
		if ( d.Rows.Count == 0 || e.RowIndex == -1 ){ return; }
		if (e.Button == MouseButtons.Middle) {
			if ( d.Rows[e.RowIndex].Height != rowHeight ){
				d.Rows[e.RowIndex].Height = rowHeight;
			}
			else { d.AutoResizeRow(e.RowIndex); }
			return;
		}
	}

	private void Dgv_CurrentCellChanged(object sender, EventArgs e) {
		DataGridView d = (DataGridView)sender;
		IntPtr ptr = IntPtr.Zero;
		if ( hTarget != IntPtr.Zero ) {
			try {
				COPYDATASTRUCT cds = new COPYDATASTRUCT();
				COL_ROW cr;
				cr.colIndex = d.CurrentCellAddress.X;
				cr.rowIndex = d.CurrentCellAddress.Y;
				if ( cr.colIndex != -1 && cr.rowIndex != -1 ){
					ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(COL_ROW)));
					Marshal.StructureToPtr(cr, ptr, false);
					cds.dwData = IntPtr.Zero;
					cds.cbData = Marshal.SizeOf(typeof(COL_ROW));
					cds.lpData = ptr;
					SendMessage(hTarget, WM_COPYDATA, d.Handle, ref cds);
				}
			}
			finally {
				if ( ptr != IntPtr.Zero ){ Marshal.FreeHGlobal(ptr); }
			}
		}
		return;
	}

	private void Dgv_DataError(object sender, DataGridViewDataErrorEventArgs anError){
	}

	int LoadHSFile(string fileName){
		string[] lines = File.ReadAllLines(fileName, System.Text.Encoding.GetEncoding(932));
		if ( lines == null ){ return 0;}
		int numIndex = 0, flag = 0, type = 0, typeTmp;
		string buf = ¥"¥";
		DataRow row = table.NewRow();
		DataRow rowDef = table.NewRow();
		int tagLen = tagNames.Length, len = lines.Length, len2;
		for ( int i = 0; i < len; i++ ){
			len2 = lines[i].Length;
			if ( len2 != 0 && (lines[i][0] == ';' || lines[i] == ¥"^¥" || lines[i] == ¥"^p¥") ){ continue; }
			typeTmp = -1;
			if ( len2 != 0 && lines[i][0] == '%' ){
				for ( int j = 0; j < tagLen; j++ ){
					if ( lines[i].IndexOf(tagNames[j], StringComparison.OrdinalIgnoreCase) == 1 ){
						typeTmp = j; break;
					}
				}
			}
			if ( flag != 0 ){
				if ( typeTmp == -1 && i != (len - 1)){ buf += ¥"¥¥r¥¥n¥" + lines[i]; continue; }
				flag = buf.LastIndexOf('¥¥n');
				if ( flag != -1 ) {
					if ( buf.Length == (flag + 1) ) { buf = buf.Substring(0, flag); }
				}
				switch ( type ){
					case 1: row[colNames[3]] = buf; break;
					case 2: row[colNames[4]] = buf; break;
					case 3: row[colNames[5]] = buf; break;
					case 4: row[colNames[6]] = buf; break;
					case 7: row[colNames[9]] = buf; break;
					case 8: row[colNames[10]] = buf; break;
					case 9: row[colNames[11]] = buf; break;
					case 10: row[colNames[12]] = buf; break;
					case 13: row[colNames[15]] = buf; break;
					case 14: row[colNames[16]] = buf; break;
				}
				flag = 0;
			}
			else if ( typeTmp == -1 ){ continue; }
			type = typeTmp;
			if ( len <= i + 1 ){ break; }
			switch ( type ){
				case 0:
					if ( numIndex == 0 ){ rowDef.ItemArray = row.ItemArray; }
					else {
						table.Rows.Add(row);
						row = table.NewRow();
						row.ItemArray = rowDef.ItemArray;
					}
					if ( len <= i + 2 ){ break; }
					row[colNames[17]] = fileName;
					numIndex++; i++; row[colNames[0]] = lines[i];
					i++; row[colNames[1]] = lines[i];
					break;
				case 1:
					if ( lines[i + 1] == ¥"¥" ){ break; }
					i++; row[colNames[2]] = lines[i]; buf = ¥"¥"; flag = 1;
					break;
				case 2:
				case 3:
				case 4: buf = ¥"¥"; flag = 1; break;
				case 5: i++; row[colNames[7]] = lines[i]; break;
				case 6: i++; row[colNames[8]] = lines[i]; break;
				case 7:
				case 8:
				case 9:
				case 10: buf = ¥"¥"; flag = 1; break;
				case 11: i++; row[colNames[13]] = lines[i]; break;
				case 12: i++; row[colNames[14]] = lines[i]; break;
				case 13:
				case 14:
				case 15: buf = ¥"¥"; flag = 1; break;
			}
		}
		if ( numIndex != 0 ){ table.Rows.Add(row); }
		return numIndex;
	}

	private int LoadHSDir(string dirName){
		int len = 0;
		string[] files = Directory.GetFiles(dirName, ¥"*.hs¥");
		foreach ( string s in files ){
			if ( LoadHSFile(s) != 0 ){ len++; }
		}
		return len;
	}
	private delegate int LoadHSDirDelegate(string dirName);
	public int LoadHS() {
		int ret = 0;
		FolderBrowserDialog folderDlg = new FolderBrowserDialog();
		folderDlg.Description = ¥"hsphelpフォルダを選択してください¥";
		folderDlg.SelectedPath = Directory.GetCurrentDirectory();
		if ( folderDlg.ShowDialog() == DialogResult.OK ) {
			table.Rows.Clear();
			ret = (int)form.Invoke(new LoadHSDirDelegate(LoadHSDir), new object[]{ folderDlg.SelectedPath });
		}
		folderDlg.Dispose();
		if ( ret == 0 ){ return 0; }
		return table.Rows.Count;
	}

	private int SetCell(int col, int row){
		dgv.CurrentCell = dgv[col, row];
		if ( dgv.CurrentCell == null ){ return 0; }
		return 1;
	}

	private int SetSymbolCell_(string key){
		string c;
		key = key.ToLowerInvariant();
		int len = dgv.Rows.Count, i;
		for ( i = 0; i < len; i++ ){
			c = dgv.Rows[i].Cells[0].Value.ToString().ToLowerInvariant();
			if ( c != "" && c == key ){
				dgv.CurrentCell = dgv[0, i];
				return 1;
			}
		}
		return 0;
	}
	private delegate int SetSymbolCellDelegate(string key);
	public int SetSymbolCell(string key) {
		return (int)form.Invoke(new SetSymbolCellDelegate(SetSymbolCell_), new object[]{ key });
	}

	public int GetWnd() {
		return (int)form.Handle;
	}

	public void SetTarget(int hWndTarget) {
		hTarget = (IntPtr)hWndTarget;
	}

	public int GetRows(){
		return table.Rows.Count;
	}

	public int GetRows2(){
		return bSrc.Count;
	}

	public void MoveWnd(int x, int y, int w, int h) {
		dgv.Left = x; dgv.Top = y; dgv.Width = w; dgv.Height = h;
	}

	public int LoadXml_(string fileName) {
		try {
			table.Rows.Clear();
			table.ReadXml(fileName);
		}
		catch {
			return 0;
		}
		bSrc.DataSource = table;
		dgv.DataSource = bSrc;
		return table.Rows.Count;
	}
	private delegate int LoadXmlDelegate(string fileName);
	public int LoadXml(string fileName) {
		return (int)form.Invoke(new LoadXmlDelegate(LoadXml_), new object[]{ fileName });
	}

	public int SaveXml_(string fileName) {
		try {
			table.WriteXml(fileName);
		}
		catch {
			return 0;
		}
		return 1;
	}
	private delegate int SaveXmlDelegate(string fileName);
	public int SaveXml(string fileName) {
		return (int)form.Invoke(new SaveXmlDelegate(SaveXml_), new object[]{ fileName });
	}

	public int SetFilter_(string sFilter) {
		try {
			if ( sFilter == ¥"¥" ) { 
				bSrc.RemoveFilter();
			}
			else {
				bSrc.Filter = sFilter;
			}
		}
		catch { return 0; }
		return bSrc.Count;
	}
	private delegate int SetFilterDelegate(string sFilter);
	public int SetFilter(string sFilter) {
		return (int)form.Invoke(new SetFilterDelegate(SetFilter_), new object[]{ sFilter });
	}

	public string GetSymbol(int rowIndex) {
		if ( rowIndex >= dgv.Rows.Count ) { return ¥"¥"; }
		return dgv.Rows[rowIndex].Cells[0].Value.ToString();
	}

	public string GetData(int rowIndex) {
		string s, s2;
		string sRet = ¥"¥¥r¥¥n¥";
		string sBar = ¥"--------------------------------¥";
		s = String.Format(¥"{2}{0}{3}{0}{0}解説{0}{1}{0}{4}{0}{0}書式{0}{1}{0}{2} {5}{0}{6}¥",
			sRet, sBar,
			dgv.Rows[rowIndex].Cells[0].Value.ToString(),
			dgv.Rows[rowIndex].Cells[1].Value.ToString(),
			dgv.Rows[rowIndex].Cells[4].Value.ToString(),
			dgv.Rows[rowIndex].Cells[2].Value.ToString(),
			dgv.Rows[rowIndex].Cells[3].Value.ToString());
		s2 = dgv.Rows[rowIndex].Cells[5].Value.ToString();
		if ( s2 != ¥"¥" ){ s += String.Format(¥"{0}{0}サンプル{0}{1}{0}{2}¥", sRet, sBar, s2); }
		s2 = dgv.Rows[rowIndex].Cells[6].Value.ToString();
		if ( s2 != ¥"¥" ){ s += String.Format(¥"{0}{0}関連項目{0}{1}{0}{2}¥", sRet, sBar, s2); }
		s2 = dgv.Rows[rowIndex].Cells[7].Value.ToString();
		if ( s2 != ¥"¥" ){ s += String.Format(¥"{0}{0}使用プラグイン{0}{1}{0}{2}¥", sRet, sBar, s2); }
		s2 = dgv.Rows[rowIndex].Cells[15].Value.ToString();
		if ( s2 != ¥"¥" ){ s += String.Format(¥"{0}{0}対応環境{0}{1}{0}{2}¥", sRet, sBar, s2); }
		s2 = dgv.Rows[rowIndex].Cells[16].Value.ToString();
		if ( s2 != ¥"¥" ){ s += String.Format(¥"{0}{0}移植のヒント{0}{1}{0}{2}¥", sRet, sBar, s2); }
		s += String.Format(¥"{0}{0}情報{0}{1}{0}グループ   {2}{0}著作者    {3}{0}作成日    {4}{0}バージョン  {5}{0}備考     {6}{0}URL    {7}{0}タイプ    {8}{0}HSファイル {9}{0}¥",
			sRet, sBar,
			dgv.Rows[rowIndex].Cells[14].Value.ToString(),
			dgv.Rows[rowIndex].Cells[10].Value.ToString(),
			dgv.Rows[rowIndex].Cells[9].Value.ToString(),
			dgv.Rows[rowIndex].Cells[8].Value.ToString(),
			dgv.Rows[rowIndex].Cells[12].Value.ToString(),
			dgv.Rows[rowIndex].Cells[11].Value.ToString(),
			dgv.Rows[rowIndex].Cells[13].Value.ToString(),
			dgv.Rows[rowIndex].Cells[17].Value.ToString());
		return s;
	}
}
"}

	sdim buf, 260
	aRefs = {"
System.dll
System.IO.dll
System.Data.dll
System.Xml.dll
System.Windows.Forms.dll
System.Drawing.dll
System.Runtime.InteropServices.dll
System.Threading.dll
System.Reflection.dll"}

	rowSelTmp = -1 : rowCnt1 = 0 : rowCnt2 = 0
	sdim bufIP, 1024
	sdim bufMB, 1024 * 64
	sdim buf, 1024

	screen 0, ginfo_dispx, ginfo_dispy, 2, -1, -1, 600, 400
	GetWindowLong hwnd, -16
	SetWindowLong hwnd, -16, stat | 0x00050000
	SetWindowPos hwnd, 0, 0, 0, 0, 0, 0x23
	title strf("HSPHelp (%3d/%3d)", rowCnt2, rowCnt1)
	objmode 2 : font "メイリオ", 10
	if ( CSMakeMod(cs) == 0 ){ dialog "err" : end }
	notesel aRefs
	repeat notemax
		noteget buf, cnt
		ret = CSCAddRef(cs, buf)
	loop
	if ( CSCNew(cs, src, "Dgv", cDGV) == 0 ){ dialog "err2" : end }
	v1 = "hsphelp.xml" : exist v1
	if ( strsize != -1 ){ gosub *BTN_LOAD2 }

	hDgv = CSCall(cDGV, "GetWnd")
	SetParent hDgv, hwnd
	GetWindowLong hDgv, -16
	SetWindowLong hDgv, -16, stat | 0x40000000
	MoveWindow hDgv, 0, 0, ginfo_winx, ginfo_winy, 1
	ShowWindow hDgv, 1
	v1 = hwnd : ret = CSCall1(cDGV, "SetTarget", v1)
	input bufIP, 0, 0 : hIP = objinfo(stat, 2)
	objsize 0, 0
	button gosub "Open", *BTN_OPEN : hBtnOpen = objinfo(stat, 2)
	button gosub "Load", *BTN_LOAD : hBtnLoad = objinfo(stat, 2)
	button gosub "Save", *BTN_SAVE : hBtnSave = objinfo(stat, 2)
	mesbox bufMB, 0, 0, 0 : hMB = objinfo(stat, 2)
	oncmd gosub *WM_SIZE,     0x0005
	oncmd gosub *WM_COPYDATA, 0x004a
	oncmd gosub *WM_COMMAND,  0x0111
	gosub *WM_SIZE : gsel 0, 1
	stop

*BTN_OPEN
 	rowCnt1 = CSCall(cDGV, "LoadHS")
 	rowCnt2 = CSCall(cDGV, "GetRows2")
 	title strf("HSPHelp (%3d/%3d)", rowCnt2, rowCnt1)
	rowSelTmp = -1
	return

*BTN_LOAD
	dialog "xml", 16
	if ( stat == 0 ){ return }
	v1 = refstr
*BTN_LOAD2
	rowCnt1 = CSCall1(cDGV, "LoadXml", v1)
 	rowCnt2 = CSCall(cDGV, "GetRows2")
	title strf("HSPHelp (%3d/%3d)", rowCnt2, rowCnt1)
	rowSelTmp = -1
	return

*BTN_SAVE
	dialog "xml", 17
	if ( stat == 0 ){ return }
	v1 = refstr
	ret = CSCall1(cDGV, "SaveXml", v1)
	return

*WM_SIZE
	x = ginfo_winx - 150 : y = (ginfo_winy - 24) / 2
	MoveWindow hIP, 0, 0, x, 24, 1
	MoveWindow hBtnOpen, x, 0, 50, 24, 1
	MoveWindow hBtnLoad, x + 50, 0, 50, 24, 1
	MoveWindow hBtnSave, x + 100, 0, 50, 24, 1
	MoveWindow hMB, 0, 24, ginfo_winx, y, 1
	MoveWindow hDgv, 0, 24 + y, ginfo_winx, y, 1
	return

*WM_COPYDATA
	dupptr dp, lparam, 12, 4
	if ( dp(2) ){
		dupptr dp2, dp(2), 8, 4
		if ( rowSelTmp != dp2(1) ){
			rowSelTmp = dp2(1)
			v1 = dp2(1) : buf = CSCall1(cDGV, "GetData", v1)
			sendmsg hMB, 0x000C, 0, varptr(buf)
		}
	}
	return

*WM_COMMAND
	if ( lparam == hIP ){
		hw = wparam >> 16
		if ( hw == 0x0300 ){
			sendmsg hIP,  0x000D, 1024, varptr(buf)
			v1 = buf
			if ( v1 != "" ){
				v2 = strf("シンボル名 LIKE '*%s*' or 解説文 LIKE '*%s*' or 関連項目 LIKE '*%s*'", v1, v1, v1)
			}
			else { v2 = "" }
			rowCnt2 = CSCall1(cDGV, "SetFilter", v2)
			if ( rowCnt2 ){ ret = CSCall1(cDGV, "SetSymbolCell", v1) }
			title strf("HSPHelp (%3d/%3d)", rowCnt2, rowCnt1)
		}
	}
	return
コメント ( 0 ) | Trackback ( 0 )

mod_CSharp.hsp

mod_CSharp.hsp
#ifndef MOD_CSHARP_HSP_
#define global MOD_CSHARP_HSP_

#include "kernel32.as"
#include "mod_HostCLR.hsp"

#ifndef SysAllocString
#uselib "Oleaut32.dll"
#func global SysAllocString        "SysAllocString"        wstr
#func global SysFreeString         "SysFreeString"         int
#func global VariantInit           "VariantInit"           var
#func global VariantClear          "VariantClear"          var
#func global VariantChangeType     "VariantChangeType"     var,var,int,int
#func global SafeArrayCreate       "SafeArrayCreate"       int,int,var
#func global SafeArrayCreateVector "SafeArrayCreateVector" int,int,int
#func global SafeArrayDestroy      "SafeArrayDestroy"      int
#func global SafeArrayAccessData   "SafeArrayAccessData"   int,var
#func global SafeArrayUnaccessData "SafeArrayUnaccessData" int
#func global SafeArrayGetElement   "SafeArrayGetElement"   int,var,var
#func global SafeArrayPutElement   "SafeArrayPutElement"   int,var,var
#func global SafeArrayPutElementP  "SafeArrayPutElement"   int,var,int
#endif

#ifndef IUnknown
#define global IID_IUnknown "{00000000-0000-0000-C000-000000000046}"
#usecom global IUnknown IID_IUnknown "{}"
#comfunc global IUnknown_QueryInterface  0 var,var
#comfunc global IUnknown_AddRef          1
#comfunc global IUnknown_Release         2
#endif

#ifndef IDispatch
#define global IID_IDispatch "{00020400-0000-0000-C000-000000000046}"
#usecom global IDispatch IID_IDispatch "{}"
#comfunc global IDispatch_QueryInterface    0 var,var
#comfunc global IDispatch_AddRef            1
#comfunc global IDispatch_Release           2
#comfunc global IDispatch_GetTypeInfoCount  3 var
#comfunc global IDispatch_GetTypeInfo       4 int,int,int
#comfunc global IDispatch_GetIDsOfNames     5 var,var,int,int,var
#comfunc global IDispatch_Invoke            6 int,var,int,int,var,int,int,int
#endif

#ifndef IEnumUnknown
#define global IID_IEnumUnknown "{00000100-0000-0000-C000-000000000046}"
#usecom global IEnumUnknown IID_IEnumUnknown "{}"
#comfunc global IEnumUnknown_Next   3 int,var,int
#comfunc global IEnumUnknown_Skip   4 int
#comfunc global IEnumUnknown_Reset  5
#comfunc global IEnumUnknown_Clone  6 var
#endif

#module mod_CSharp mCor, mApp, mCSPrm, mCSCode

#modinit str sVer, str sPath, str sPath2
	mCor = 0 : mApp = 0 : mCSPrm = 0 : mCSCode = 0
	dim mi, 16
	mi(0) = 0xcb2f6723, 0x11d2ab3a, 0xc000409c, 0x3e0aa34f
	mi(4) = 0xcb2f6722, 0x11d2ab3a, 0xc000409c, 0x3e0aa34f
	if ( sVer == "" ){ mi(8) = 0 }
	else { sdim buf, (strlen(sVer) + 1) * 2 : cnvstow buf, sVer : mi(8) = varptr(buf) }
	CorBindToRuntimeEx mi(8), 0, 3, mi, mi(4), mi(9)
	if ( stat >= 0 ){
		newcom mCor, ICorRuntimeHost, -1, mi(9) : ICorRuntimeHost_Start mCor : ICorRuntimeHost_CreateDomainSetup mCor, mi(8)
		if ( stat == 0 ){
			lNumAppp++ : newcom cMI1, AppDomainSetup, -1, mi(8)
			if ( sPath != "" ){
				SysAllocString sPath : mi(9) = stat : AppDomainSetup_SetApplicationBase cMI1, mi(9) : SysFreeString mi(9)
			}
			if ( sPath2 != "" ){
				SysAllocString sPath2 : mi(9) = stat : AppDomainSetup_SetPrivateBinPath cMI1, mi(9) : SysFreeString mi(9)
			}
			ICorRuntimeHost_CreateDomainEx mCor, "AppDomain" + lNumAppp, mi(8), 0, mi(10)
			if ( stat == 0 ){ newcom mApp, _AppDomain, -1, mi(10) }
			delcom cMI1
		}
	}
	buf = CSGetSysDir() + "System.dll"
	buf2 = "System.CodeDom.Compiler.CompilerParameters"
	if ( CSCNewObj(thismod, buf, buf2, mCSPrm) == 0 ){ return 0 }
	buf2 = "Microsoft.CSharp.CSharpCodeProvider"
	if ( CSCNewObj(thismod, buf, buf2, mCSCode) == 0 ){ return 0 }
	return 1

#modterm
	if ( vartype(mCSCode) == 6 ){ if ( varuse(mCSCode) ){ delcom mCSCode } }
	if ( vartype(mCSPrm) == 6 ){ if ( varuse(mCSPrm) ){ delcom mCSPrm } }
	if ( vartype(mCOR) == 6 ){ if ( varuse(mCOR) ){
		if ( vartype(mApp) == 6 ){ 	if ( varuse(mApp) ){ dupptr dpMI, varptr(mApp), 4, 4 : ICorRuntimeHost_UnloadDomain mCOR, dpMI : delcom mApp } }
		ICorRuntimeHost_Stop mCOR : delcom mCOR
	} }
	return

#modcfunc CSCNewObj str sFile, str sType, var cObj
	if ( vartype(mApp) != 6 ){ return 0 }
	if ( varuse(mApp) == 0 ){ return 0 }
	dim no, 8 : SysAllocString sFile : no(1) = stat : SysAllocString sType : no(2) = stat
	_AppDomain_CreateInstanceFrom mApp, no(1), no(2), no(3)
	if ( stat == 0 ){
		newcom cNO1, _ObjectHandle, -1, no(3) : no(4) = 0, 0, 0, 0 : _ObjectHandle_Unwrap cNO1, no(4)
		if ( stat == 0 ){
			if ( no(4) == 13 ){ newcom cNO2, IUnknown, -1, no(6) }
			else { if ( no(4) == 9 ){ newcom cNO2, IDispatch, -1, no(6) } }
			if ( no(4) == 9 || no(4) == 13 ){ querycom cObj, cNO2, _Object : if ( varuse(cObj) ){ no(0) = 1 } delcom cNO2 }
		}
		delcom cNO1
	}
	SysFreeString no(1) : SysFreeString no(2)
	if ( no(0) == 0 ){ return 0 }
	dupptr dpNO, varptr(cObj), 4, 4
	return dpNO

#modcfunc CSCSetTarget str sTarget
	dim stg, 4
	buf = CSGetProp(mCSPrm, "CompilerOptions")
	if ( vartype(buf) == 2 ){ stg = instr(buf, 0, "/target") : if ( stg == -1 ){ stg = instr(buf, 0, "/TARGET") } }
	else { stg = -1 : buf = "" }
	if ( stg != -1 ){
		stg(1) = stg + 7 : stg(2) = instr(buf, stg(1), "/")
		if ( stg(2) == -1 ){ buf2 = strmid(buf, 0, stg) }
		else { buf2 = strmid(buf, 0, stg) + " " : stg(3) = stg(1) + stg(2) : buf2 += strmid(buf, stg(3), strlen(buf) - stg(3)) }
	}
	else { buf2 = buf }
	stg = strlen(buf2)
	if ( stg ){ if ( peek(buf2, stg - 1) != ' ' ){ buf2 += " " } }
	buf2 += sTarget
	return CSCSetOption(thismod, buf2)

#modcfunc CSCGetOption
	return CSGetProp(mCSPrm, "CompilerOptions")

#modcfunc CSCSetOption str sData
	return CSSetPropStr(mCSPrm, "CompilerOptions", sData)

#modcfunc CSCGetGenExe
	return CSGetProp(mCSPrm, "GenerateExecutable")

#modcfunc CSCSetGenExe int bGen
	return CSSetProp2(mCSPrm, "GenerateExecutable", 11, bGen)

#modcfunc CSCGetGenMem
	return CSGetProp(mCSPrm, "GenerateInMemory")

#modcfunc CSCSetGenMem int bGen
	return CSSetProp2(mCSPrm, "GenerateInMemory", 11, bGen)

#modcfunc CSCGetIncDebugInfo
	return CSGetProp(mCSPrm, "IncludeDebugInformation")

#modcfunc CSCSetIncDebugInfo int bGen
	return CSSetProp2(mCSPrm, "IncludeDebugInformation", 11, bGen)

#modcfunc CSCGetMainClass
	return CSGetProp(mCSPrm, "MainClass")

#modcfunc CSCSetMainClass str sData
	return CSSetPropStr(mCSPrm, "MainClass", sData)

#modcfunc CSCGetOutputAsm
	return CSGetProp(mCSPrm, "OutputAssembly")

#modcfunc CSCSetOutputAsm str sData
	return CSSetPropStr(mCSPrm, "OutputAssembly", sData)

#modcfunc CSCGetWarnAsErr
	return CSGetProp(mCSPrm, "TreatWarningsAsErrors")

#modcfunc CSCSetWarnAsErr int bGen
	return CSSetProp2(mCSPrm, "TreatWarningsAsErrors", 11, bGen)

#modcfunc CSCGetWarnLv
	return CSGetProp(mCSPrm, "WarningLevel")

#modcfunc CSCSetWarnLv int nLevel
	return CSSetProp2(mCSPrm, "WarningLevel", 3, nLevel)

#modcfunc CSCRefInit var cObj
	dim ri, 5
	ri(4) = 0
	if ( CSGetProp3(mCSPrm, "ReferencedAssemblies", 0, ri) ){
		if ( ri == 13 ){ newcom cRI1, IUnknown, -1, ri(2) : querycom cObj, cRI1, _Object : if ( varuse(cObj) ){ ri(4) = 1 } else { delcom cObj } delcom cRI1 }
	}
	return ri(4)

#modcfunc CSCGetRef array aRef
	dim gr, 10
	if ( CSCRefInit(thismod, cGR1) == 0 ){ return 0 }
	if ( CSGetProp3(cGR1, "Count", 0, gr) ){
		SafeArrayCreateVector 12, 0, 1 : gr(4) = stat : gr(5) = 3, 0 : sdim aRef, 64, gr(2)
		repeat gr(2)
			gr(7) = cnt : SafeArrayPutElement gr(4), gr(6), gr(5)
			if ( CSGetProp3(cGR1, "Item", gr(4), gr) ){ if ( gr == 8 ){ aRef(cnt) = CSCCnvBstr(gr(2)) : gr(9)++ } }
		loop
		SafeArrayDestroy gr(4)
	}
	delcom cGR1
	return gr(9)

#modcfunc CSCAddRef str sData
	dim ar, 6
	if ( CSCRefInit(thismod, cAR1) == 0 ){ return 0 }
	SafeArrayCreateVector 12, 0, 1 : ar = stat
	SysAllocString sData : ar(1) = 8, 0, stat, 0
	SafeArrayPutElement ar, ar(5), ar(1)
	ar(1) = CSInvoke(cAR1, "Add", 28, 0, ar, ar(2))
	SafeArrayDestroy ar : delcom cAR1
	if ( ar(1) == 0 ){ return 0 }
	return 1

#modcfunc CSCClearRef
	if ( CSCRefInit(thismod, cCR1) == 0 ){ return 0 }
	dim cr, 5
	cr(4) = CSInvoke(cCR1, "Clear", 28, 0, 0, cr)
	delcom cCR1
	if ( cr(4) == 0 ){ return 0 }
	return 1

#modcfunc CSCl2 str sSrc, var cAsm, var cObjErr
	dim cle, 13
	SafeArrayCreateVector 12, 0, 2 : cle(1) = stat
	if ( cle(1) ){
		dupptr dpCSCL, varptr(mCSPrm), 4, 4 : cle(2) = 0, 13, 0, dpCSCL, 0 : SafeArrayPutElement cle(1), cle(2), cle(3) : SafeArrayCreateVector 8, 0, 1 : cle(7) = stat
		if ( cle(7) ){
			SysAllocString sSrc : cle(8) = stat : SafeArrayPutElementP cle(7), cle(2), cle(8) : cle(2) = 1, 0x2008, 0, cle(7) : SafeArrayPutElement cle(1), cle(2), cle(3) : cle = CSInvoke(mCSCode, "CompileAssemblyFromSource", 28, 0, cle(1), cle(9)) : SysFreeString cle(8) : SafeArrayDestroy cle(7)
			if ( cle ){
				newcom cCSCL1, IUnknown, -1, cle(11) : querycom cObjErr, cCSCL1, _Object
				if ( varuse(cObjErr) == 0 ){ cle = 0 }
				else { if ( CSCErrLen(thismod, cObjErr) == 0 ){ if ( CSGetProp3(cObjErr, "CompiledAssembly", 0, cle(2)) ){ if ( cle(2) == 9 ){ newcom cAsm, _Assembly, -1, cle(4) } if ( cle(2) == 13 ){ newcom cCSCL2, IUnknown, -1, cle(4) : querycom cAsm, cCSCL2, _Assembly : delcom cCSCL2 } } } }
				delcom cCSCL1
			}
		}
		SafeArrayDestroy cle(1)
	}
	return cle

#modcfunc CSCl str sSrc, var cAsm
	cle = CSCl2(thismod, sSrc, cAsm, cSC) : delcom cSC
	return cle

#modcfunc CSCMakeDll2 str sSrc, str sFile, var cObj, var cObjErr
	if ( CSCSetTarget(thismod, "/target:library") == 0 ){ return 0 }
	if ( CSCSetGenExe(thismod, 0) == 0 ){ return 0 }
	if ( CSCSetGenMem(thismod, 1) == 0 ){ return 0 }
	if ( CSCSetOutputAsm(thismod, sFile) == 0 ){ return 0 }
	if ( CSCl2(thismod, sSrc, cObj, cObjErr) == 0 ){ return 0 }
	if ( CSCErrLen(thismod, cObjErr) != 0 ){ return 0 }
	return 1

#modcfunc CSCMakeDll str sSrc, str sFile
	md = CSCMakeDLL2(thismod, sSrc, sFile, cMD1, cMD2) : cMD2 = 0 : cMD1 = 0
	return md

#modcfunc CSCMakeWin2 str sSrc, str sFile, var cObj, var cObjErr
	if ( CSCSetTarget(thismod, "/target:winexe") == 0 ){ return 0 }
	if ( CSCSetGenExe(thismod, 1) == 0 ){ return 0 }
	if ( CSCSetGenMem(thismod, 1) == 0 ){ return 0 }
	if ( CSCSetOutputAsm(thismod, sFile) == 0 ){ return 0 }
	if ( CSCl2(thismod, sSrc, cObj, cObjErr) == 0 ){ return 0 }
	if ( CSCErrLen(thismod, cObjErr) != 0 ){ return 0 }
	return 1

#modcfunc CSCMakeWin str sSrc, str sFile
	mw = CSCMakeWin2(thismod, sSrc, sFile, cMW1, cMW2) : cMW2 = 0 : cMW1 = 0
	return mw

#modcfunc CSCMakeCon2 str sSrc, str sFile, var cObj, var cObjErr
	if ( CSCSetTarget(thismod, "/target:exe") == 0 ){ return 0 }
	if ( CSCSetGenExe(thismod, 1) == 0 ){ return 0 }
	if ( CSCSetGenMem(thismod, 1) == 0 ){ return 0 }
	if ( CSCSetOutputAsm(thismod, sFile) == 0 ){ return 0 }
	if ( CSCl2(thismod, sSrc, cObj, cObjErr) == 0 ){ return 0 }
	if ( CSCErrLen(thismod, cObjErr) != 0 ){ return 0 }
	return 1

#modcfunc CSCMakeCon str sSrc, str sFile
	mc = CSCMakeCon2(thismod, sSrc, sFile, cMC1, cMC2) : cMC2 = 0 : cMC1 = 0
	return mc

#modcfunc CSCErrInit str sName, var cObjErr, var cObj
	if ( vartype(cObjErr) != 6 ){ return 0 }
	if ( varuse(cObjErr) == 0 ){ return 0 }
	dim ei, 5
	if ( CSGetProp3(cObjErr, sName, 0, ei) ){ if ( ei == 13 ){ newcom cEI1, IUnknown, -1, ei(2) : querycom cObj, cEI1, _Object : if ( varuse(cObj) ){ ei(4) = 1 } else { delcom cObj } delcom cEI1 } }
	return ei(4)

#modcfunc CSCErrLen var cObjErr
	if ( CSCErrInit(thismod, "Errors", cObjErr, cEL1) == 0 ){ return -1 }
	dim el, 5 : el(4) = CSGetProp3(cEL1, "Count", 0, el) : delcom cEL1
	if ( el(4) == 0 ){ VariantClear el : return -1 }
	return el(2)

#modcfunc CSCErrList var cObjErr, array aErrList
	sdim aErrList, 64, 5, 1
	if ( CSCErrInit(thismod, "Errors", cObjErr, cELT1) == 0 ){ return 0 }
	dim elt, 10
	if ( CSGetProp3(cELT1, "Count", 0, elt) ){
		sdim aErrList, 64, 5, elt(2) : SafeArrayCreateVector 12, 0, 1 : elt(4) = stat : elt(5) = 3, 0
		repeat elt(2)
			elt(7) = cnt : SafeArrayPutElement elt(4), elt(6), elt(5)
			if ( CSGetProp3(cELT1, "Item", elt(4), elt) ){
				if ( elt == 13 ){
					newcom cELT2, IUnknown, -1, elt(2) : querycom cELT3, cELT2, _Object
					if ( varuse(cELT3) ){
						aErrList(0, cnt) = CSGetProp(cELT3, "FileName") : aErrList(1, cnt) = str(CSGetProp(cELT3, "Column"))
						aErrList(2, cnt) = str(CSGetProp(cELT3, "Line")) : aErrList(3, cnt) = CSGetProp(cELT3, "ErrorNumber")
						aErrList(4, cnt) = CSGetProp(cELT3, "ErrorText") : elt(9)++ : delcom cELT3
					}
					delcom cELT3 : delcom cELT2
				}
			}
		loop
		SafeArrayDestroy elt(4)
	}
	delcom cELT1
	return elt(9)

#modcfunc CSCErrOutput var cObjErr, var sOutput
	if ( CSCErrInit(thismod, "Output", cObjErr, cEOP1) == 0 ){ return 0 }
	sOutput = "" : dim eop, 10
	if ( CSGetProp3(cEOP1, "Count", 0, eop) ){
		SafeArrayCreateVector 12, 0, 1 : eop(4) = stat : eop(5) = 3, 0
		repeat eop(2)
			eop(7) = cnt : SafeArrayPutElement eop(4), eop(6), eop(5)
			if ( CSGetProp3(cEOP1, "Item", eop(4), eop) ){
				if ( eop == 8 ){ sOutput += strf("%s¥n", CSCCnvBstr(eop(2))) : eop(9)++ }
			}
		loop
		SafeArrayDestroy eop(4)
	}
	delcom cEOP1
	return eop(9)

#modcfunc CSCLoad str sAsm, var cAsm
	dim cld, 3
	SysAllocString sAsm : cld = stat
	_AppDomain_Load_2 mApp, cld, cld(1) : cld(2) = stat
	if ( cld(2) == 0 ){ if ( cld(1) == 0 ){ cld(2) = -1 } }
	if ( cld(2) == 0 ){ newcom cAsm, _Assembly, -1, cld(1) }
	SysFreeString cld
	if ( cld(2) ){ return 0 }
	return 1

#modcfunc CSCInstance str sName, var cAsm, var cObj
	if ( vartype(cAsm) != 6 ){ return 0 }
	if ( varuse(cAsm) == 0 ){ return 0 }
	dim cit, 6 : SysAllocString sName : cit = stat
	_Assembly_CreateInstance cAsm, cit, cit(1) : cit(5) = stat
	if ( cit(5) == 0 ){ newcom cObj, _Object, -1, cit(3) }
	SysFreeString cit
	if ( cit(5) ){ return 0 }
	return 1

#modcfunc CSCNew str sSrc, str sName, var cObj
	if ( CSCSetTarget(thismod, "") == 0 ){ return 0 }
	if ( CSCSetGenExe(thismod, 0) == 0 ){ return 0 }
	if ( CSCSetGenMem(thismod, 1) == 0 ){ return 0 }
	if ( CSCSetOutputAsm(thismod, "") == 0 ){ return 0 }
	if ( CSCl2(thismod, sSrc, cNEW1, cNEW2) == 0 ){ return 0 }
	nw = 0
	if ( CSCErrLen(thismod, cNEW2) == 0 ){ if ( CSCInstance(thismod, sName, cNEW1, cObj) ){ nw = 1 } : delcom cNEW1 }
	delcom cNEW2
	return nw

#defcfunc CSMakeMod var modCS
#ifndef _debug
	newmod modCS, mod_CSharp, CSGetNewVer(), "", ""
	return stat
#else
	newmod modCS, mod_CSharp, CSGetNewVer(), dir_cur, ""
	return stat
#endif

#defcfunc CSCCnvBstr int pBstr
	lstrlenW pBstr : dupptr dpCVB, pBstr, (stat + 1) * 2, 2 : bufCVB = cnvwtos(dpCVB) : SysFreeString pBstr
	return bufCVB

#defcfunc CSCGetType var cObj, var cType
	if ( vartype(cObj) != 6 ){ return 0 }
	if ( varuse(cObj) == 0 ){ return 0 }
	gt = 0 : _Object_GetType cObj, gt
	if ( stat ){ return 0 }
	newcom cType, _Type, -1, gt
	return 1

#defcfunc CSPropInit var cObj, str sName, var cProp
	if ( CSCGetType(cObj, cGS1) == 0 ){ return 0 }
	dim gs, 3 : SysAllocString sName : gs = stat
	_Type_GetProperty_7 cGS1, gs, gs(1) : gs(2) = stat
	SysFreeString gs
	if ( gs(2) != 0 || gs(1) == 0 ){ delcom cGS1 : return 0 }
	newcom cProp, _PropertyInfo, -1, gs(1)
	delcom cGS1 : dupptr dpGS, varptr(cObj), 4, 4
	return dpGS

#defcfunc CSGetProp3 var cObj, str sName, int psaId, var vProp
	gs2 = CSPropInit(cObj, sName, cGS2)
	if ( gs2 ){ _PropertyInfo_GetValue cGS2, 13, 0, gs2, 0, psaId, vProp : gs2 = stat : delcom cGS2 }
	if ( gs2 ){ return 0 }
	return 1

#defcfunc CSGetProp2 var cObj, str sName, var vProp
	return CSGetProp3(cObj, sName, 0, vProp)

#defcfunc CSGetPropA var cObj, str sName, array aProp
	dim gs3, 6
	if ( CSGetProp3(cObj, sName, 0, gs3) == 0 ){ return 0 }
	if ( gs3 != 27 ){ VariantClear gs3 : return 0 }
	dupptr dpGS, gs3(2), 24, 4 : gs3(4) = dpGS(4)
	if ( dpGS >> 16 != 1 || dpGS(1) != 16 ){ SafeArrayDestroy gs3(2) : return 0 }
	SafeArrayAccessData gs3(2), gs3(5)
	dupptr dpGS, gs3(5), gs3(4) * 16, 4
	if ( dpGS == 8 ){ sdim aProp, 64, gs3(4) : repeat gs3(4) : aProp(cnt) = CSCCnvBstr(dpGS(cnt * 4 + 2)) : loop }
	else {
		if ( dpGS == 5 ){ ddim aProp, gs3(4) : repeat gs3(4) : dupptr dpGS2, varptr(dpGS(cnt * 4 + 2)), 8, 3 : aProp(cnt) = dpGS2 : loop }
		else { dim aProp, gs3(4) : repeat gs3(4) : aProp(cnt) = dpGS(cnt * 4 + 2) : loop }
	}
	SafeArrayUnaccessData gs3(2) : SafeArrayDestroy gs3(2)
	return gs3(4)

#defcfunc CSGetProp var cObj, str sName
	dim gs3, 4
	if ( CSGetProp3(cObj, sName, 0, gs3) == 0 ){ return 0 }
	if ( gs3 == 8 ){ return CSCCnvBstr(gs3(2)) }
	if ( gs3 == 5 ){ dupptr dpGS, varptr(gs3(2)), 8, 3 : return dpGS }
	return gs3(2)

#defcfunc CSSetProp3 var cObj, str sName, int psaId, var vProp
	gs2 = CSPropInit(cObj, sName, cGS2)
	if ( gs2 == 0 ){ return 0 }
	dupptr dpGS, varptr(vProp), 16, 4
	_PropertyInfo_SetValue cGS2, 13, 0, gs2, 0, dpGS(0), dpGS(1), dpGS(2), dpGS(3), psaId
	gs2 = stat : delcom cGS2
	if ( gs2 ){ return 0 }
	return 1

#defcfunc CSSetProp2 var cObj, str sName, int iVT, int iProp
	gs3 = iVT, 0, iProp, 0
	return CSSetProp3(cObj, sName, 0, gs3)

#defcfunc CSSetProp var cObj, str sName, var vProp
	dim gs3, 6 : gs3(4) = vartype(vProp)
	if ( gs3(4) == 2 ){ SysAllocString vProp : gs3(2) = stat : gs3 = 8 }
	else { if ( gs3(4) == 3 ){ gs3 = 4 : dupptr dpGS, varptr(gs3(2)), 8, 3 : dpGS = vProp } else { gs3 = 3 : gs3(2) = vProp } }
	gs3(5) = CSSetProp3(cObj, sName, 0, gs3)
	if ( gs3(4) == 2 ){ SysFreeString gs3(2) }
	return gs3(5)

#defcfunc CSSetPropStr var cObj, str sName, str sProp
	dim gs3, 5 : SysAllocString sProp : gs3 = 8, 0, stat, 0 : gs3(4) = CSSetProp3(cObj, sName, 0, gs3) : SysFreeString gs3(2)
	return gs3(4)

#defcfunc CSFieldInit var cObj, str sName, var cField
	if ( CSCGetType(cObj, cGS1) == 0 ){ return 0 }
	dim gs, 10 : SysAllocString sName : gs = stat : _Type_GetField_2 cGS1, gs, gs(1) : gs(2) = stat : SysFreeString gs
	if ( gs(2) != 0 || gs(1) == 0 ){ delcom cGS1 : return 0 }
	newcom cField, _FieldInfo, -1, gs(1) : delcom cGS1 : dupptr dpGS, varptr(cObj), 4, 4
	return dpGS

#defcfunc CSGetField2 var cObj, str sName, var vField
	gs2 = CSFieldInit(cObj, sName, cGS2)
	if ( gs2 == 0 ){ return 0 }
	_FieldInfo_GetValue cGS2, 13, 0, gs2, 0, vField : gs2 = stat : delcom cGS2
	if ( gs2 ){ return 0 }
	return 1

#defcfunc CSGetFieldA var cObj, str sName, array aField
	dim gs3, 6
	if ( CSGetField2(cObj, sName, gs3) == 0 ){ return 0 }
	if ( gs3 != 27 ){ VariantClear gs3 : return 0 }
	dupptr dpGS, gs3(2), 24, 4 : gs3(4) = dpGS(4)
	if ( dpGS >> 16 != 1 || dpGS(1) != 16 ){ SafeArrayDestroy gs3(2) : return 0 }
	SafeArrayAccessData gs3(2), gs3(5) : dupptr dpGS, gs3(5), gs3(4) * 16, 4
	if ( dpGS == 8 ){ sdim aField, 64, gs3(4) : repeat gs3(4) : aField(cnt) = CSCCnvBstr(dpGS(cnt * 4 + 2)) : loop }
	else {
		if ( dpGS == 5 ){ ddim aField, gs3(4) : repeat gs3(4) : dupptr dpgs3, varptr(dpGS(cnt * 4 + 2)), 8, 3 : aField(cnt) = dpgs3 : loop }
		else { dim aField, gs3(4) : repeat gs3(4) : aField(cnt) = dpGS(cnt * 4 + 2) : loop }
	}
	SafeArrayUnaccessData gs3(2) : SafeArrayDestroy gs3(2)
	return 1

#defcfunc CSGetField var cObj, str sName
	dim gs3, 3
	if ( CSGetField2(cObj, sName, gs3) == 0 ){ return 0 }
	if ( gs3 == 8 ){ return CSCCnvBstr(gs3(2)) }
	else {
		if ( gs3 == 5 ){ dupptr dpGS, varptr(gs3(2)), 8, 3 : return dpGS }
		else { return gs3(2) }
	}
	return 1

#defcfunc CSSetField3 var cObj, str sName, var vField
	gs2 = CSFieldInit(cObj, sName, cGS2)
	if ( gs2 == 0 ){ return 0 }
	dupptr dpGS, varptr(vField), 16, 4 : _FieldInfo_SetValue_2 cGS2, 13, 0, gs2, 0, dpGS(0), dpGS(1), dpGS(2), dpGS(3) : gs2 = stat : delcom cGS2
	if ( gs2 ){ return 0 }
	return 1

#defcfunc CSSetField2 var cObj, str sName, int iVT, int iField
	gs3 = iVT, 0, iField, 0
	return CSSetField3(cObj, sName, gs3)

#defcfunc CSSetField var cObj, str sName, var vField
	dim gs3, 6 : gs3(4) = vartype(vField)
	if ( gs3(4) == 2 ){ SysAllocString vField : gs3(2) = stat : gs3 = 8 }
	else {
		if ( gs3(4) == 3 ){ gs3 = 4 : dupptr dpGS, varptr(gs3(2)), 8, 3 : dpGS = vField }
		else { gs3 = 3 : gs3(2) = vField }
	}
	gs3(5) = CSSetField3(cObj, sName, gs3)
	if ( gs3(4) == 2 ){ SysFreeString gs3(2) }
	return gs3(5)

#defcfunc CSSetFieldStr var cObj, str sName, str sField
	SysAllocString sField : gs3 = 8, 0, stat, 0 : gs3(4) = CSSetField3(cObj, sName, gs3) : SysFreeString gs3(2)
	return gs3(4)

#defcfunc CSInvoke var cObj, str sName, int fBind, int psaTypes, int psaArgs, var vRet
	if ( CSCGetType(cObj, cIV1) == 0 ){ return 0 }
	dim iv, 12 : SysAllocString sName : iv(0) = stat
	if ( psaTypes ){ _Type_GetMethod cIV1, iv(0), fBind, 0, psaTypes, 0, iv(1) }
	else { _Type_GetMethod_2 cIV1, iv(0), fBind, iv(1) }
	iv(2) = stat
	if ( iv(2) == 0 ){ if ( iv(1) == 0 ){ iv(2) = -1 } }
	if ( iv(2) == 0 ){
		newcom cIV2, _MethodInfo, -1, iv(1) : dupptr dpIV, varptr(cObj), 4, 4
		_MethodInfo_Invoke_3 cIV2, 13, 0, dpIV, 0, psaArgs, vRet : iv(2) = stat : delcom cIV2
	}
	delcom cIV1
	if ( iv(2) ){ return 0 }
	return 1

#defcfunc CSMakeArgs var vArgs, int iNum
	dim ma, iNum * 4 + 4 : dupptr dpMA, varptr(vArgs), iNum * 8, 4
	repeat iNum
		ma = dpMA(cnt * 2), dpMA(cnt * 2 + 1)
		if ( ma == 2 ){ lstrlenA ma(1) : dupptr dpMA2, ma(1), stat + 1, 2 : SysAllocString dpMA2 : ma(cnt * 4 + 4) = 8, 0, stat, 0 }
		else {
			if ( ma == 3 ){ ma(cnt * 4 + 4) = 5, 0 : dupptr dpMA2, ma(1), 8, 3 : dupptr dpMA3, varptr(ma(cnt * 4 + 6)), 8, 3 : dpMA3 = dpMA2 }
			else { dupptr dpMA2, ma(1), 4, 4 : ma(cnt * 4 + 4) = 3, 0, dpMA2, 0 }
		}
	loop
	ma = iNum * 16 : dupptr dpMA, varptr(ma(4)), ma, 4 : SafeArrayCreateVector 12, 0, iNum : ma(1) = stat
	if ( ma(1) ){
		ma(3) = 1 : SafeArrayAccessData ma(1), ma(2)
		if ( stat == 0 ){ dupptr dpMA2, ma(2), ma, 4 : memcpy dpMA2, dpMA, ma : SafeArrayUnaccessData ma(1) }
		else { ma(3) = 0 }
	}
	if ( ma(3) == 0 ){
		repeat iNum : VariantClear dpMA(cnt * 4) : loop
		return 0
	}
	return ma(1)

#defcfunc CSCallRet var vRet
	dupptr dpCR, varptr(vRet), 16, 4
	if ( dpCR == 8 ){ return CSCCnvBstr(dpCR(2)) }
	else { if ( dpCR == 5 ){ dupptr dpCR2, varptr(dpCR(2)), 8, 3 : return dpCR2 } else{ return dpCR(2) } }
	return 0

#defcfunc CSCall var cObj, str sName
	dim cl, 4
	if ( CSInvoke(cObj, sName, 28, 0, 0, cl) == 0 ){ return 0 }
	vaRet = CSCallRet(cl) : VariantClear cl
	return vaRet

#defcfunc CSCall1 var cObj, str sName, var v1
	dim cl2, 8 : cl2(6) = vartype(v1), varptr(v1) : cl2(4) = CSMakeArgs(cl2(6), 1)
	if ( cl2(4) == 0 ){ return 0 }
	cl2(5) = CSInvoke(cObj, sName, 28, 0, cl2(4), cl2)
	if ( cl2(5) ){ vaRet = CSCallRet(cl2) : Variantclear cl2 }
	SafeArrayDestroy cl2(4)
	if ( cl2(5) == 0 ){ return 0 }
	return vaRet

#defcfunc CSCall2 var cObj, str sName, var v1, var v2
	dim cl2, 10
	cl2(6) = vartype(v1), varptr(v1), vartype(v2), varptr(v2) : cl2(4) = CSMakeArgs(cl2(6), 2)
	if ( cl2(4) == 0 ){ return 0 }
	cl2(5) = CSInvoke(cObj, sName, 28, 0, cl2(4), cl2)
	if ( cl2(5) ){ vaRet = CSCallRet(cl2) : Variantclear cl2 }
	SafeArrayDestroy cl2(4)
	if ( cl2(5) == 0 ){ return 0 }
	return vaRet

#defcfunc CSCall3 var cObj, str sName, var v1, var v2, var v3
	dim cl2, 12
	cl2(6) = vartype(v1), varptr(v1), vartype(v2), varptr(v2), vartype(v3), varptr(v3)
	cl2(4) = CSMakeArgs(cl2(6), 3)
	if ( cl2(4) == 0 ){ return 0 }
	cl2(5) = CSInvoke(cObj, sName, 28, 0, cl2(4), cl2)
	if ( cl2(5) ){ vaRet = CSCallRet(cl2) : Variantclear cl2 }
	SafeArrayDestroy cl2(4)
	if ( cl2(5) == 0 ){ return 0 }
	return vaRet

#defcfunc CSCall4 var cObj, str sName, var v1, var v2, var v3, var v4
	dim cl2, 14
	cl2(6) = vartype(v1), varptr(v1), vartype(v2), varptr(v2), vartype(v3), varptr(v3), vartype(v4), varptr(v4)
	cl2(4) = CSMakeArgs(cl2(6), 4)
	if ( cl2(4) == 0 ){ return 0 }
	cl2(5) = CSInvoke(cObj, sName, 28, 0, cl2(4), cl2)
	if ( cl2(5) ){ vaRet = CSCallRet(cl2) : Variantclear cl2 }
	SafeArrayDestroy cl2(4)
	if ( cl2(5) == 0 ){ return 0 }
	return vaRet

#defcfunc CSGetClassList var cAsm, array aList
	sdim aList, 64, 1 : dim gmd, 4
	_Assembly_GetTypes cAsm, gmd : gmd(1) = stat
	if ( gmd(1) == 0 && gmd != 0 ){
		dupptr dpGMD1, gmd, 24, 4
		if ( dpGMD1(4) ){
			sdim aList, 64, dpGMD1(4) : SafeArrayAccessData gmd, gmd(2) : dupptr dpGMD2, gmd(2), dpGMD1(4) * 4, 4
			repeat dpGMD1(4)
				newcom cGMD1, _Type, -1, dpGMD2(cnt)
				if ( CSGetProp(cGMD1, "IsClass") ){ aList(gmd(3)) = CSGetProp(cGMD1, "FullName") : gmd(3)++ }
				delcom cGMD1
			loop
			SafeArrayUnaccessData gmd
		}
		SafeArrayDestroy gmd
	}
	return gmd(3)

#defcfunc CSGetPropList var cObj, array aList
	sdim aList, 64, 2, 1
	if ( CSCGetType(cObj, cGPL1) == 0 ){ return 0 }
	dim gpl, 6
	_Type_GetProperties_2 cGPL1, gpl : gpl(1) = stat
	if ( gpl(1) == 0 && gpl != 0 ){
		dupptr dpGPL, gpl, 24, 4
		if ( dpGPL(4) ){
			SafeArrayAccessData gpl, gpl(2) : dupptr dpGPL2, gpl(2), dpGPL(4) * 4, 4 : sdim aList, 64, 2, dpGPL(4)
			repeat dpGPL(4)
				newcom cGPL2, _PropertyInfo, -1, dpGPL2(cnt) : _PropertyInfo_name cGPL2, gpl(3)
				if ( stat == 0 ){ aList(0, cnt) = CSCCnvBstr(gpl(3)) }
				_PropertyInfo_PropertyType cGPL2, gpl(3)
				if ( stat == 0 ){ newcom cGPL3, _Type, -1, gpl(3) : _Type_ToString cGPL3, gpl(4) : aList(1, cnt) = CSCCnvBstr(gpl(4)) : delcom cGPL3 }
				delcom cGPL2 : gpl(5)++
			loop
			SafeArrayUnaccessData gpl
		}
		SafeArrayDestroy gpl
	}
	delcom cGPL1
	return gpl(5)

#defcfunc CSGetFieldList var cObj, array aList
	sdim aList, 64, 2, 1
	if ( CSCGetType(cObj, cGFL1) == 0 ){ return 0 }
	dim gfl, 6 : _Type_GetFields_2 cGFL1, gfl : gfl(1) = stat
	if ( gfl(1) == 0 && gfl != 0 ){
		dupptr dpGFL, gfl, 24, 4
		if ( dpGFL(4) ){
			SafeArrayAccessData gfl, gfl(2) : dupptr dpGFL2, gfl(2), dpGFL(4) * 4, 4 : sdim aList, 64, 2, dpGFL(4)
			repeat dpGFL(4)
				newcom cGFL2, _FieldInfo, -1, dpGFL2(cnt) : _FieldInfo_name cGFL2, gfl(3)
				if ( stat == 0 ){ aList(0, cnt) = CSCCnvBstr(gfl(3)) }
				_FieldInfo_FieldType cGFL2, gfl(3)
				if ( stat == 0 ){ newcom cGFL3, _Type, -1, gfl(3) : _Type_ToString cGFL3, gfl(4) : aList(1, cnt) = CSCCnvBstr(gfl(4)) : delcom cGFL3 }
				delcom cGFL2 : gfl(5)++
			loop
			SafeArrayUnaccessData gfl
		}
		SafeArrayDestroy gfl
	}
	delcom cGFL1
	return gfl(5)

#defcfunc CSGetMethodList var cObj, array aList
	sdim aList, 64, 3, 1
	if ( CSCGetType(cObj, cGML1) == 0 ){ return 0 }
	dim gml, 9 : _Type_GetMethods_2 cGML1, gml
	if ( stat == 0 && gml != 0 ){
		dupptr dpGML, gml, 24, 4
		if ( dpGML(4) ){
			SafeArrayAccessData gml, gml(1) : dupptr dpGML2, gml(1), dpGML(4) * 4, 4 : sdim aList, 64, 3, dpGML(4)
			repeat dpGML(4)
				newcom cGML2, _MethodInfo, -1, dpGML2(cnt) : _MethodInfo_name cGML2, gml(3)
				if ( stat == 0 ){
					aList(0, cnt) = CSCCnvBstr(gml(3)) : _MethodInfo_returnType cGML2, gml(2)
					if ( stat == 0 && gml(2) != 0 ){ newcom cGML3, _Type, -1, gml(2) : _Type_FullName cGML3, gml(2) : aList(1, cnt) = CSCCnvBstr(gml(2)) : delcom cGML3 }
					_MethodInfo_GetParameters cGML2, gml(2)
					if ( stat == 0 && gml(2) != 0 ){
						dupptr dpGML3, gml(2), 24, 4
						if ( dpGML3(4) ){
							SafeArrayAccessData gml(2), gml(3) : dupptr dpGML4, gml(3), dpGML3(4) * 4, 4 : buf = ""
							repeat dpGML3(4)
								newcom cGML3, _ParameterInfo, -1, dpGML4(cnt) : 
								if ( CSGetProp3(cGML3, "ParameterType", 0, gml(4)) ){ newcom cGML4, _Type, -1, gml(6) : _Type_FullName cGML4, gml(3) : if ( buf != "" ){ buf += "," } : buf += CSCCnvBstr(gml(3)) : delcom cGML4 }
								delcom cGML3
							loop
							SafeArrayUnaccessData gml(2) : aList(2, cnt) = buf
						}
					}
					gml(8)++
				}
				delcom cGML2
			loop
			SafeArrayUnaccessData gml
		}
		SafeArrayDestroy gml
	}
	delcom cGML1
	return gml(8)

#defcfunc CSGetMetaHost var cMeta
	dim gmh, 9
	gmh(0) = 0x9280188d, 0x48670e8e, 0xa87f0cb3, 0xdee88438
	gmh(4) = 0xd332db9e, 0x4125b9b3, 0x48a10782, 0x1632f584
	CLRCreateInstance gmh(0), gmh(4), gmh(8)
	if ( stat ){ return 0 }
	newcom cMeta, ICLRMetaHost, -1, gmh(8)
	return 1

#defcfunc CSGetVerList array aList
	if ( CSGetMetaHost(cGVL1) == 0 ){ return 0 }
	dim gvl, 2 : sdim buf, 520 : sdim aList, 520, 1
	ICLRMetaHost_EnumerateInstalledRuntimes cGVL1, gvl(1)
	if ( stat == 0 ){
		newcom cGVL2, IEnumUnknown, -1, gvl(1)
		repeat
			IEnumUnknown_Next cGVL2, 1, gvl(1), 0
			if ( stat ){ break }
			newcom cGVL3, ICLRRuntimeInfo, -1, gvl(1) : gvl(1) = 260 : ICLRRuntimeInfo_GetVersionString cGVL3, buf, gvl(1) : gvl(1) = stat : delcom cGVL3
			if ( gvl(1) ){ break }
			aList(gvl) = cnvwtos(buf) : gvl++
		loop
		delcom cGVL2
	}
	delcom cGVL1
	return gvl

#defcfunc CSGetSysDir
	sdim bufGSD, 520 : prmGSD = 0 : GetCORSystemDirectory bufGSD, 260, prmGSD
	if ( stat ){ return "" }
	return cnvwtos(bufGSD)

#defcfunc CSGetVer
	sdim bufGV, 520 : prmGVR = 0 : GetCORVersion bufGV, 260, prmGVR
	if ( stat ){ return "" }
	return cnvwtos(bufGV)

#defcfunc CSGetNewVer
	dim gnv, 7
	if ( CSGetVerList(aList) == 0 ){ return "" }
	gnv = length(aList)
	if ( gnv == 1 ){ return aList(0) }
	buf = aList(0) : buf2 = strmid(aList(0), 1, strlen(aList(0)) - 1) : gnv--
	repeat gnv, 1
		split buf2, ".", sb
		if ( length(sb) != 3 ){ continue }
		gnv(1) = int(sb(0)), int(sb(1)), int(sb(2)) : buf3 = strmid(aList(cnt), 1, strlen(aList(cnt)) - 1) : split buf3, ".", sb
		if ( length(sb) != 3 ){ continue }
		gnv(4) = int(sb(0)), int(sb(1)), int(sb(2))
		if ( gnv(4) > gnv(1) ){ buf = aList(cnt) }
		else { if ( gnv(4) == gnv(1) ){ if ( gnv(5) > gnv(2) ){ buf = aList(cnt) } else { if ( gnv(5) == gnv(2) ){ if ( gnv(6) > gnv(3) ){ buf = aList(cnt) } } } } }
	loop
	aList = 0
	return buf

#global

#endif // MOD_CSHARP_HSP_
コメント ( 0 ) | Trackback ( 0 )

mod_HostCLR.hsp

mod_HostCLR.hsp
#ifndef MOD_HOSTCLR_HSP_
#define global MOD_HOSTCLR_HSP_

#ifndef CLRCreateInstance
#uselib "MSCorEE.dll"
#func global CLRCreateInstance       "CLRCreateInstance"       var,var,var
#func global CorBindToRuntimeEx      "CorBindToRuntimeEx"      int,int,int,var,var,var
#func global GetCORRequiredVersion   "GetCORRequiredVersion"   var,int,var
#func global GetCORSystemDirectory   "GetCORSystemDirectory"   var,int,var
#func global GetCORVersion           "GetCORVersion"           var,int,var
#func global GetRequestedRuntimeInfo "GetRequestedRuntimeInfo" int,int,int,int,int,var,int,var,var,int,var
#endif

#ifndef ICorRuntimeHost
#define global IID_ICorRuntimeHost  "{CB2F6722-AB3A-11d2-9C40-00C04FA30A3E}"
#define global CLSID_CorRuntimeHost "{CB2F6723-AB3A-11d2-9C40-00C04FA30A3E}"
#usecom global ICorRuntimeHost IID_ICorRuntimeHost CLSID_CorRuntimeHost
#comfunc global ICorRuntimeHost_CreateLogicalThreadState     3
#comfunc global ICorRuntimeHost_DeleteLogicalThreadState     4
#comfunc global ICorRuntimeHost_SwitchInLogicalThreadState   5 var
#comfunc global ICorRuntimeHost_SwitchOutLogicalThreadState  6 var
#comfunc global ICorRuntimeHost_LocksHeldByLogicalThread     7 var
#comfunc global ICorRuntimeHost_MapFile                      8 int,var
#comfunc global ICorRuntimeHost_GetConfiguration             9 var
#comfunc global ICorRuntimeHost_Start                       10
#comfunc global ICorRuntimeHost_Stop                        11
#comfunc global ICorRuntimeHost_CreateDomain                12 wstr,int,var
#comfunc global ICorRuntimeHost_GetDefaultDomain            13 var
#comfunc global ICorRuntimeHost_EnumDomains                 14 var
#comfunc global ICorRuntimeHost_NextDomain                  15 int,var
#comfunc global ICorRuntimeHost_CloseEnum                   16 int
#comfunc global ICorRuntimeHost_CreateDomainEx              17 wstr,int,int,var
#comfunc global ICorRuntimeHost_CreateDomainSetup           18 var
#comfunc global ICorRuntimeHost_CreateEvidence              19 var
#comfunc global ICorRuntimeHost_UnloadDomain                20 int
#comfunc global ICorRuntimeHost_CurrentDomain               21 var
#endif

#ifndef ICLRMetaHost
#define global IID_ICLRMetaHost  "{D332DB9E-B9B3-4125-8207-A14884F53216}"
#define global CLSID_CLRMetaHost "{9280188D-0E8E-4867-B30C-7FA83884E8DE}"
#usecom global ICLRMetaHost IID_ICLRMetaHost CLSID_CLRMetaHost
#comfunc global ICLRMetaHost_GetRuntime                        3 wstr,var,var
#comfunc global ICLRMetaHost_GetVersionFromFile                4 wstr,var,var
#comfunc global ICLRMetaHost_EnumerateInstalledRuntimes        5 var
#comfunc global ICLRMetaHost_EnumerateLoadedRuntimes           6 int,var
#comfunc global ICLRMetaHost_RequestRuntimeLoadedNotification  7 int
#comfunc global ICLRMetaHost_QueryLegacyV2RuntimeBinding       8 var,var
#comfunc global ICLRMetaHost_ExitProcess                       9 int
#endif

#ifndef ICLRRuntimeInfo
#define global IID_ICLRRuntimeInfo "{BD39D1D2-BA2F-486a-89B0-B4B0CB466891}"
#usecom global ICLRRuntimeInfo IID_ICLRRuntimeInfo "{}"
#comfunc global ICLRRuntimeInfo_GetVersionString         3 var,var
#comfunc global ICLRRuntimeInfo_GetRuntimeDirectory      4 var,var
#comfunc global ICLRRuntimeInfo_IsLoaded                 5 int,var
#comfunc global ICLRRuntimeInfo_LoadErrorString          6 int,var,var,int
#comfunc global ICLRRuntimeInfo_LoadLibrary              7 wstr,var
#comfunc global ICLRRuntimeInfo_GetProcAddress           8 wstr,var
#comfunc global ICLRRuntimeInfo_GetInterface             9 var,var,var
#comfunc global ICLRRuntimeInfo_IsLoadable              10 var
#comfunc global ICLRRuntimeInfo_SetDefaultStartupFlags  11 int,wstr
#comfunc global ICLRRuntimeInfo_GetDefaultStartupFlags  12 var,var,var
#comfunc global ICLRRuntimeInfo_BindAsLegacyV2Runtime   13
#comfunc global ICLRRuntimeInfo_IsStarted               14 var,var
#endif

#ifndef _AppDomain
#define global IID__AppDomain   "{05F696DC-2B29-3663-AD8B-C4389CF2A713}"
#define global CLSID__AppDomain "{5FE0A145-A82B-3D96-94E3-FD214C9D6EB9}"
#usecom global _AppDomain IID__AppDomain CLSID__AppDomain
#comfunc global _AppDomain_ToString                    7 int
#comfunc global _AppDomain_Equals                      8 int,int,int,int,var
#comfunc global _AppDomain_GetHashCode                 9 var
#comfunc global _AppDomain_GetType                    10 var
#comfunc global _AppDomain_InitializeLifetimeService  11 var
#comfunc global _AppDomain_GetLifetimeService         12 var
#comfunc global _AppDomain_Evidence                   13 var
#comfunc global _AppDomain_add_DomainUnload           14 int
#comfunc global _AppDomain_remove_DomainUnload        15 int
#comfunc global _AppDomain_add_AssemblyLoad           16 int
#comfunc global _AppDomain_remove_AssemblyLoad        17 int
#comfunc global _AppDomain_add_ProcessExit            18 int
#comfunc global _AppDomain_remove_ProcessExit         19 int
#comfunc global _AppDomain_add_TypeResolve            20 int
#comfunc global _AppDomain_remove_TypeResolve         21 int
#comfunc global _AppDomain_add_ResourceResolve        22 int
#comfunc global _AppDomain_remove_ResourceResolve     23 int
#comfunc global _AppDomain_add_AssemblyResolve        24 int
#comfunc global _AppDomain_remove_AssemblyResolve     25 int
#comfunc global _AppDomain_add_UnhandledException     26 int
#comfunc global _AppDomain_remove_UnhandledException  27 int
#comfunc global _AppDomain_DefineDynamicAssembly      28 int,int,var
#comfunc global _AppDomain_DefineDynamicAssembly_2    29 int,int,int,var
#comfunc global _AppDomain_DefineDynamicAssembly_3    30 int,int,int,var
#comfunc global _AppDomain_DefineDynamicAssembly_4    31 int,int,int,int,int,var
#comfunc global _AppDomain_DefineDynamicAssembly_5    32 int,int,int,int,var
#comfunc global _AppDomain_DefineDynamicAssembly_6    33 int,int,int,int,int,int,var
#comfunc global _AppDomain_DefineDynamicAssembly_7    34 int,int,int,int,int,int,var
#comfunc global _AppDomain_DefineDynamicAssembly_8    35 int,int,int,int,int,int,int,var
#comfunc global _AppDomain_DefineDynamicAssembly_9    36 int,int,int,int,int,int,int,int,var
#comfunc global _AppDomain_CreateInstance             37 int,int,var
#comfunc global _AppDomain_CreateInstanceFrom         38 int,int,var
#comfunc global _AppDomain_CreateInstance_2           39 int,int,int,var
#comfunc global _AppDomain_CreateInstanceFrom_2       40 int,int,int,var
#comfunc global _AppDomain_CreateInstance_3           41 int,int,int,int,int,int,int,int,int,var
#comfunc global _AppDomain_CreateInstanceFrom_3       42 int,int,int,int,int,int,int,int,int,var
#comfunc global _AppDomain_Load                       43 int,var
#comfunc global _AppDomain_Load_2                     44 int,var
#comfunc global _AppDomain_Load_3                     45 int,var
#comfunc global _AppDomain_Load_4                     46 int,int,var
#comfunc global _AppDomain_Load_5                     47 int,int,int,var
#comfunc global _AppDomain_Load_6                     48 int,int,var
#comfunc global _AppDomain_Load_7                     49 int,int,var
#comfunc global _AppDomain_ExecuteAssembly            50 int,int,var
#comfunc global _AppDomain_ExecuteAssembly_2          51 int,var
#comfunc global _AppDomain_ExecuteAssembly_3          52 int,int,int,var
#comfunc global _AppDomain_FriendlyName               53 var
#comfunc global _AppDomain_BaseDirectory              54 var
#comfunc global _AppDomain_RelativeSearchPath         55 var
#comfunc global _AppDomain_ShadowCopyFiles            56 var
#comfunc global _AppDomain_GetAssemblies              57 var
#comfunc global _AppDomain_AppendPrivatePath          58 int
#comfunc global _AppDomain_ClearPrivatePath           59
#comfunc global _AppDomain_SetShadowCopyPath          60 int
#comfunc global _AppDomain_ClearShadowCopyPath        61
#comfunc global _AppDomain_SetCachePath               62 int
#comfunc global _AppDomain_SetData                    63 int,int,int,int,int
#comfunc global _AppDomain_GetData                    64 int,var
#comfunc global _AppDomain_SetAppDomainPolicy         65 int
#comfunc global _AppDomain_SetThreadPrincipal         66 int
#comfunc global _AppDomain_SetPrincipalPolicy         67 int
#comfunc global _AppDomain_DoCallBack                 68 int
#comfunc global _AppDomain_DynamicDirectory           69 var
#endif

#ifndef AppDomainSetup
#define global IID_IAppDomainSetup  "{27FFF232-A7A8-40DD-8D4A-734AD59FCD41}"
#define global CLSID_AppDomainSetup "{3E8E0F03-D3FD-3A93-BAE0-C74A6494DBCA}"
#usecom global AppDomainSetup IID_IAppDomainSetup CLSID_AppDomainSetup
#comfunc global AppDomainSetup_GetApplicationBase         3 var
#comfunc global AppDomainSetup_SetApplicationBase         4 int
#comfunc global AppDomainSetup_GetApplicationName         5 var
#comfunc global AppDomainSetup_SetApplicationName         6 int
#comfunc global AppDomainSetup_GetCachePath               7 var
#comfunc global AppDomainSetup_SetCachePath               8 int
#comfunc global AppDomainSetup_GetConfigurationFile       9 var
#comfunc global AppDomainSetup_SetConfigurationFile      10 int
#comfunc global AppDomainSetup_GetDynamicBase            11 var
#comfunc global AppDomainSetup_SetDynamicBase            12 int
#comfunc global AppDomainSetup_GetLicenseFile            13 var
#comfunc global AppDomainSetup_SetLicenseFile            14 int
#comfunc global AppDomainSetup_GetPrivateBinPath         15 var
#comfunc global AppDomainSetup_SetPrivateBinPath         16 int
#comfunc global AppDomainSetup_GetPrivateBinPathProbe    17 var
#comfunc global AppDomainSetup_PrivateBinPathProbe       18 int
#comfunc global AppDomainSetup_GetShadowCopyDirectories  19 var
#comfunc global AppDomainSetup_SetShadowCopyDirectories  20 int
#comfunc global AppDomainSetup_GetShadowCopyFiles        21 var
#comfunc global AppDomainSetup_SetShadowCopyFiles        22 int
#endif

#ifndef _ObjectHandle
#define global IID__ObjectHandle   "{EA675B47-64E0-3B5F-9BE7-F7DC2990730D}"
#define global CLSID__ObjectHandle "{ABEB0459-03B9-35AF-96E1-66BB7BC923F7}"
#usecom global _ObjectHandle IID__ObjectHandle CLSID__ObjectHandle
#comfunc global _ObjectHandle_ToString                    7 var
#comfunc global _ObjectHandle_Equals                      8 int,int,int,int,var
#comfunc global _ObjectHandle_GetHashCode                 9 var
#comfunc global _ObjectHandle_GetType                    10 var
#comfunc global _ObjectHandle_GetLifetimeService         11 var
#comfunc global _ObjectHandle_InitializeLifetimeService  12 var
#comfunc global _ObjectHandle_CreateObjRef               13 int,var
#comfunc global _ObjectHandle_Unwrap                     14 var
#endif

#ifndef _Object
#define global IID__Object   "{65074F7F-63C0-304E-AF0A-D51741CB4A8D}"
#define global CLSID__OBJECT "{81C5FE01-027C-3E1C-98D5-DA9C9862AA21}"
#usecom global _Object IID__Object CLSID__OBJECT
#comfunc global _Object_ToString     7 var
#comfunc global _Object_Equals       8 int,int,int,int,var
#comfunc global _Object_GetHashCode  9 var
#comfunc global _Object_GetType     10 var
#endif

#ifndef _Assembly
#define global IID__Assembly   "{17156360-2F1A-384A-BC52-FDE93C215C5B}"
#define global CLSID__Assembly "{28E89A9F-E67D-3028-AA1B-E5EBCDE6F3C8}"
#usecom global _Assembly IID__Assembly CLSID__Assembly
#comfunc global _Assembly_ToString                      7 var
#comfunc global _Assembly_Equals                        8 int,int,int,int,var
#comfunc global _Assembly_GetHashCode                   9 var
#comfunc global _Assembly_GetType                      10 var
#comfunc global _Assembly_CodeBase                     11 var
#comfunc global _Assembly_EscapedCodeBase              12 var
#comfunc global _Assembly_GetName                      13 var
#comfunc global _Assembly_GetName_2                    14 int,var
#comfunc global _Assembly_FullName                     15 var
#comfunc global _Assembly_EntryPoint                   16 var
#comfunc global _Assembly_GetType_2                    17 int,var
#comfunc global _Assembly_GetType_3                    18 int,int,var
#comfunc global _Assembly_GetExportedTypes             19 var
#comfunc global _Assembly_GetTypes                     20 var
#comfunc global _Assembly_GetManifestResourceStream    21 int,int,var
#comfunc global _Assembly_GetManifestResourceStream_2  22 int,var
#comfunc global _Assembly_GetFile                      23 int,var
#comfunc global _Assembly_GetFiles                     24 var
#comfunc global _Assembly_GetFiles_2                   25 int,var
#comfunc global _Assembly_GetManifestResourceNames     26 var
#comfunc global _Assembly_GetManifestResourceInfo      27 int,var
#comfunc global _Assembly_Location                     28 var
#comfunc global _Assembly_Evidence                     29 var
#comfunc global _Assembly_GetCustomAttributes          30 int,int,var
#comfunc global _Assembly_GetCustomAttributes_2        31 int,var
#comfunc global _Assembly_IsDefined                    32 int,int,var
#comfunc global _Assembly_GetObjectData                33 int,int
#comfunc global _Assembly_add_ModuleResolve            34 int
#comfunc global _Assembly_remove_ModuleResolve         35 int
#comfunc global _Assembly_GetType_4                    36 int,int,int,var
#comfunc global _Assembly_GetSatelliteAssembly         37 int,var
#comfunc global _Assembly_GetSatelliteAssembly_2       38 int,int,var
#comfunc global _Assembly_LoadModule                   39 int,int,var
#comfunc global _Assembly_LoadModule_2                 40 int,int,int,var
#comfunc global _Assembly_CreateInstance               41 int,var
#comfunc global _Assembly_CreateInstance_2             42 int,int,var
#comfunc global _Assembly_CreateInstance_3             43 int,int,int,int,int,int,int,var
#comfunc global _Assembly_GetLoadedModules             44 var
#comfunc global _Assembly_GetLoadedModules_2           45 int,var
#comfunc global _Assembly_GetModules                   46 var
#comfunc global _Assembly_GetModules_2                 47 int,var
#comfunc global _Assembly_GetModule                    48 int,var
#comfunc global _Assembly_GetReferencedAssemblies      49 var
#comfunc global _Assembly_GlobalAssemblyCache          50 var
#endif

#ifndef _Module
#define global IID__Module   "{D002E9BA-D9E3-3749-B1D3-D565A08B13E7}"
#define global CLSID__Module "{128191C5-B188-3054-81B7-E4F588EACF0E}"
#usecom global _Module IID__Module CLSID__Module
#endif

#ifndef _Type
#define global IID__Type   "{BCA8B44D-AAD6-3A86-8AB7-03349F4F2DA2}"
#define global CLSID__Type "{6C9863DC-7207-327F-A048-C3BB63474BFC}"
#usecom global _Type IID__Type CLSID__Type
#comfunc global _Type_QueryInterface          0 var,var
#comfunc global _Type_AddRef                  1
#comfunc global _Type_Release                 2
#comfunc global _Type_GetTypeInfoCount        3 var
#comfunc global _Type_GetTypeInfo             4 int,int,int
#comfunc global _Type_GetIDsOfNames           5 var,var,int,int,var
#comfunc global _Type_Invoke                  6 int,var,int,int,var,int,int,int
#comfunc global _Type_ToString                7 var
#comfunc global _Type_Equals                  8 int,int,int,int,var
#comfunc global _Type_GetHashCode             9 var
#comfunc global _Type_GetType                10 var
#comfunc global _Type_MemberType             11 var
#comfunc global _Type_name                   12 var
#comfunc global _Type_DeclaringType          13 var
#comfunc global _Type_ReflectedType          14 var
#comfunc global _Type_GetCustomAttributes    15 int,int,var
#comfunc global _Type_GetCustomAttributes_2  16 int,var
#comfunc global _Type_IsDefined              17 int,int,var
#comfunc global _Type_Guid                   18 var
#comfunc global _Type_Module                 19 var
#comfunc global _Type_Assembly               20 var
#comfunc global _Type_TypeHandle             21 var
#comfunc global _Type_FullName               22 var
#comfunc global _Type_Namespace              23 var
#comfunc global _Type_AssemblyQualifiedName  24 var
#comfunc global _Type_GetArrayRank           25 var
#comfunc global _Type_BaseType               26 var
#comfunc global _Type_GetConstructors        27 int,var
#comfunc global _Type_GetInterface           28 int,int,var
#comfunc global _Type_GetInterfaces          29 var
#comfunc global _Type_FindInterfaces         30 int,int,int,int,int,var
#comfunc global _Type_GetEvent               31 int,int,var
#comfunc global _Type_GetEvents              32 var
#comfunc global _Type_GetEvents_2            33 int,var
#comfunc global _Type_GetNestedTypes         34 int,var
#comfunc global _Type_GetNestedType          35 int,int,var
#comfunc global _Type_GetMember              36 int,int,int,var
#comfunc global _Type_GetDefaultMembers      37 var
#comfunc global _Type_FindMembers            38 int,int,int,int,int,int,int,var
#comfunc global _Type_GetElementType         39 var
#comfunc global _Type_IsSubclassOf           40 int,var
#comfunc global _Type_IsInstanceOfType       41 int,int,int,int,var
#comfunc global _Type_IsAssignableFrom       42 int,var
#comfunc global _Type_GetInterfaceMap        43 int,var
#comfunc global _Type_GetMethod              44 int,int,int,int,int,var
#comfunc global _Type_GetMethod_2            45 int,int,var
#comfunc global _Type_GetMethods             46 int,var
#comfunc global _Type_GetField               47 int,int,var;
#comfunc global _Type_GetFields              48 int,var
#comfunc global _Type_GetProperty            49 int,int,var
#comfunc global _Type_GetProperty_2          50 int,int,int,int,int,int,var
#comfunc global _Type_GetProperties          51 int,var
#comfunc global _Type_GetMember_2            52 int,int,var
#comfunc global _Type_GetMembers             53 int,var
#comfunc global _Type_InvokeMember           54 int,int,int,int,int,int,int,int,int,int,int,var
#comfunc global _Type_UnderlyingSystemType   55 var
#comfunc global _Type_InvokeMember_2         56 int,int,int,int,int,int,int,int,int,var
#comfunc global _Type_InvokeMember_3         57 int,int,int,int,int,int,int,int,var
#comfunc global _Type_GetConstructor         58 int,int,int,int,int,var
#comfunc global _Type_GetConstructor_2       59 int,int,int,int,var
#comfunc global _Type_GetConstructor_3       60 int,var
#comfunc global _Type_GetConstructors_2      61 var
#comfunc global _Type_TypeInitializer        62 var
#comfunc global _Type_GetMethod_3            63 int,int,int,int,int,int,var
#comfunc global _Type_GetMethod_4            64 int,int,int,var
#comfunc global _Type_GetMethod_5            65 int,int,var
#comfunc global _Type_GetMethod_6            66 int,var
#comfunc global _Type_GetMethods_2           67 var
#comfunc global _Type_GetField_2             68 int,var
#comfunc global _Type_GetFields_2            69 var
#comfunc global _Type_GetInterface_2         70 int,var
#comfunc global _Type_GetEvent_2             71 int,var
#comfunc global _Type_GetProperty_3          72 int,int,int,int,var
#comfunc global _Type_GetProperty_4          73 int,int,int,var
#comfunc global _Type_GetProperty_5          74 int,int,var
#comfunc global _Type_GetProperty_6          75 int,int,var
#comfunc global _Type_GetProperty_7          76 int,var
#comfunc global _Type_GetProperties_2        77 var
#comfunc global _Type_GetNestedTypes_2       78 var
#comfunc global _Type_GetNestedType_2        79 int,var
#comfunc global _Type_GetMember_3            80 int,var
#comfunc global _Type_GetMembers_2           81 var
#comfunc global _Type_Attributes             82 var
#comfunc global _Type_IsNotPublic            83 var
#comfunc global _Type_IsPublic               84 var
#comfunc global _Type_IsNestedPublic         85 var
#comfunc global _Type_IsNestedPrivate        86 var
#comfunc global _Type_IsNestedFamily         87 var
#comfunc global _Type_IsNestedAssembly       88 var
#comfunc global _Type_IsNestedFamANDAssem    89 var
#comfunc global _Type_IsNestedFamORAssem     90 var
#comfunc global _Type_IsAutoLayout           91 var
#comfunc global _Type_IsLayoutSequential     92 var
#comfunc global _Type_IsExplicitLayout       93 var
#comfunc global _Type_IsClass                94 var
#comfunc global _Type_IsInterface            95 var
#comfunc global _Type_IsValueType            96 var
#comfunc global _Type_IsAbstract             97 var
#comfunc global _Type_IsSealed               98 var
#comfunc global _Type_IsEnum                 99 var
#comfunc global _Type_IsSpecialName         100 var
#comfunc global _Type_IsImport              101 var
#comfunc global _Type_IsSerializable        102 var
#comfunc global _Type_IsAnsiClass           103 var
#comfunc global _Type_IsUnicodeClass        104 var
#comfunc global _Type_IsAutoClass           105 var
#comfunc global _Type_IsArray               106 var
#comfunc global _Type_IsByRef               107 var
#comfunc global _Type_IsPointer             108 var
#comfunc global _Type_IsPrimitive           109 var
#comfunc global _Type_IsCOMObject           110 var
#comfunc global _Type_HasElementType        111 var
#comfunc global _Type_IsContextful          112 var
#comfunc global _Type_IsMarshalByRef        113 var
#comfunc global _Type_Eauals_2              114 int,var
#endif

#ifndef _MemberInfo
#define global IID__MemberInfo   "{F7102FA9-CABB-3A74-A6DA-B4567EF1B079}"
#define global CLSID__MemberInfo "{5AE028B5-9A3A-32A9-899C-1DEEFB85CC50}"
#usecom global _MemberInfo IID__MemberInfo CLSID__MemberInfo
#comfunc global _MemberInfo_ToString                7 var
#comfunc global _MemberInfo_Equals                  8 int,int,int,int,var
#comfunc global _MemberInfo_GetHashCode             9 var
#comfunc global _MemberInfo_GetType                10 var
#comfunc global _MemberInfo_MemberType             11 var
#comfunc global _MemberInfo_name                   12 var
#comfunc global _MemberInfo_DeclaringType          13 var
#comfunc global _MemberInfo_ReflectedType          14 var
#comfunc global _MemberInfo_GetCustomAttributes    15 int,int,var
#comfunc global _MemberInfo_GetCustomAttributes_2  16 int,var
#comfunc global _MemberInfo_IsDefined              17 int,int,var
#endif

#ifndef _PropertyInfo
#define global IID__PropertyInfo   "{F59ED4E4-E68F-3218-BD77-061AA82824BF}"
#define global CLSID__PropertyInfo "{BFDF1F57-230D-394A-B773-D9EC58CBEF9A}"
#usecom global _PropertyInfo IID__PropertyInfo CLSID__PropertyInfo
#comfunc global _PropertyInfo_ToString                7 var
#comfunc global _PropertyInfo_Equals                  8 int,int,int,int,var
#comfunc global _PropertyInfo_GetHashCode             9 var
#comfunc global _PropertyInfo_GetType                10 var
#comfunc global _PropertyInfo_MemberType             11 var
#comfunc global _PropertyInfo_name                   12 var
#comfunc global _PropertyInfo_DeclaringType          13 var
#comfunc global _PropertyInfo_ReflectedType          14 var
#comfunc global _PropertyInfo_GetCustomAttributes    15 int,int,var
#comfunc global _PropertyInfo_GetCustomAttributes_2  16 int,var
#comfunc global _PropertyInfo_IsDefined              17 int,int,var
#comfunc global _PropertyInfo_PropertyType           18 var
#comfunc global _PropertyInfo_GetValue               19 int,int,int,int,int,var
#comfunc global _PropertyInfo_GetValue_2             20 int,int,int,int,int,int,int,int,var
#comfunc global _PropertyInfo_SetValue               21 int,int,int,int,int,int,int,int,int
#comfunc global _PropertyInfo_SetValue_2             22 int,int,int,int,int,int,int,int,int,int,int,int
#comfunc global _PropertyInfo_GetAccessors           23 int,var
#comfunc global _PropertyInfo_GetGetMethod           24 int,var
#comfunc global _PropertyInfo_GetSetMethod           25 int,var
#comfunc global _PropertyInfo_GetIndexParameters     26 var
#comfunc global _PropertyInfo_Attributes             27 var
#comfunc global _PropertyInfo_CanRead                28 var
#comfunc global _PropertyInfo_CanWrite               29 var
#comfunc global _PropertyInfo_GetAccessors_2         30 var
#comfunc global _PropertyInfo_GetGetMethod_2         31 var
#comfunc global _PropertyInfo_GetSetMethod_2         32 var
#comfunc global _PropertyInfo_IsSpecialName          33 var
#endif

#ifndef _FieldInfo
#define global IID__FieldInfo   "{8A7C1442-A9FB-366B-80D8-4939FFA6DBE0}"
#define global CLSID__FieldInfo "{98BA57DC-4CF2-3ED1-B4A2-890C21BBBF4B}"
#usecom global _FieldInfo IID__FieldInfo CLSID__FieldInfo
#comfunc global _FieldInfo_ToString               7 var
#comfunc global _FieldInfo_Equals                 8 int,int,int,int,var
#comfunc global _FieldInfo_GetHashCode            9 var
#comfunc global _FieldInfo_GetType               10 var
#comfunc global _FieldInfo_MemberType            11 var
#comfunc global _FieldInfo_name                  12 var
#comfunc global _FieldInfo_DeclaringType         13 var
#comfunc global _FieldInfo_ReflectedType         14 var
#comfunc global _FieldInfo_GetCustomAttributes   15 int,int,var
#comfunc global _FieldInfo_GetCustomAttributes_2 16 int,var
#comfunc global _FieldInfo_IsDefined             17 int,int,var
#comfunc global _FieldInfo_FieldType             18 var
#comfunc global _FieldInfo_GetValue              19 int,int,int,int,var
#comfunc global _FieldInfo_GetValueDirect        20 int,int,int,int,var
#comfunc global _FieldInfo_SetValue              21 int,int,int,int,int,int,int,int,int,int,int
#comfunc global _FieldInfo_SetValueDirect        22 int,int,int,int,int,int,int,int
#comfunc global _FieldInfo_FieldHandle           23 var
#comfunc global _FieldInfo_Attributes            24 var
#comfunc global _FieldInfo_SetValue_2            25 int,int,int,int,int,int,int,int
#comfunc global _FieldInfo_IsPublic              26 var
#comfunc global _FieldInfo_IsPrivate             27 var
#comfunc global _FieldInfo_IsFamily              28 var
#comfunc global _FieldInfo_IsAssembly            29 var
#comfunc global _FieldInfo_IsFamilyAndAssembly   30 var
#comfunc global _FieldInfo_IsFamilyOrAssembly    31 var
#comfunc global _FieldInfo_IsStatic              32 var
#comfunc global _FieldInfo_IsInitOnly            33 var
#comfunc global _FieldInfo_IsLiteral             34 var
#comfunc global _FieldInfo_IsNotSerialized       35 var
#comfunc global _FieldInfo_IsSpecialName         36 var
#comfunc global _FieldInfo_IsPinvokeImpl         37 var
#endif

#ifndef _MethodInfo
#define global IID__MethodInfo   "{FFCC1B5D-ECB8-38DD-9B01-3DC8ABC2AA5F}"
#define global CLSID__MethodInfo "{0E22CC27-CA1E-3138-9640-BE831F721659}"
#usecom global _MethodInfo IID__MethodInfo CLSID__MethodInfo
#comfunc global _MethodInfo_ToString                      7 var
#comfunc global _MethodInfo_Equals                        8 int,int,int,int,var
#comfunc global _MethodInfo_GetHashCode                   9 var
#comfunc global _MethodInfo_GetType                      10 var
#comfunc global _MethodInfo_MemberType                   11 var
#comfunc global _MethodInfo_name                         12 var
#comfunc global _MethodInfo_DeclaringType                13 var
#comfunc global _MethodInfo_ReflectedType                14 var
#comfunc global _MethodInfo_GetCustomAttributes          15 int,int,var
#comfunc global _MethodInfo_GetCustomAttributes_2        16 int,var
#comfunc global _MethodInfo_IsDefined                    17 int,int,var
#comfunc global _MethodInfo_GetParameters                18 var
#comfunc global _MethodInfo_GetMethodImplementationFlags 19 var
#comfunc global _MethodInfo_MethodHandle                 20 var
#comfunc global _MethodInfo_Attributes                   21 var
#comfunc global _MethodInfo_CallingConvention            22 var
#comfunc global _MethodInfo_Invoke_2                     23 int,int,int,int,int,int,int,int,var
#comfunc global _MethodInfo_IsPublic                     24 var
#comfunc global _MethodInfo_IsPrivate                    25 var
#comfunc global _MethodInfo_IsFamily                     26 var
#comfunc global _MethodInfo_IsAssembly                   27 var
#comfunc global _MethodInfo_IsFamilyAndAssembly          28 var
#comfunc global _MethodInfo_IsFamilyOrAssembly           29 var
#comfunc global _MethodInfo_IsStatic                     30 var
#comfunc global _MethodInfo_IsFinal                      31 var
#comfunc global _MethodInfo_IsVirtual                    32 var
#comfunc global _MethodInfo_IsHideBySig                  33 var
#comfunc global _MethodInfo_IsAbstract                   34 var
#comfunc global _MethodInfo_IsSpecialName                35 var
#comfunc global _MethodInfo_IsConstructor                36 var
#comfunc global _MethodInfo_Invoke_3                     37 int,int,int,int,int,var
#comfunc global _MethodInfo_returnType                   38 var
#comfunc global _MethodInfo_ReturnTypeCustomAttributes   39 var
#comfunc global _MethodInfo_GetBaseDefinition            40 var
#endif

#ifndef _ParameterInfo
#define global IID__ParameterInfo   "{993634C4-E47A-32CC-BE08-85F567DC27D6}"
#define global CLSID__ParameterInfo "{E5CE8078-0CA7-3578-80DB-F20FCA8786A6}"
#usecom global _ParameterInfo IID__ParameterInfo CLSID__ParameterInfo
#comfunc global _ParameterInfo_GetTypeInfoCount 3 var
#comfunc global _ParameterInfo_GetTypeInfo      4 int,int,int
#comfunc global _ParameterInfo_GetIDsOfNames    5 var,var,int,int,var
#comfunc global _ParameterInfo_Invoke           6 int,var,int,int,var,int,int,int
#endif

#endif // MOD_HOSTCLR_HSP_
コメント ( 0 ) | Trackback ( 0 )
« 前ページ