I want to create a DLL using C#, which can be then called from VBA in the following manner -
Private Declare Function invokePath Lib "\\shared_computer\Projects\somedll\myDLL.dll" (ByVal strUName As String, ByVal strSFile As String) As String
The idea is, if the path of the DLL is changed I need to only update the path in the Private Declare function line....
I have searched a lot for it, and also not sure whether this arrangement is possible - where we can call a DLL function from a network path without referencing or registering.
Actually you can. Check out unmanagedexports It is a complete walk-through and you'll be able to create entry points like this:
[DllExport("GenerateSomehting", CallingConvention = CallingConvention.Cdecl)]
public static int GenerateSomehting(int somevalue, ref IntPtr pointer)
and call it just like any other unmanaged dll.
[DllImport("MyGenerator.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int GenerateSomehting(int somevalue, ref IntPtr pointer);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With