-
Hello, COM(Cobra) World!
Posted on 2月 6th, 2013 by cx20
COM(Cobra)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
以下は Cobra による COM クライアントの例となっている。ソースコード(実行時バインディング)
use System use System.Reflection use System.Runtime.InteropServices class Program def main is shared objType = Type.getTypeFromProgID("Shell.Application") shell = Activator.createInstance(objType) param = @[ 0, "Hello, COM(Cobra) World!", 0, 36 ] folder = shell.getType.invokeMember( "BrowseForFolder", BindingFlags.InvokeMethod, nil, shell, param ) if folder nil Marshal.releaseComObject(folder) Marshal.releaseComObject(shell)
コンパイル方法(実行時バインディング)
C:¥> cobra -compile Hello.cobra
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(Cobra) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, COM(IronRuby) World!
Posted on 2月 2nd, 2013 by cx20
COM(IronRuby)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
以下は IronRuby による COM クライアントの例となっている。ソースコード(実行時バインディング)
require 'mscorlib' include System include System::Reflection include System::Runtime::InteropServices objType = System::Type.GetTypeFromProgID("Shell.Application") shell = System::Activator.CreateInstance(objType) hwnd = 0 title = "Hello, COM(IronRuby) World!".to_clr_string option = 0 rootFolder = 36 params = System::Array[System::Object].new [hwnd, title, option, rootFolder] folder = shell.GetType().InvokeMember( "BrowseForFolder", BindingFlags.InvokeMethod, nil, shell, params ) if folder != nil then System::Runtime::InteropServices::Marshal.ReleaseComObject(folder) end System::Runtime::InteropServices::Marshal.ReleaseComObject(shell)
コンパイル方法(実行時バインディング)
C:¥> ir Hello.rb
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(IronRuby) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, COM(IronPython) World!
Posted on 2月 1st, 2013 by cx20
COM(IronPython)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
以下は IronPython による COM クライアントの例となっている。ソースコード(実行時バインディング)
import System from System.Reflection import BindingFlags from System.Runtime.InteropServices import Marshal objType = System.Type.GetTypeFromProgID("Shell.Application") shell = System.Activator.CreateInstance(objType) param = System.Array[System.Object]([ 0, "Hello, COM(IronPython) World!", 0, 36 ]) folder = shell.GetType().InvokeMember( "BrowseForFolder", BindingFlags.InvokeMethod, None, shell, param ) if folder != None: Marshal.ReleaseComObject(folder) Marshal.ReleaseComObject(shell)
コンパイル方法(実行時バインディング)
C:¥> ipy Hello.py
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(IronPython) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, COM(Pascal) World!
Posted on 1月 29th, 2013 by cx20
COM(Pascal)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
以下は Free Pascal による COM クライアントの例となっている。ソースコード
program hello; uses ComObj; var shell: Variant; folder: Variant; begin shell := CreateOleObject('Shell.Application'); folder := shell.BrowseForFolder( 0, 'Hello, COM(Pascal) World!', 0, 36 ); end.
実行方法
C:¥> fpc hello.pas
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(Pascal) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, COM(Haskell) World!
Posted on 1月 27th, 2013 by cx20
COM(Haskell)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
以下は Haskell にて COM support library を使用した COM クライアントの例となっている。ソースコード
import System.Win32.Com import System.Win32.Com.Automation main = do coInitialize shell <- createObject "Shell.Application"; method0 "browseForFolder" [inInt 0, inString "Hello, COM(Haskell) World!", inInt 0, inInt 36] shell
コンパイル方法
C:¥> ghc Hello.hs
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(Haskell) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, COM(Jasmin) World!
Posted on 1月 26th, 2013 by cx20
COM(Jasmin)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
Jasmin 自身には、COM を呼び出す機能を持っていないが、別途ライブラリを経由することで呼び出すことが可能である。
以下は Jasmin より JACOB(JAVA-COM Bridge) ライブラリを使用した COM クライアントの例となっている。ソースコード
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Sun Dec 09 17:59:35 JST 2012 .bytecode 51.0 .source Hello.java .class public Hello .super java/lang/Object .method public ()V .limit stack 1 .limit locals 1 .var 0 is this LHello; from Label0 to Label1 Label0: .line 4 0: aload_0 1: invokespecial java/lang/Object/()V Label1: 4: return .end method .method public static main([Ljava/lang/String;)V .limit stack 4 .limit locals 8 .var 0 is arg0 [Ljava/lang/String; from Label0 to Label1 Label0: .line 6 0: new com/jacob/activeX/ActiveXComponent 3: dup 4: ldc "Shell.Application" 6: invokespecial com/jacob/activeX/ActiveXComponent/(Ljava/lang/String;)V 9: astore_1 .line 7 10: new com/jacob/com/Variant 13: dup 14: iconst_0 15: invokespecial com/jacob/com/Variant/(I)V 18: astore_2 .line 8 19: new com/jacob/com/Variant 22: dup 23: ldc "Hello, COM(JACOB) World!" 25: invokespecial com/jacob/com/Variant/(Ljava/lang/String;)V 28: astore_3 .line 9 29: new com/jacob/com/Variant 32: dup 33: iconst_0 34: invokespecial com/jacob/com/Variant/(I)V 37: astore 4 .line 10 39: new com/jacob/com/Variant 42: dup 43: bipush 36 45: invokespecial com/jacob/com/Variant/(I)V 48: astore 5 .line 11 50: iconst_4 51: anewarray com/jacob/com/Variant 54: dup 55: iconst_0 56: aload_2 57: aastore 58: dup 59: iconst_1 60: aload_3 61: aastore 62: dup 63: iconst_2 64: aload 4 66: aastore 67: dup 68: iconst_3 69: aload 5 71: aastore 72: astore 6 .line 12 74: aload_1 75: ldc "BrowseForFolder" 77: aload 6 79: invokevirtual com/jacob/activeX/ActiveXComponent/invoke(Ljava/lang/String;[Lcom/jacob/com/Variant;)Lcom/jacob/com/Variant; 82: astore 7 Label1: .line 13 84: return .end method
コンパイル&実行方法
C:¥> jasmin Hello.j C:¥> java -cp jacob.jar;. Hello
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(JACOB) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, COM(Rhino) World!
Posted on 1月 24th, 2013 by cx20
COM(Rhino)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
Rhino 自身には、COM を呼び出す機能を持っていないが、別途ライブラリを経由することで呼び出すことが可能である。
以下は Rhino より JACOB(JAVA-COM Bridge) ライブラリを使用した COM クライアントの例となっている。ソースコード
importPackage(com.jacob.com); importPackage(com.jacob.activeX); var shell = new ActiveXComponent("Shell.Application"); var hwnd = new Variant(0); var title = new Variant("Hello, COM(JACOB) World!"); var option = new Variant(0); var rootFolder = new Variant(36); var params = java.lang.reflect.Array.newInstance(Variant, 4); params[0] = hwnd; params[1] = title; params[2] = option; params[3] = rootFolder; var folder = shell.invoke( "BrowseForFolder", params );
実行方法
C:¥> jrunscript -cp jacob.jar;. Hello.js
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(JACOB) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, COM(BeanShell) World!
Posted on 1月 22nd, 2013 by cx20
COM(BeanShell)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
BeanShell 自身には、COM を呼び出す機能を持っていないが、別途ライブラリを経由することで呼び出すことが可能である。
以下は BeanShell より JACOB(JAVA-COM Bridge) ライブラリを使用した COM クライアントの例となっている。ソースコード
import com.jacob.com.Variant; import com.jacob.activeX.ActiveXComponent; ActiveXComponent shell = new ActiveXComponent("Shell.Application"); Variant hwnd = new Variant(0); Variant title = new Variant("Hello, COM(Jacob) World!"); Variant option = new Variant(0); Variant rootFolder = new Variant(36); Variant[] params = new Variant[] { hwnd, title, option, rootFolder }; Object folder = shell.invoke( "BrowseForFolder", params );
実行方法
C:¥> SET CLASSPATH=bsh-2.0b4.jar;jacob.jar;%CLASSPATH% C:¥> java bsh.Interpreter Hello.bsh
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(JACOB) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, COM(Clojure) World!
Posted on 1月 21st, 2013 by cx20
COM(Clojure)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
Clojure 自身には、COM を呼び出す機能を持っていないが、別途ライブラリを経由することで呼び出すことが可能である。
以下は Clojure より JACOB(JAVA-COM Bridge) ライブラリを使用した COM クライアントの例となっている。ソースコード
(import (com.jacob.com Variant) (com.jacob.activeX ActiveXComponent)) (def shell (ActiveXComponent. "Shell.Application")) (def hwnd (Variant. 0)) (def title (Variant. "Hello, COM(JACOB) World!")) (def option (Variant. 0)) (def rootFolder (Variant. 36)) (def params (into-array [hwnd title option rootFolder])) (def folder (.invoke shell "BrowseForFolder" params ))
実行方法
C:¥> SET CLASSPATH=jacob.jar;.;%CLASSPATH% C:¥> clojure Hello.clj
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(JACOB) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, COM(Jython) World!
Posted on 1月 20th, 2013 by cx20
COM(Jython)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
Jython 自身には、COM を呼び出す機能を持っていないが、別途ライブラリを経由することで呼び出すことが可能である。
以下は Jython より JACOB(JAVA-COM Bridge) ライブラリを使用した COM クライアントの例となっている。ソースコード
from com.jacob.com import Variant from com.jacob.activeX import ActiveXComponent shell = ActiveXComponent("Shell.Application") hwnd = Variant(0) title = Variant("Hello, COM(JACOB) World!") option = Variant(0) rootFolder = Variant(36) params = [ hwnd, title, option, rootFolder ] folder = shell.invoke( "BrowseForFolder", params )
実行方法
C:¥> SET CLASSPATH=jacob.jar;.;%CLASSPATH% C:¥> jython Hello.py
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(JACOB) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+