在Golang中通过COM与Lotus Notes交互

I am trying to access the COM classes provided by the Lotus Notes client. In Python this has been quite easy with the win32com.client lib:

def initialize_notes(self):
    """
    Initializes an object from the class.
    :return: Lotus Notes database
    """
    notes_session = win32com.client.Dispatch('Lotus.NotesSession')
    notes_session.Initialize(self.notes_password)
    notes_database = notes_session.GetDatabase(self.domino_server, self.domino_db)
    return notes_database

Now in Go, I have been unsuccessful. Below is my code:

import (
    "github.com/go-ole/go-ole"
    "github.com/go-ole/go-ole/oleutil"
)

func Connect(dominoServer, database, notesPassword string) (*ole.IDispatch, error) {
    ole.CoInitialize(0)
    unknown, err := oleutil.CreateObject("Lotus.NotesSession")
    if err != nil {
        panic(err)
    }
    notes, err := unknown.QueryInterface(ole.IID_IDispatch)
    if err != nil {
        panic(err)
    }
    session := oleutil.MustCallMethod(notes, "Initialize", notesPassword).ToIDispatch()
    db := oleutil.MustCallMethod(session, "GetDatabase", dominoServer, database).ToIDispatch()
    return db, nil
}

Which panics with the following error panic: Class not registered. The class is registered though, as both the Powershell and Python version of the function can access it without a problem.

What am I doing wrong?

If Go is executing in a 64 bit environment and Powershell and Python are executing in a 32 bit environment - or vice versa, that's your problem. Note that the Lotus COM classes are unsupported in 64 bit environments. They can be made to work (mostly) if you get them registered correctly, but a few of the calls do fail. If memory serves me correctly, all the methods that return collections of design elements fail, and there may be a few others.

楼主解决了嘛,我现在也遇到同样问题不知道如何解决,可以分享一下嘛?