One way , since I take it that you want a .dll addin, is to use vb
and create a new Add-In project. Set it for Excel, version
whatever, add OnConnection code, OnDisConnection code, etc.
Compile into a dll....etc.

Or you could create a .xla Excel addin, protected with a password
so users can not view the module code.

HTH