How to use DLLImport when the entry point is nested in a class?
-
Hi, I have searched around the web and all my reference books but have yet to see an example of how this is done, or even if it can be done. Here is my dilemma: I have some old legacy apps that were written in VB6. Yay. Despite the fact that the VB6 programmers never used Object Oriented Programming of any kind... for some reason in this case they decided to nest the Procedure I need inside a class. Because of some poor programming practices that our team insists on following, I am prohibited from creating a strong reference to this COM Dll, I have to use PInvoke. So How can I use PInvoke to reference a method when it is a member of a VB6 class? The entry point is not recognized since an instance of the class would need to first be instantiated in order to access the method. Here is a sample of what my DllImport looks like:
[DllImport("SomeCOMDll", EntryPoint="aVB6Function")]
public static extern Recordset AVb6Function([MarshalAs(UnmanagedType.BStr)]
string globalIdentifier,
[MarshalAs(UnmanagedType.BStr)]
string webUser_ID,
DateTime shipDate,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)]
string[,] origDestArray,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)]
string[,] wtClsArray,
[MarshalAs(UnmanagedType.BStr)]
string mode,
[MarshalAs(UnmanagedType.BStr)]
string svcLvl,
[MarshalAs(UnmanagedType.BStr)]
string IOT,
[MarshalAs(UnmanagedType.BStr)]
string custCode,
[MarshalAs(UnmanagedType.Currency)]
decimal fuel,
[MarshalAs(UnmanagedType.Currency)]
decimal addtMarkupPct,
[MarshalAs(UnmanagedType.SafeArray, SafeAr