Hello,
I need to pass an array from a VB6 application to another application. How can I do?
Thank for help

Dani AI

Generated

For : since a disk file is not allowed (and 's temp-file approach is therefore out), common, reliable IPC options in VB6 are: out‑of‑process COM (ActiveX EXE), WM_COPYDATA (window messages), named/shared memory (CreateFileMapping with INVALID_HANDLE_VALUE), named pipes or TCP (Winsock). Each has tradeoffs; two practical choices follow.

COM (ActiveX EXE) — simplest if both apps are VB6:

  • Build an ActiveX EXE that exposes a public routine that accepts a Variant (a SAFEARRAY will be marshaled automatically).
  • Variant arrays of built‑in types (Strings, Numbers) cross the process boundary cleanly; user‑defined types do not.
  • Example (server class in ActiveX EXE):
    Public Sub ReceiveData(data As Variant)
      Dim i As Long
      For i = LBound(data) To UBound(data)
          Debug.Print data(i)
      Next i
    End Sub
  • Client:
    Dim srv As Object
    Set srv = CreateObject("MyProj.ServerClass")
    Dim arr As Variant
    arr = Array("one","two","three")
    srv.ReceiveData arr

WM_COPYDATA — good for small/medium chunks and when a window handle is available:

  • Pack the array into a byte buffer, send with WM_COPYDATA (WM_COPYDATA = &H4A) via SendMessage; receiver handles WM_COPYDATA and copies the bytes into a local buffer.
  • Caveats: synchronous call, limited practicality for very large data, requires a target hWnd and safe subclassing to receive messages, and messages can fail across different integrity levels (UAC/elevation).

Other options:

  • Memory‑mapped sections with CreateFileMapping(hFile = INVALID_HANDLE_VALUE) — shared memory with no disk file.
  • Named pipes or Winsock — robust for larger or streaming data.
  • DDE / Clipboard — legacy or fragile; not recommended.

Troubleshooting notes:

  • If no window handle exists, prefer COM or pipes.
  • Ensure both processes run at compatible privilege levels.
  • Avoid passing UDTs; convert to Variant/SAFEARRAY or serialize.
  • Start with a tiny test payload to validate the channel before sending full arrays.

Create a temp file and declare a variable in it.

Thank for your reply. But I can not use file

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.