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. Visual Basic
  4. passing a string array to a C dll

passing a string array to a C dll

Scheduled Pinned Locked Moved Visual Basic
helpquestiondata-structuresjson
2 Posts 2 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.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    Heres the synopsis:

    Heres my problem:

    FRom the VB I am sending:

    Dim MyString(0 To 2) As String
    MyString(0) = "a "
    MyString(1) = "aaaa"
    MyString(2) = "mmmm"
    Call MyCString(MyString(0)) //I want to send in the address of the array MyString which is what I think I'm doing because:

    // If I had an array of ints called IntAr[0 to 5] in VB then sending in IntAR[0] means sending in the address of the array I have gathered.

    ============================ where:

    Public Declare Sub MyCString Lib "MyProj.dll" _
    Alias "?MyCString@@YGXPAD@Z" (ByVal invar As String)

    ========== and in the C dll:

    __declspec( dllexport ) void MyCString(char * invar)
    {
    strcpy(invar+4, "From The C Code"); // Leave first 4 characters alone & replace the rest
    return;
    }

    This makes the value of MySTring(0) = "a From The C Code" in VB because the dll did : strcpy(invar+4, "From The C Code"); But how do I change MySTring(1)in the dll ? Thx, ns Appreciate your help, ns

    N 1 Reply Last reply
    0
    • N ns

      Heres the synopsis:

      Heres my problem:

      FRom the VB I am sending:

      Dim MyString(0 To 2) As String
      MyString(0) = "a "
      MyString(1) = "aaaa"
      MyString(2) = "mmmm"
      Call MyCString(MyString(0)) //I want to send in the address of the array MyString which is what I think I'm doing because:

      // If I had an array of ints called IntAr[0 to 5] in VB then sending in IntAR[0] means sending in the address of the array I have gathered.

      ============================ where:

      Public Declare Sub MyCString Lib "MyProj.dll" _
      Alias "?MyCString@@YGXPAD@Z" (ByVal invar As String)

      ========== and in the C dll:

      __declspec( dllexport ) void MyCString(char * invar)
      {
      strcpy(invar+4, "From The C Code"); // Leave first 4 characters alone & replace the rest
      return;
      }

      This makes the value of MySTring(0) = "a From The C Code" in VB because the dll did : strcpy(invar+4, "From The C Code"); But how do I change MySTring(1)in the dll ? Thx, ns Appreciate your help, ns

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      ns wrote: But how do I change MySTring(1)in the dll ? I think you can increment the address position, something like this, however I know the following doesn't work exactly how you need it to. This atleast provides the idea.

      Show(int* x)
      {
      int* y;
      cout *x << endl;
      y = x += sizeof(int);
      cout << *y << endl;
      }


      Nick Parker

      You see the Standards change. - Fellow co-worker

      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