Archive for 1月 29th, 2013

  1. 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] |
    +----------------------------------------+