Using Windows COM API in GoLang

Hi Folks,

I am currently doing a system programming project. Initially I picked up C/C++ for my work as there are lot of resource available for development for various use cases.
Then I looked into GoLang and am really impressed with it and decided to go with GO :wink:.

My goal is to build a multi platform system programming project and started concentrating on Windows first. Looked into Go’s windows package and other third party packages and used them for my works. Also, I am loading few dll’s through syscall and make use of them.
Now, I am stuck with using Windows COM apis in GoLang and in need help to move forward.

Previously I was developing my project with MS C++ and it was easy there to make use of all Windows (COM) apis. In order to make full use of windows apis and its msvc objects, I have analysed for any such provision in GoLang and ended up in MSVC Support and understood that it is not planned for any recent releases due to some difficulties. If the above support have been released I would be happy but My bad :worried:.

So, I planned to proceed my implementation through syscall by loading the dll and calling its function address.
What I am trying here is to create a get the list of installed updates in a windows machine and Microsoft provides api for it through wuapi.dll. For that, I have to create instance for UpdateSession from the loaded dll.

What I did in MS C++ is,

IUpdateSession* updateSession;
result = CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (LPVOID*)&updateSession);

where the params CLSID_UpdateSession and IID_IUpdateSession are GUIDs availble in the header files there and that it, it worked like charm.

What I am trying in GoLang is,

var wuapiDll = syscall.NewLazyDLL("wuapi.dll")
var ole32Dll = syscall.NewLazyDLL("ole32.dll")
var instanceRef = ole32Dll.NewProc("CoCreateInstance")
instanceRef.Call() // Stuck here

I am not sure about how to define and send the guid params in GoLang.

Also, I have a doubt on whether am I going on the right direction for calling the Windows COM apis from GoLang.

So thought of asking it in forum so that experts like you guys may provide more useful information about this. Any help/input is much appreciated.

In the continuation for the search of solution, I have tried for COM bindings and is working well. Might be helpful for someone else if they come across this in future.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.