1

I'm struggling to get a simple COM Server running in Visual D 2010. These are the steps I did so far:

  1. Clean Visual D 2010 solution of type Dynamic Library (DLL)
  2. I've copied contents of dserver.d into dllmain.d
  3. I've copied file chello.d and dserver.def into the solution's source folder, as well as advapi32.lib and ole32.lib from the <D install dir>\dmd2\windows\lib.
  4. I've added the copied file into the solution by right-clicking the project in the solution explorer and Add->Existing item...
  5. Renamed file dserver.def into dll.def, overwriting existing project's file.
  6. Applied a patch to the chello.d and dllmain.d (originally dserver.d) as written on this forum thread
  7. Build Debug. No errors.
  8. Calling regsvr32 COMServer.dll returns these four message boxes:

enter image description here

then

enter image description here

then

enter image description here

and finally

enter image description here

I am still unable to access the COM object from VBA. And referencing the DLL directly (by Browse... button and pointing to the COMServer.dll) fails with "Can't add a reference to the specified file."

14
  • 1
    check Modern COM Programming in D Commented Nov 4, 2013 at 10:29
  • @PaoloFalabella great presentation. Correct me if I'm wrong: there's nothing on COM Server in D in this presentation. There are examples of how D can be used as a COM client only. Commented Nov 4, 2013 at 10:37
  • sorry, rereading it I think you're right. The only thing I can find about COM server is here. There is an example in the "samples" folder in the DMD2 compiler (look for dserver.d) Commented Nov 4, 2013 at 10:59
  • @PaoloFalabella Yes, they are. I'm still struggling to get them working. I can build the sample .dll alright, but the file itself appears not to be a valid COM server. I'll update the question. Commented Nov 4, 2013 at 15:28
  • 1
    Looks like you need to add Advapi32.lib and ole32.lib to your project. (I don't know how to do that on visual D, but these are regular Windows libs, so it should be there, just need to add it to the build command). Then it should compile and you can try it. Commented Nov 4, 2013 at 16:54

2 Answers 2

1

I took another look at the forums and the problem with the samples seems related to TLS on Windows XP. I posted a (somewhat hacky) solution to it here:

http://forum.dlang.org/thread/[email protected]?page=2

Sign up to request clarification or add additional context in comments.

2 Comments

the comment thing is too long there... What's your VBA code look like? I just tried the sample from windows scripting host jscript: WScript.CreateObject("Hello1.0"); and it failed because the sample doesn't implement IDispatch ("the object does not support automation" so QueryInterface failed). Maybe it is the same with vba.
well, I implemented IDispatch (sort of, just barely enough to work) and it worked from JScript now (currently on Windows 7). Took a fair amount of stuff since the phobos windows headers don't describe IDispatch, so i had to use the extra win32 download... and modify them too. But I'm feeling pretty good about this now, I'll clean it up at some point today and post a zip for you to look over with everything needed to compile it.
0

I can't provide you with a working answer. It looks like this was a year ago, I was trying to get an example of using a COM server working. This uses Juno (not 64bit ready), has nothing to do with Visual D, and most importantly I couldn't get to work. The issue I hit was related to registering the server ("side-by-side configuration is incorrect").

My qualifications for COM are all there in the history of Juno (so not much of any). If you're more familiar with COM you may get further, if it doesn't compile for the latest DMD let me know (2.064 isn't out yet anyway).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.