goo

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 SetWindowLongPtrW_ "SetWindowLongPtrW" 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", "GetWindowLongPtrW", 2, 0, dGetWindowLongPtrW
	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(dGetWindowLongPtrW, dArgs)
	lpoke procInfo, 50, lpeek(dRet, 0) : lpoke procInfo, 54, lpeek(dRet, 4)
	VirtualProtect_ procInfo, 16 * 8, 0x40, i1
	SetWindowLongPtrW_ 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 )
« 前ページ 次ページ »