File: camlclient.ml

package info (click to toggle)
camlidl 1.05-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 872 kB
  • ctags: 1,131
  • sloc: ml: 4,894; ansic: 940; cpp: 897; makefile: 294; sh: 182
file content (36 lines) | stat: -rw-r--r-- 1,296 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(* A simple client in Caml *)

open Printf

let testcomp clsid =
  print_string "Call Com.create_instance to create component and get interface IX"; print_newline();
  begin try
    let ix = Com.create_instance clsid Component.iid_iX in
    let obj = Component.use_iX ix in
    print_string "Calling Fx..."; print_newline();
    obj#fx;
    print_string "Calling FxStringIn(\"foo bar\")..."; print_newline();
    obj#fxStringIn("foo bar");
    print_string "Calling FxStringOut..."; print_newline();
    let res = obj#fxStringOut in
    print_string "Result is: "; print_string res; print_newline();
    print_string "Calling FxFakeError..."; print_newline();
    begin try
      obj#fxFakeError;
      print_string "FxFakeError returned normally"; print_newline()
    with Com.Error(_, who, what) ->
      print_string "Exception Com.Error("; print_string who;
      print_string ", "; print_string what; print_string ")"; print_newline()
    end
  with Com.Error(_, src, msg) ->
    printf "COM error (%s): %s\n" src msg; flush stdout
  end

let clsid_component1 = Com.clsid "0C092C2C-882C-11CF-A6BB-0080C7B2D682"
let clsid_component2 = Com.clsid "6a3d0750-dad9-11d2-8e2c-0060974fbf19"

let _ =
  Com.initialize();
  testcomp clsid_component1;
  testcomp clsid_component2;
  Com.uninitialize()