Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. How to use DLLImport when the entry point is nested in a class?

How to use DLLImport when the entry point is nested in a class?

Scheduled Pinned Locked Moved COM
tutorialquestioncomiot
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cor2879
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups