<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/6882279f58bacd72d522aa6c9fefa1ea"
  from="Dmitry Bely &lt;dbely@m...&gt;"
  author="Dmitry Bely"
  date="2002-07-21T08:15:21"
  subject="Re: [Caml-list] Looking for sample DLL"
  prev="2002/07/ceef67ffac4fa576044134564c761207"
  next="2002/07/759be1ad6a6899b3005b48af216dc987"
  prev-in-thread="2002/07/d690661f4a649261a9b9e2624051ae14"
  next-in-thread="2002/07/450d830015dd4a38a8b8320afce9a57e"
  prev-thread="2002/07/70faaf98f4dc639bc10a62a5b89685a5"
  next-thread="2002/07/16bf0e05b121ad70d4407203ffcc2060"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] ocamldot on steroids">
<msg 
  url="2002/07/647457434ab87dabf18062d5a922a07a"
  from="Brian Naylor &lt;bwv211mail@y...&gt;"
  author="Brian Naylor"
  date="2002-07-18T08:47:27"
  subject="[Caml-list] ocamldot on steroids">
<msg 
  url="2002/07/0a12b1839ea262e3265338dbc896e33e"
  from="Maxence Guesdon &lt;maxence.guesdon@i...&gt;"
  author="Maxence Guesdon"
  date="2002-07-18T08:54:11"
  subject="Re: [Caml-list] ocamldot on steroids">
<msg 
  url="2002/07/eb1d0a87e3e7c09cdae7fea4c8fd1a22"
  from="Mattias Waldau &lt;mattias.waldau@a...&gt;"
  author="Mattias Waldau"
  date="2002-07-18T14:45:50"
  subject="[Caml-list] Looking for sample DLL">
<msg 
  url="2002/07/0adf2052f58493ec09fa255e85227c32"
  from="Dmitry Bely &lt;dbely@m...&gt;"
  author="Dmitry Bely"
  date="2002-07-19T03:55:17"
  subject="Re: [Caml-list] Looking for sample DLL">
<msg 
  url="2002/07/adb807c0494bb2efa45ae2255111211f"
  from="Mattias Waldau &lt;mattias.waldau@a...&gt;"
  author="Mattias Waldau"
  date="2002-07-19T06:10:46"
  subject="RE: [Caml-list] Looking for sample DLL">
<msg 
  url="2002/07/102c21688ca964c6c052c6d5e01613ce"
  from="Dmitry Bely &lt;dbely@m...&gt;"
  author="Dmitry Bely"
  date="2002-07-19T20:25:59"
  subject="Re: [Caml-list] Looking for sample DLL">
<msg 
  url="2002/07/d690661f4a649261a9b9e2624051ae14"
  from="Mattias Waldau &lt;mattias.waldau@a...&gt;"
  author="Mattias Waldau"
  date="2002-07-19T21:17:17"
  subject="RE: [Caml-list] Looking for sample DLL">
<msg 
  url="2002/07/6882279f58bacd72d522aa6c9fefa1ea"
  from="Dmitry Bely &lt;dbely@m...&gt;"
  author="Dmitry Bely"
  date="2002-07-21T08:15:21"
  subject="Re: [Caml-list] Looking for sample DLL">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/450d830015dd4a38a8b8320afce9a57e"
  from="Brian Naylor &lt;bwv211mail@y...&gt;"
  author="Brian Naylor"
  date="2002-07-18T17:02:46"
  subject="Re: [Caml-list] ocamldot on steroids">
<msg 
  url="2002/07/f3cb1029fa67245b3da380088071af64"
  from="Emmanuel Renieris &lt;er@c...&gt;"
  author="Emmanuel Renieris"
  date="2002-07-18T18:45:49"
  subject="Re: [Caml-list] ocamldot on steroids">
</msg>
<msg 
  url="2002/07/ab4601e4eb8d239bf25b5a1757596831"
  from="Maxence Guesdon &lt;maxence.guesdon@i...&gt;"
  author="Maxence Guesdon"
  date="2002-07-19T08:39:39"
  subject="Re: [Caml-list] ocamldot on steroids">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
"Mattias Waldau" &lt;mattias.waldau@abc.se&gt; writes:

&gt; The reason I was looking for a sample is that it will take me 
&gt; probably a couple of days just getting the makefile right etc.
&gt; Therefor, much easier to just take someone else code and tweak
&gt; it a little.

Well, look into camlidl runtime. In fact, all you need is

extern "C"
BOOL APIENTRY DllMain(HANDLE module, DWORD reason, void *reserved)
{
  char * argv[2];
  char dll_path[_MAX_PATH];

  switch(reason) {
  case DLL_PROCESS_ATTACH:
    GetModuleFileName( (HMODULE) module, dll_path, _MAX_PATH );
    argv[0] = dll_path;
    argv[1] = NULL;
    camlidl_module_handle = (HMODULE) module;
#if 0
    int fd = open("/tmp/camllog", O_RDWR|O_TRUNC|O_CREAT, _S_IWRITE|_S_IREAD);
    dup2(fd, 1);
    dup2(fd, 2);
    close(fd);
#endif
    caml_startup(argv);
    break;
  /* TODO: free all memory when DLL detached */
  }
  return TRUE;
}

and an appropriate Makefile. You can also easily modify camlidldll script,
removing all COM-related stuff from there.

&gt;&gt; I cannot understand this. DLL and COM are not concepts of the 
&gt;&gt; same level. That's like to say "I prefer fruits to oranges" :-)
&gt;
&gt; COM's are implemented as a DLL, I have been unclear. What I need
&gt; is to be able using the old win16/32 dll-calling convention, not
&gt; using the modern COM-convention.
&gt;
&gt; The reason is that VBA doesn't support the COM supported by camlidl,
&gt; it only supports IDISPATCH.

But once again, IDISPATCH is *supported* by camlidl. Why not to create
IDispatch-equipped Ocaml COM component?

&gt; (I made some COM-stuff in my life, but
&gt; I do not like it, especially if you need to use C++. Now at last
&gt; in dotnet seems Microsoft gotten it right without wizards that
&gt; creates enormous amounts of code I don't understand.)

For VB and OCaml, no wizard-generated code is necessary, just normal C
stubs and virtual method tables plus type libraries, generated by MIDL.

&gt; I would like to keep it as simple as possible, thus the dll-calling
&gt; convention is enough. I will only call a few functions and I only
&gt; need to return integers. (Thus no need to mess with BSTR, which
&gt; would be needed if I would return strings from ocaml to vb).

- Dmitry Bely


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

