goo

Scintilla

関連
Scintilla 公式
A free source code editing component for Win32, GTK, and OS X
ライセンス
License
License for Scintilla and SciTE
Copyright 1998-2002 by Neil Hodgson 

All Rights Reserved 

Permission to use, copy, modify, and distribute this software and its 
documentation for any purpose and without fee is hereby granted, 
provided that the above copyright notice appear in all copies and that 
both that copyright notice and this permission notice appear in 
supporting documentation. 

NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY 
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 
OR PERFORMANCE OF THIS SOFTWARE. 
準備
SciLexer.dll
Download Scintilla and SciTEから、 SciTEをダウンロードする。(例 full 32-bit download
現状、HSPは64ビットをフルサポートしていないので32-bitを使用してください。解凍して、SciLexer.dllを検索パスにコピーする。
Scintilla Edit コントロールの作成
上記画像は、右クリックでのメニューも表示させています。 エラーがなければ、Scintillaコントロールが作成されて、文字を入力できます。 デフォルト状態では、文字が小さかったので、次はフォントの変更をしてみます。
#include "user32.as"
#include "kernel32.as"

	screen 0, 300, 200
	title "Scintilla"
	LoadLibrary "SciLexer.dll"
	dllSciLexer = stat
	if ( dllSciLexer == 0 ){ dialog "Err SciLexer.dll", , "終了" : end }
	st = 0x52010000 : w = ginfo_winx : h = ginfo_winy
	CreateWindowEx 0, "Scintilla", "Scintilla", st, 0, 0, w, h, hwnd, 0x8000, hinstance, 0
	hEdit = stat
	SetFocus hEdit
	stop
コメント ( 0 ) | Trackback ( 0 )

mod_WebView2_08355.hsp

関連
WebView2_08355.hsp
HSP用WebView2.hの定義ファイル
環境
OS:Windows10 x64
HSP: Ver3.5
開発用Edgeは、アンインストール。
リリース版Edgeのバージョンは、80.0.361.48 (公式ビルド) (64 ビット)。
サンプル WebView2 コントロールの表示
mod_WebView2_08355.hspは、サンプルの下に記載。
#include "mod_WebView2_08355.hsp"

	screen 0, 600, 400
	WebView2New web
	WebView2Size web, 0, 0, ginfo_winx, ginfo_winy
	WebView2Navigate web, "https://www.bing.com"
	stop
サンプル WebView2 イベント処理
mod_WebView2_08355.hspは、サンプルの下に記載。
#include "mod_WebView2_08355.hsp"

	screen 0, 600, 400
	WebView2New web
	WebView2Size web, 0, 0, ginfo_winx, ginfo_winy

	dim token, 2
	WebView2EventInit webEvent, 0x9000
	WebView2EventSetBegin webEvent, WebView2_NavigationCompleted, *WEB_COMPLETED
	IWebView2WebView_add_NavigationCompleted web, stat, token
	WebView2EventSetEnd webEvent, WebView2_NavigationCompleted, token

	WebView2Navigate web, "https://www.bing.com"
	stop

*WEB_COMPLETED
	IWebView2WebView3_get_DocumentTitle web, tmp
	if ( stat == 0 ){
		WebView2WtoS tmp, buf
	}
	else { buf = "err" }
	title buf
	return
mod_WebView2_08355.hsp
#ifndef MOD_WEBVIEW2_HSP_
#define global MOD_WEBVIEW2_HSP_

#include "user32.as"
#include "kernel32.as"
#ifndef CreateEventExA
#func global CreateEventEx "CreateEventExA" int,sptr,int,int
#endif
#include "ole32.as"
#include "WebView2_08355.hsp"

#enum global WebView2_NavigationStarting = 0
#enum global WebView2_DocumentStateChanged
#enum global WebView2_NavigationCompleted
#enum global WebView2_FrameNavigationStarting
#enum global WebView2_MoveFocusRequested
#enum global WebView2_GotFocus
#enum global WebView2_LostFocus
#enum global WebView2_WebResourceRequested
#enum global WebView2_ScriptDialogOpening
#enum global WebView2_ZoomFactorChanged
#enum global WebView2_PermissionRequested
#enum global WebView2_ProcessFailed
#enum global WebView2_ScriptToExecuteOnDocumentCreated
#enum global WebView2_ExecuteScript
#enum global WebView2_CapturePreview
#enum global WebView2_WebMessageReceived
#enum global WebView2_CallDevToolsProtocolMethod
#enum global WebView2_DevToolsProtocolEventReceived
#enum global WebView2_NewWindowRequested
#enum global WebView2_DocumentTitleChanged
#enum global WebView2_AcceleratorKeyPressed
#enum global WEBVIEW2_NewVersionAvailable
#enum global WebView2_MAXHDL

#module mod_WebView2

#deffunc WevView2Init
	p1 = 0
	dim p2, 2
	dTmp = 0.0
	ldim lbTmp, 1
	eVt(0)  = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
	eVt(10) = 0, 0, 1, 1, 2, 0, 1, 0, 0, 0
	eVt(20) = 0, 0
	WebView2InitHdl
	return

#deffunc WebView2InitHdl
	if ( codeWeb2Hdl == 0 ){
		dim codeWeb2Hdl, 136
		codeWeb2Hdl(0) = $0c24448b, $04244c8b, $c0330889, $00000cc2
		codeWeb2Hdl(8) = $04c2c033, $00000000
		codeWeb2Hdl(16) = $04c2c033, $00000000
		codeWeb2Hdl(24) = $8b575653, $8514247c, $8b0674ff, $50ff5707, $245c8b04, $74db8518, $53038b06, $8b0450ff
		codeWeb2Hdl(32) = $83102474, $8900147e, $5e89047e, $ff117408, $44c71476, $aaaa1824, $448baaaa, $d0ff1824
		codeWeb2Hdl(40) = $00187e83, $006a1774, $1c76ff56, $202444c7, $bbbbbbbb, $8b1876ff, $ff242444, $335e5fd0
		codeWeb2Hdl(48) = $0cc25bc0, $00000000
		codeWeb2Hdl(56) = $0824448b, $4675c085, $24748b56, $147e8308, $04468900, $1024448b, $74084689, $1476ff11
		codeWeb2Hdl(64) = $102444c7, $aaaaaaaa, $1024448b, $7e83d0ff, $17740018, $ff56006a, $44c71c76, $bbbb1824
		codeWeb2Hdl(72) = $76ffbbbb, $24448b18, $33d0ff1c, $0cc25ec0, $00000000
		codeWeb2Hdl(80) = $24748b56, $7c8b5708, $7e831024, $7e890014, $ff117404, $44c71476, $aaaa1424, $448baaaa
		codeWeb2Hdl(88) = $d0ff1424, $00187e83, $006a1774, $1c76ff56, $1c2444c7, $bbbbbbbb, $8b1876ff, $ff20244c
		codeWeb2Hdl(96) = $5fc78bd1, $0008c25e, $00000000
		codeWeb2Hdl(104) = $0824448b, $5675c085, $7c8b5756, $ff851424, $078b0674, $0450ff57, $0c24748b, $00147e83
		codeWeb2Hdl(112) = $000446c7, $89000000, $1174087e, $c71476ff, $aa142444, $8baaaaaa, $ff142444, $187e83d0
		codeWeb2Hdl(120) = $6a177400, $76ff5600, $2444c71c, $bbbbbb1c, $1876ffbb, $2024448b, $335fd0ff, $0cc25ec0
		codeWeb2Hdl(128) = $00000000
		p1 = varptr(SetEvent)
		lpoke codeWeb2Hdl, 150, p1 : lpoke codeWeb2Hdl, 260, p1 : lpoke codeWeb2Hdl, 346, p1 : lpoke codeWeb2Hdl, 467, p1
		p1 = varptr(SendMessageA)
		lpoke codeWeb2Hdl, 176, p1 : lpoke codeWeb2Hdl, 286, p1 : lpoke codeWeb2Hdl, 372, p1 : lpoke codeWeb2Hdl, 493, p1
		VirtualProtect varptr(codeWeb2Hdl), 136 * 4, 0x40, varptr(p1)
		vtWeb2Hdl_IxI = varptr(codeWeb2Hdl(0)), varptr(codeWeb2Hdl(8)), varptr(codeWeb2Hdl(16)), varptr(codeWeb2Hdl(24))
		vtWeb2Hdl_HxW = varptr(codeWeb2Hdl(0)), varptr(codeWeb2Hdl(8)), varptr(codeWeb2Hdl(16)), varptr(codeWeb2Hdl(56))
		vtWeb2Hdl_H   = varptr(codeWeb2Hdl(0)), varptr(codeWeb2Hdl(8)), varptr(codeWeb2Hdl(16)), varptr(codeWeb2Hdl(80))
		vtWeb2Hdl_HxI = varptr(codeWeb2Hdl(0)), varptr(codeWeb2Hdl(8)), varptr(codeWeb2Hdl(16)), varptr(codeWeb2Hdl(104))
		dim vtHdl, 4
		vtHdl = varptr(vtWeb2Hdl_IxI), varptr(vtWeb2Hdl_HxW), varptr(vtWeb2Hdl_H), varptr(vtWeb2Hdl_HxI)
	}
	return

#deffunc WebView2Wait int hdlEvent
	if ( hdlEvent == 0 ){ return 1 }
	p2 = hdlEvent
	repeat
		await 1
		CoWaitForMultipleHandles 0, 1, 1, varptr(p2), varptr(p1)
		if ( stat == 0 || stat != 0x80010115 ){ break }
	loop
	p1 = stat
	CloseHandle p2
	return p1

#deffunc WebView2CWtoS int pWStr, var dst
	if ( pWStr == 0 ){ return 0 }
	WideCharToMultiByte 0, 0, pWStr, -1, 0, 0, 0, 0
	if ( stat == 0 ){ return 0 }
	sdim dst, stat + 1
	WideCharToMultiByte 0, 0, pWStr, -1, varptr(dst), stat, 0, 0
	return 1

#deffunc WebView2WtoS int pWStr, var dst
	WebView2CWtoS pWStr, dst
	p1 = stat
	CoTaskMemFree pWStr
	return p1

*WM_WEBVIEW2
	if ( wparam == 0 ){ return }
	dupptr dpHdl, wparam, 44, 4
	if ( dpHdl(4) >= WebView2_MAXHDL || dpHdl(10) == 0 ){ return }
	lpoke lbTmp, 0, dpHdl(10)
	gosub lbTmp
	return

#defcfunc WebView2HdlEvent array hdl
	CreateEventEx 0, 0, 0, 0x1F0003
	if ( stat == 0 ){ return 0 }
	dim hdl, 11
	hdl(0) = vtHdl(3)
	hdl(5) = stat
	return 1

#deffunc WebView2EnvInit var env
	dimtype env, 6, 1
	if ( WebView2HdlEvent(hdlTmp) == 0 ){ return 0 }
	CreateWebView2Environment varptr(hdlTmp)
	if ( stat ){ dialog strf("%#x", stat) : return 0 }

	WebView2Wait hdlTmp(5)
	if ( hdlTmp(1) != 0 || hdlTmp(2) == 0 ){ return 0 }
	newcom env, IWebView2Environment3, -1, hdlTmp(2)
	return 1

#deffunc WebView2New2 var env, var cWeb
	dimtype cWeb, 6, 1
	if ( WebView2HdlEvent(hdlTmp) == 0 ){ return 0 }
	IWebView2Environment_CreateWebView env, hwnd, varptr(hdlTmp)
	if ( stat == 0 ){
		WebView2Wait hdlTmp(5)
		if ( hdlTmp(1) == 0 && hdlTmp(2) != 0 ){
			newcom cWeb, IWebView2WebView, -1, hdlTmp(2)
		}
	}
	return 1

#deffunc WebView2New var cWeb
	WebView2EnvInit envTmp
	if ( stat == 0 ){ return 0 }
	WebView2New2 envTmp, cWeb
	envTmp = 0
	return stat

#deffunc WebView2Setting var cWeb, var cSetting
	IWebView2WebView_get_Settings cWeb, p1
	if ( stat ){ return 0 }
	newcom cSetting, IWebView2Settings2, -1, p1
	return 1

#deffunc WebView2Size var cWeb, int x, int y, int w, int h
	if ( varuse(cWeb) == 0 ){ return 0 }
	IWebView2WebView_put_Bounds cWeb, x, y, x + w, y + h
	if ( stat ){ return 0 }
	return 1

#deffunc WebView2Navigate var cWeb, str sUrl
	if ( varuse(cWeb) == 0 ){ return 0 }
	IWebView2WebView_Navigate cWeb, sUrl
	if ( stat ){ return 0 }
	return 1

#deffunc WebView2Write var cWeb, str sSrc
	if ( varuse(cWeb) == 0 ){ return 0 }
	IWebView2WebView_NavigateToString cWeb, sSrc
	if ( stat ){ return 0 }
	return 1

#deffunc WebView2Script var cWeb, str sSrc
	IWebView2WebView_ExecuteScript cWeb, sSrc, 0
	return

#deffunc WebView2EventInit array hdl, int idWebView2
	dim hdl, 11, WEBVIEW2_MAXHDL
	repeat WEBVIEW2_MAXHDL
		hdl(0, cnt) = vtHdl(eVt(cnt))
		hdl(4, cnt) = cnt, 0, hwnd, idWebView2
	loop
	oncmd gosub *WM_WEBVIEW2, idWebView2
	return

#deffunc WebView2EventSetBegin array hdl, int idEvent, label lbEvent
	if ( hdl(8, idEvent) != 0 || hdl(9, idEvent) != 0 || hdl(10, idEvent) != 0 ){
		return 0
	}
	lbTmp = lbEvent : hdl(10, idEvent) = lpeek(lbTmp, 0)
	return varptr(hdl(0, idEvent))

#deffunc WebView2EventSetEnd array hdl, int idEvent, array aToken
	hdl(8, idEvent) = aToken(0), aToken(1)
	return 1

#deffunc WebView2EventDelBegin array hdl, int idEvent, array aToken
	dim aToken, 2
	aToken = hdl(8, idEvent), hdl(9, idEvent)
	return 1

#deffunc WebView2EventDelEnd array hdl, int idEvent
	if ( stat ){ return 0 }
	hdl(8, idEvent) = 0, 0, 0
	return 1

#deffunc WebView2EventGet array eventInfo
	dupptr dp, wparam, 44, 4
	// InvokeArg1, InvokeArg2, IWebView2WebView*, ENUM_WEBVIEW2
	eventInfo = dp(1), dp(2), dp(3), dp(4)
	return

#global

	WevView2Init

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

WebView2

関連
Microsoft Edge Insider Channels
edgeのダウンロード(開発者用)
Microsoft Edge WebView2 (developer preview)
WebView2概要。各種リンク等。
mod_WebView2_08355.hsp
WebView2用モジュールとサンプル。
準備
  • WebView2Loader.dllの取得
    WebView2 SDK のDownload packageから、nupkgをダウンロードする。

  • SDK
    Version
    Edge
    Version
    DownloadsLast updated
    0.8.35580.0.355.02,5712019/12/09
    0.8.31480.0.314.01,5462019/10/28
    0.8.27078.0.270.01,8232019/09/10
    0.8.23077.0.230.06452019/07/29
    0.8.19077.0.190.05902019/06/17
    0.8.14976.0.149.07592019/05/06

    ダウンロードしたnupkgのファイル名の最後を.zipに変更して、解凍する。 WebView2Loader.dllを実行ファイルと同じフォルダか、検索パス上に配置する。
  • 開発者用の新しいバージョンのEdgeが必要な場合は、Microsoft Edge(Chromium) から、インストールする。
WebView2_08355.hsp
上記SDKの中の、build\native\include\WebView2.hを参照。
#ifndef WEBVIEW2_HSP_
#define global WEBVIEW2_HSP_

#uselib "WebView2Loader.dll"
#func global CreateWebView2EnvironmentWithDetails "CreateWebView2EnvironmentWithDetails" wptr,wptr,wptr,sptr
#func global CreateWebView2Environment            "CreateWebView2Environment"            sptr
#func global GetWebView2BrowserVersionInfo        "GetWebView2BrowserVersionInfo"        wptr,var
#func global CompareBrowserVersions               "CompareBrowserVersions"               wptr,wptr,var

#define global IID_IWebView2WebView "{76711B9E-8D56-4806-8485-35250BB2384F}"
#usecom global IWebView2WebView IID_IWebView2WebView "{}"
#comfunc global IWebView2WebView_get_Settings                             3 var
#comfunc global IWebView2WebView_get_Source                               4 var
#comfunc global IWebView2WebView_Navigate                                 5 wptr
#comfunc global IWebView2WebView_MoveFocus                                6 sptr
#comfunc global IWebView2WebView_NavigateToString                         7 wptr
#comfunc global IWebView2WebView_add_NavigationStarting                   8 sptr,var
#comfunc global IWebView2WebView_remove_NavigationStarting                9 int,int
#comfunc global IWebView2WebView_add_DocumentStateChanged                10 sptr,var
#comfunc global IWebView2WebView_remove_DocumentStateChanged             11 int,int
#comfunc global IWebView2WebView_add_NavigationCompleted                 12 sptr,var
#comfunc global IWebView2WebView_remove_NavigationCompleted              13 int,int
#comfunc global IWebView2WebView_add_FrameNavigationStarting             14 sptr,var
#comfunc global IWebView2WebView_remove_FrameNavigationStarting          15 int,int
#comfunc global IWebView2WebView_add_MoveFocusRequested                  16 sptr,var
#comfunc global IWebView2WebView_remove_MoveFocusRequested               17 int,int
#comfunc global IWebView2WebView_add_GotFocus                            18 sptr,var
#comfunc global IWebView2WebView_remove_GotFocus                         19 int,int
#comfunc global IWebView2WebView_add_LostFocus                           20 sptr,var
#comfunc global IWebView2WebView_remove_LostFocus                        21 int,int
#comfunc global IWebView2WebView_add_WebResourceRequested_deprecated     22 var,var,sptr,sptr,var
#comfunc global IWebView2WebView_remove_WebResourceRequested             23 int,int
#comfunc global IWebView2WebView_add_ScriptDialogOpening                 24 sptr,var
#comfunc global IWebView2WebView_remove_ScriptDialogOpening              25 int,int
#comfunc global IWebView2WebView_add_ZoomFactorChanged                   26 sptr,var
#comfunc global IWebView2WebView_remove_ZoomFactorChanged                27 int,int
#comfunc global IWebView2WebView_add_PermissionRequested                 28 sptr,var
#comfunc global IWebView2WebView_remove_PermissionRequested              29 int,int
#comfunc global IWebView2WebView_add_ProcessFailed                       30 sptr,var
#comfunc global IWebView2WebView_remove_ProcessFailed                    31 int,int
#comfunc global IWebView2WebView_AddScriptToExecuteOnDocumentCreated     32 wptr,sptr
#comfunc global IWebView2WebView_RemoveScriptToExecuteOnDocumentCreated  33 wptr
#comfunc global IWebView2WebView_ExecuteScript                           34 wptr,sptr
#comfunc global IWebView2WebView_CapturePreview                          35 sptr,sptr,sptr
#comfunc global IWebView2WebView_Reload                                  36 
#comfunc global IWebView2WebView_get_Bounds                              37 var
#comfunc global IWebView2WebView_put_Bounds                              38 int,int,int,int
#comfunc global IWebView2WebView_get_ZoomFactor                          39 var
#comfunc global IWebView2WebView_put_ZoomFactor                          40 double
#comfunc global IWebView2WebView_get_IsVisible                           41 var
#comfunc global IWebView2WebView_put_IsVisible                           42 int
#comfunc global IWebView2WebView_PostWebMessageAsJson                    43 wptr
#comfunc global IWebView2WebView_PostWebMessageAsString                  44 wptr
#comfunc global IWebView2WebView_add_WebMessageReceived                  45 sptr,var
#comfunc global IWebView2WebView_remove_WebMessageReceived               46 int,int
#comfunc global IWebView2WebView_Close                                   47 
#comfunc global IWebView2WebView_CallDevToolsProtocolMethod              48 wptr,wptr,sptr
#comfunc global IWebView2WebView_add_DevToolsProtocolEventReceived       49 wptr,sptr,var
#comfunc global IWebView2WebView_remove_DevToolsProtocolEventReceived    50 wptr,int,int
#comfunc global IWebView2WebView_get_BrowserProcessId                    51 var
#comfunc global IWebView2WebView_get_CanGoBack                           52 var
#comfunc global IWebView2WebView_get_CanGoForward                        53 var
#comfunc global IWebView2WebView_GoBack                                  54 
#comfunc global IWebView2WebView_GoForward                               55 

#define global IID_IWebView2WebView2 "{BB2DA827-0632-4ED6-8EDA-3F9E561767CA}"
#usecom global IWebView2WebView2 IID_IWebView2WebView2 "{}"
#comfunc global IWebView2WebView2_Stop   3 

#define global IID_IWebView2WebView3 "{A16A5FF1-C23B-4489-8752-8568A1BED09C}"
#usecom global IWebView2WebView3 IID_IWebView2WebView3 "{}"
#comfunc global IWebView2WebView3_Stop                         56 
#comfunc global IWebView2WebView3_add_NewWindowRequested       57 sptr,var
#comfunc global IWebView2WebView3_remove_NewWindowRequested    58 int,int
#comfunc global IWebView2WebView3_add_DocumentTitleChanged     59 sptr,var
#comfunc global IWebView2WebView3_remove_DocumentTitleChanged  60 int,int
#comfunc global IWebView2WebView3_get_DocumentTitle            61 var

#define global IID_IWebView2WebView4 "{E8B04ED2-FA61-4CBB-B303-786088177555}"
#usecom global IWebView2WebView4 IID_IWebView2WebView4 "{}"
#comfunc global IWebView2WebView4_AddRemoteObject               62 wptr,var
#comfunc global IWebView2WebView4_RemoveRemoteObject            63 wptr
#comfunc global IWebView2WebView4_OpenDevToolsWindow            64 
#comfunc global IWebView2WebView4_add_AcceleratorKeyPressed     65 sptr,var
#comfunc global IWebView2WebView4_remove_AcceleratorKeyPressed  66 int,int

#define global IID_IWebView2WebView5 "{E55144F5-A16F-43D8-9580-1E5227152EDF}"
#usecom global IWebView2WebView5 IID_IWebView2WebView5 "{}"
#comfunc global IWebView2WebView5_add_ContainsFullScreenElementChanged     67 sptr,var
#comfunc global IWebView2WebView5_remove_ContainsFullScreenElementChanged  68 int,int
#comfunc global IWebView2WebView5_get_ContainsFullScreenElement            69 var
#comfunc global IWebView2WebView5_add_WebResourceRequested                 70 sptr,var
#comfunc global IWebView2WebView5_AddWebResourceRequestedFilter            71 wptr,sptr
#comfunc global IWebView2WebView5_RemoveWebResourceRequestedFilter         72 wptr,sptr

#define global IID_IWebView2Deferral "{BD478C19-4706-4B1D-88B6-76DD39ACB7B1}"
#usecom global IWebView2Deferral IID_IWebView2Deferral "{}"
#comfunc global IWebView2Deferral_Complete   3 

#define global IID_IWebView2Settings "{A28CD108-3234-4B45-B390-7E871B504A96}"
#usecom global IWebView2Settings IID_IWebView2Settings "{}"
#comfunc global IWebView2Settings_get_IsScriptEnabled                  3 var
#comfunc global IWebView2Settings_put_IsScriptEnabled                  4 int
#comfunc global IWebView2Settings_get_IsWebMessageEnabled              5 var
#comfunc global IWebView2Settings_put_IsWebMessageEnabled              6 int
#comfunc global IWebView2Settings_get_AreDefaultScriptDialogsEnabled   7 var
#comfunc global IWebView2Settings_put_AreDefaultScriptDialogsEnabled   8 int
#comfunc global IWebView2Settings_get_IsFullscreenAllowed_deprecated   9 var
#comfunc global IWebView2Settings_put_IsFullscreenAllowed_deprecated  10 int
#comfunc global IWebView2Settings_get_IsStatusBarEnabled              11 var
#comfunc global IWebView2Settings_put_IsStatusBarEnabled              12 int
#comfunc global IWebView2Settings_get_AreDevToolsEnabled              13 var
#comfunc global IWebView2Settings_put_AreDevToolsEnabled              14 int

#define global IID_IWebView2Settings2 "{9FC76F96-CFD8-4C92-8EC5-9215E92EF3E8}"
#usecom global IWebView2Settings2 IID_IWebView2Settings2 "{}"
#comfunc global IWebView2Settings2_get_AreDefaultContextMenusEnabled  15 var
#comfunc global IWebView2Settings2_put_AreDefaultContextMenusEnabled  16 int

#define global IID_IWebView2ProcessFailedEventArgs "{6DABCFB8-8C7D-4515-893B-9766766900DA}"
#usecom global IWebView2ProcessFailedEventArgs IID_IWebView2ProcessFailedEventArgs "{}"
#comfunc global IWebView2ProcessFailedEventArgs_get_ProcessFailedKind   3 var

#define global IID_IWebView2ProcessFailedEHdl "{011EC830-5DAF-4767-A099-C43DE1A925F4}"
#usecom global IWebView2ProcessFailedEHdl IID_IWebView2ProcessFailedEHdl "{}"
#comfunc global IWebView2ProcessFailedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2ZoomFactorChangedEHdl "{A5C0B08B-25D7-4BAC-AD06-11783393088E}"
#usecom global IWebView2ZoomFactorChangedEHdl IID_IWebView2ZoomFactorChangedEHdl "{}"
#comfunc global IWebView2ZoomFactorChangedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2HttpHeadersCollectionIterator "{66a215e4-ca41-490b-884a-411ffb17cd1c}"
#usecom global IWebView2HttpHeadersCollectionIterator IID_IWebView2HttpHeadersCollectionIterator "{}"
#comfunc global IWebView2HttpHeadersCollectionIterator_GetCurrentHeader   3 var,var
#comfunc global IWebView2HttpHeadersCollectionIterator_MoveNext           4 var

#define global IID_IWebView2HttpRequestHeaders "{982be490-0252-44f3-9f33-376c04885a6d}"
#usecom global IWebView2HttpRequestHeaders IID_IWebView2HttpRequestHeaders "{}"
#comfunc global IWebView2HttpRequestHeaders_GetHeader      3 wptr,var
#comfunc global IWebView2HttpRequestHeaders_Contains       4 wptr,var
#comfunc global IWebView2HttpRequestHeaders_SetHeader      5 wptr,wptr
#comfunc global IWebView2HttpRequestHeaders_RemoveHeader   6 wptr
#comfunc global IWebView2HttpRequestHeaders_GetIterator    7 var

#define global IID_IWebView2HttpResponseHeaders "{6d1a13a6-c677-41aa-852f-827b53f35301}"
#usecom global IWebView2HttpResponseHeaders IID_IWebView2HttpResponseHeaders "{}"
#comfunc global IWebView2HttpResponseHeaders_AppendHeader   3 wptr,wptr
#comfunc global IWebView2HttpResponseHeaders_Contains       4 wptr,var
#comfunc global IWebView2HttpResponseHeaders_GetHeaders     5 wptr,var
#comfunc global IWebView2HttpResponseHeaders_GetIterator    6 var

#define global IID_IWebView2WebResourceRequest "{1b3f4122-34a0-4f5d-9089-af63c3afe375}"
#usecom global IWebView2WebResourceRequest IID_IWebView2WebResourceRequest "{}"
#comfunc global IWebView2WebResourceRequest_get_Uri       3 var
#comfunc global IWebView2WebResourceRequest_put_Uri       4 wptr
#comfunc global IWebView2WebResourceRequest_get_Method    5 var
#comfunc global IWebView2WebResourceRequest_put_Method    6 wptr
#comfunc global IWebView2WebResourceRequest_get_Content   7 var
#comfunc global IWebView2WebResourceRequest_put_Content   8 sptr
#comfunc global IWebView2WebResourceRequest_get_Headers   9 var

#define global IID_IWebView2WebResourceResponse "{297886a6-5fdf-472d-a97a-e336ecfe1352}"
#usecom global IWebView2WebResourceResponse IID_IWebView2WebResourceResponse "{}"
#comfunc global IWebView2WebResourceResponse_get_Content        3 var
#comfunc global IWebView2WebResourceResponse_put_Content        4 sptr
#comfunc global IWebView2WebResourceResponse_get_Headers        5 var
#comfunc global IWebView2WebResourceResponse_get_StatusCode     6 var
#comfunc global IWebView2WebResourceResponse_put_StatusCode     7 int
#comfunc global IWebView2WebResourceResponse_get_ReasonPhrase   8 var
#comfunc global IWebView2WebResourceResponse_put_ReasonPhrase   9 wptr

#define global IID_IWebView2NavigationStartingEventArgs "{9d7a1f73-8211-48c0-9119-686d1fb1ae02}"
#usecom global IWebView2NavigationStartingEventArgs IID_IWebView2NavigationStartingEventArgs "{}"
#comfunc global IWebView2NavigationStartingEventArgs_get_Uri               3 var
#comfunc global IWebView2NavigationStartingEventArgs_get_IsUserInitiated   4 var
#comfunc global IWebView2NavigationStartingEventArgs_get_IsRedirected      5 var
#comfunc global IWebView2NavigationStartingEventArgs_get_RequestHeaders    6 var
#comfunc global IWebView2NavigationStartingEventArgs_get_Cancel            7 var
#comfunc global IWebView2NavigationStartingEventArgs_put_Cancel            8 int

#define global IID_IWebView2NavigationStartingEHdl "{34896570-DC04-40F9-A2DA-8582551A707D}"
#usecom global IWebView2NavigationStartingEHdl IID_IWebView2NavigationStartingEHdl "{}"
#comfunc global IWebView2NavigationStartingEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2DocumentStateChangedEventArgs "{3A38CB7F-EFC1-41B4-87FC-5AFCEE27C8ED}"
#usecom global IWebView2DocumentStateChangedEventArgs IID_IWebView2DocumentStateChangedEventArgs "{}"
#comfunc global IWebView2DocumentStateChangedEventArgs_get_IsNewDocument   3 var
#comfunc global IWebView2DocumentStateChangedEventArgs_get_IsErrorPage     4 var

#define global IID_IWebView2DocumentStateChangedEHdl "{88E66305-3A5A-4E7F-9C76-2EBFC138CAFD}"
#usecom global IWebView2DocumentStateChangedEHdl IID_IWebView2DocumentStateChangedEHdl "{}"
#comfunc global IWebView2DocumentStateChangedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2ScriptDialogOpeningEventArgs "{ABB0484E-8D4F-4BEA-9058-B0287221A976}"
#usecom global IWebView2ScriptDialogOpeningEventArgs IID_IWebView2ScriptDialogOpeningEventArgs "{}"
#comfunc global IWebView2ScriptDialogOpeningEventArgs_get_Uri           3 var
#comfunc global IWebView2ScriptDialogOpeningEventArgs_get_Kind          4 var
#comfunc global IWebView2ScriptDialogOpeningEventArgs_get_Message       5 var
#comfunc global IWebView2ScriptDialogOpeningEventArgs_Accept            6 
#comfunc global IWebView2ScriptDialogOpeningEventArgs_get_DefaultText   7 var
#comfunc global IWebView2ScriptDialogOpeningEventArgs_get_ResultText    8 var
#comfunc global IWebView2ScriptDialogOpeningEventArgs_put_ResultText    9 wptr
#comfunc global IWebView2ScriptDialogOpeningEventArgs_GetDeferral      10 var

#define global IID_IWebView2ScriptDialogOpeningEHdl "{8EAF9A50-2AF9-45DA-9AC5-F80F4147180E}"
#usecom global IWebView2ScriptDialogOpeningEHdl IID_IWebView2ScriptDialogOpeningEHdl "{}"
#comfunc global IWebView2ScriptDialogOpeningEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2NavigationCompletedEventArgs "{48655B1F-3F52-4835-B7AA-7D95F7D7587E}"
#usecom global IWebView2NavigationCompletedEventArgs IID_IWebView2NavigationCompletedEventArgs "{}"
#comfunc global IWebView2NavigationCompletedEventArgs_get_IsSuccess        3 var
#comfunc global IWebView2NavigationCompletedEventArgs_get_WebErrorStatus   4 var

#define global IID_IWebView2NavigationCompletedEHdl "{DCEB3A27-C8C0-4DE7-889D-AF3DE80EDB3C}"
#usecom global IWebView2NavigationCompletedEHdl IID_IWebView2NavigationCompletedEHdl "{}"
#comfunc global IWebView2NavigationCompletedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2PermissionRequestedEventArgs "{8D8DA0E4-A071-486F-85AA-31B4B2BADC61}"
#usecom global IWebView2PermissionRequestedEventArgs IID_IWebView2PermissionRequestedEventArgs "{}"
#comfunc global IWebView2PermissionRequestedEventArgs_get_Uri               3 var
#comfunc global IWebView2PermissionRequestedEventArgs_get_PermissionType    4 var
#comfunc global IWebView2PermissionRequestedEventArgs_get_IsUserInitiated   5 var
#comfunc global IWebView2PermissionRequestedEventArgs_get_State             6 var
#comfunc global IWebView2PermissionRequestedEventArgs_put_State             7 sptr
#comfunc global IWebView2PermissionRequestedEventArgs_GetDeferral           8 var

#define global IID_IWebView2PermissionRequestedEHdl "{C5DA3C20-95AC-4345-B3C9-5FCA3B92C9DB}"
#usecom global IWebView2PermissionRequestedEHdl IID_IWebView2PermissionRequestedEHdl "{}"
#comfunc global IWebView2PermissionRequestedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2AddScriptToExecOnDocCreatedCompletedHandler "{EE07AA7F-5DAF-4C00-9C0B-5F736213C92D}"
#usecom global IWebView2AddScriptToExecOnDocCreatedCompletedHandler IID_IWebView2AddScriptToExecOnDocCreatedCompletedHandler "{}"
#comfunc global IWebView2AddScriptToExecOnDocCreatedCompletedHandler_Invoke   3 sptr,wptr

#define global IID_IWebView2ExecuteScriptCompletedHandler "{F5AC0E3B-8B92-45E5-ABEF-DB8518EFFF27}"
#usecom global IWebView2ExecuteScriptCompletedHandler IID_IWebView2ExecuteScriptCompletedHandler "{}"
#comfunc global IWebView2ExecuteScriptCompletedHandler_Invoke   3 sptr,wptr

#define global IID_IWebView2WebResourceRequestedEventArgs "{D8B1DD71-B9AD-4EEB-ABE3-87E7EFC5D37F}"
#usecom global IWebView2WebResourceRequestedEventArgs IID_IWebView2WebResourceRequestedEventArgs "{}"
#comfunc global IWebView2WebResourceRequestedEventArgs_get_Request    3 var
#comfunc global IWebView2WebResourceRequestedEventArgs_get_Response   4 var
#comfunc global IWebView2WebResourceRequestedEventArgs_put_Response   5 sptr
#comfunc global IWebView2WebResourceRequestedEventArgs_GetDeferral    6 var

#define global IID_IWebView2WebResourceRequestedEventArgs2 "{b38f6f16-9568-4f12-9996-dca7a06299f4}"
#usecom global IWebView2WebResourceRequestedEventArgs2 IID_IWebView2WebResourceRequestedEventArgs2 "{}"
#comfunc global IWebView2WebResourceRequestedEventArgs2_get_ResourceContext   7 var

#define global IID_IWebView2WebResourceRequestedEHdl "{E2AE08C1-4F67-4348-AE05-C89CB14C2ADD}"
#usecom global IWebView2WebResourceRequestedEHdl IID_IWebView2WebResourceRequestedEHdl "{}"
#comfunc global IWebView2WebResourceRequestedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2CapturePreviewCompletedHandler "{5755B27A-3FCD-4E01-B368-06834A5AFCDC}"
#usecom global IWebView2CapturePreviewCompletedHandler IID_IWebView2CapturePreviewCompletedHandler "{}"
#comfunc global IWebView2CapturePreviewCompletedHandler_Invoke   3 sptr

#define global IID_IWebView2FocusChangedEHdl "{76BDBECE-02CC-4E56-AD81-5F808E8572A6}"
#usecom global IWebView2FocusChangedEHdl IID_IWebView2FocusChangedEHdl "{}"
#comfunc global IWebView2FocusChangedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2MoveFocusRequestedEventArgs "{64AF5AE3-27A1-47E0-8901-95119C1BA95B}"
#usecom global IWebView2MoveFocusRequestedEventArgs IID_IWebView2MoveFocusRequestedEventArgs "{}"
#comfunc global IWebView2MoveFocusRequestedEventArgs_get_Reason    3 var
#comfunc global IWebView2MoveFocusRequestedEventArgs_get_Handled   4 var
#comfunc global IWebView2MoveFocusRequestedEventArgs_put_Handled   5 int

#define global IID_IWebView2MoveFocusRequestedEHdl "{F3A49DD0-EA49-469C-8B7A-8CC5E8E4EF27}"
#usecom global IWebView2MoveFocusRequestedEHdl IID_IWebView2MoveFocusRequestedEHdl "{}"
#comfunc global IWebView2MoveFocusRequestedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2WebMessageReceivedEventArgs "{E32C6167-14F1-42EA-8743-B014EF6AD27F}"
#usecom global IWebView2WebMessageReceivedEventArgs IID_IWebView2WebMessageReceivedEventArgs "{}"
#comfunc global IWebView2WebMessageReceivedEventArgs_get_Source               3 var
#comfunc global IWebView2WebMessageReceivedEventArgs_get_WebMessageAsJson     4 var
#comfunc global IWebView2WebMessageReceivedEventArgs_get_WebMessageAsString   5 var

#define global IID_IWebView2WebMessageReceivedEHdl "{0E682B9A-B686-4327-9A56-E0305705A3DB}"
#usecom global IWebView2WebMessageReceivedEHdl IID_IWebView2WebMessageReceivedEHdl "{}"
#comfunc global IWebView2WebMessageReceivedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2DevToolsProtocolEventReceivedEventArgs "{BF0F875F-8EB0-4211-9B80-2892F7276BB9}"
#usecom global IWebView2DevToolsProtocolEventReceivedEventArgs IID_IWebView2DevToolsProtocolEventReceivedEventArgs "{}"
#comfunc global IWebView2DevToolsProtocolEventReceivedEventArgs_get_Object                  3 var

#define global IID_IWebView2DevToolsProtocolEventReceivedEHdl "{37D087EA-12F6-4856-81D8-5596C708CA59}"
#usecom global IWebView2DevToolsProtocolEventReceivedEHdl IID_IWebView2DevToolsProtocolEventReceivedEHdl "{}"
#comfunc global IWebView2DevToolsProtocolEventReceivedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2CallDevToolsProtocolMethodCompletedHandler "{6EA28F62-FEC5-48EA-9669-67979B50579E}"
#usecom global IWebView2CallDevToolsProtocolMethodCompletedHandler IID_IWebView2CallDevToolsProtocolMethodCompletedHandler "{}"
#comfunc global IWebView2CallDevToolsProtocolMethodCompletedHandler_Invoke   3 sptr,wptr

#define global IID_IWebView2CreateWebViewCompletedHandler "{E0618CDD-4947-4F58-802C-FC1F20BD4274}"
#usecom global IWebView2CreateWebViewCompletedHandler IID_IWebView2CreateWebViewCompletedHandler "{}"
#comfunc global IWebView2CreateWebViewCompletedHandler_Invoke   3 sptr,sptr

#define global IID_IWebView2NewWindowRequestedEventArgs "{1f6e4074-bc3d-4381-ba8a-cf65feaa036a}"
#usecom global IWebView2NewWindowRequestedEventArgs IID_IWebView2NewWindowRequestedEventArgs "{}"
#comfunc global IWebView2NewWindowRequestedEventArgs_get_Uri               3 var
#comfunc global IWebView2NewWindowRequestedEventArgs_put_NewWindow         4 sptr
#comfunc global IWebView2NewWindowRequestedEventArgs_get_NewWindow         5 var
#comfunc global IWebView2NewWindowRequestedEventArgs_put_Handled           6 int
#comfunc global IWebView2NewWindowRequestedEventArgs_get_Handled           7 var
#comfunc global IWebView2NewWindowRequestedEventArgs_get_IsUserInitiated   8 var
#comfunc global IWebView2NewWindowRequestedEventArgs_GetDeferral           9 var

#define global IID_IWebView2NewWindowRequestedEHdl "{1daa050a-98de-44ad-b5bb-935c8b9c7c0b}"
#usecom global IWebView2NewWindowRequestedEHdl IID_IWebView2NewWindowRequestedEHdl "{}"
#comfunc global IWebView2NewWindowRequestedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2DocumentTitleChangedEHdl "{E190F4F4-7C94-4CB3-BA4D-DDCDA7AC7693}"
#usecom global IWebView2DocumentTitleChangedEHdl IID_IWebView2DocumentTitleChangedEHdl "{}"
#comfunc global IWebView2DocumentTitleChangedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2AcceleratorKeyPressedEventArgs "{64C29E6D-BA57-4EBA-A14F-71697F4F3D86}"
#usecom global IWebView2AcceleratorKeyPressedEventArgs IID_IWebView2AcceleratorKeyPressedEventArgs "{}"
#comfunc global IWebView2AcceleratorKeyPressedEventArgs_get_KeyEventType        3 var
#comfunc global IWebView2AcceleratorKeyPressedEventArgs_get_VirtualKey          4 var
#comfunc global IWebView2AcceleratorKeyPressedEventArgs_get_KeyEventLParam      5 var
#comfunc global IWebView2AcceleratorKeyPressedEventArgs_get_KeyStatus           6 var
#comfunc global IWebView2AcceleratorKeyPressedEventArgs_Handle                  7 int

#define global IID_IWebView2AcceleratorKeyPressedEHdl "{53E3676B-287C-4967-B7E2-DA0448BEB0F1}"
#usecom global IWebView2AcceleratorKeyPressedEHdl IID_IWebView2AcceleratorKeyPressedEHdl "{}"
#comfunc global IWebView2AcceleratorKeyPressedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2NewVersionAvailableEventArgs "{0256DA7B-2BF7-4B12-8ECA-EFFCB28C2CD8}"
#usecom global IWebView2NewVersionAvailableEventArgs IID_IWebView2NewVersionAvailableEventArgs "{}"
#comfunc global IWebView2NewVersionAvailableEventArgs_get_NewVersion   3 var

#define global IID_IWebView2NewVersionAvailableEHdl "{9E21312F-6FE7-4118-8CA1-6317C9CD627B}"
#usecom global IWebView2NewVersionAvailableEHdl IID_IWebView2NewVersionAvailableEHdl "{}"
#comfunc global IWebView2NewVersionAvailableEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2ContainsFullScrElemChangedEHdl "{37CF6A21-4B0C-41B6-81A6-C85C0D0A7543}"
#usecom global IWebView2ContainsFullScrElemChangedEHdl IID_IWebView2ContainsFullScrElemChangedEHdl "{}"
#comfunc global IWebView2ContainsFullScrElemChangedEHdl_Invoke   3 sptr,sptr

#define global IID_IWebView2Environment "{33D17ECE-82FA-47D9-8978-CD17FF3C3CC6}"
#usecom global IWebView2Environment IID_IWebView2Environment "{}"
#comfunc global IWebView2Environment_CreateWebView               3 sptr,sptr
#comfunc global IWebView2Environment_CreateWebResourceResponse   4 sptr,int,wptr,wptr,var

#define global IID_IWebView2Environment2 "{013124F3-02FD-4DFF-8911-06016AF1E3EE}"
#usecom global IWebView2Environment2 IID_IWebView2Environment2 "{}"
#comfunc global IWebView2Environment2_get_BrowserVersionInfo   5 var

#define global IID_IWebView2Environment3 "{D82C6A26-370F-4084-8149-C08FF1598C9B}"
#usecom global IWebView2Environment3 IID_IWebView2Environment3 "{}"
#comfunc global IWebView2Environment3_add_NewVersionAvailable      6 sptr,var
#comfunc global IWebView2Environment3_remove_NewVersionAvailable   7 int,int

#define global IID_IWebView2CreateWebView2EnvironmentCompletedHandler "{A8346945-51C2-4CE6-8B4C-6F3C4391828B}"
#usecom global IWebView2CreateWebView2EnvironmentCompletedHandler IID_IWebView2CreateWebView2EnvironmentCompletedHandler "{}"
#comfunc global IWebView2CreateWebView2EnvironmentCompletedHandler_Invoke   3 sptr,sptr


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

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 )
« 前ページ