Search code examples
javascriptjavavisual-foxpro

Microsoft Visual Foxpro DLL call in Node or Java


I'm new to Visual Foxpro. I want to build a dynamic link library (dll) file using Visual Foxpro for calling the Visual Foxpro function in Node or Java to build rest API.

I tried it with Node and Java. I had an issue when I used the Foxpro dll file. So I created a C# dll, and got the same issue. So then I read a document which said to use > [DLLEXPORT] tag above the function which I want to call in another native language.

I built a 32-bit and 64-bit dll to use with my native language code. It was successful. My question is that I want to build both 32-bit and 64-bit dll files with Visual Foxpro to use with Node.js code.

This is my C# code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;
    using net.r_eg.DllExport;
    
    namespace FDLL
    {
        public  class First
        {
            [DllExport]
            public static String getData()
            {
                Console.Write("Call Function Successfully!");
                return "HI Welcome";
            }
        }
        [DllExport]
        public static String getData1(String a)
        {
            Console.Write("Call Function Successfully!");
            return "HI Welcome"+ a;
        }
    }

If I did not use [DllExport] tag, getData could not be invoked in my Node or java code.

This is my Node.js code:

const ffi = require("@saleae/ffi");

const libm = ffi.Library("./FDLL", {
    getData: ["string", []],
    getData1: ["string", ["string"]]
});

It works fine, but my Foxpro dll is not working.

This is my Visual Foxpro code:

screenshot of VFP code

This is the JavaScript code for accessing my Foxpro GetDrugsJSON() function

 var libm1 = ffi.Library("./cw/comdemo", {
         GetDrugsJSON: ["String", []],
     });
    console.log(libm1.GetDrugsJSON())

But I cannot invoke GetDrugsJSON() function with JavaScript code.

How do I fix this issue?


Solution

  • Long story short, you cannot build 32 and 64 bits DLL with VFP.

    Also a DLL is a broad term (while it is short for Dynamic Link Library, there are different DLLs).

    You are saying "in Node or Java to build rest API". For creating REST API you wouldn't want to use VFP. Use something else, be it C#, Go, ...

    With other languages too, if you are accessing VFP data via VFPOLEDB then it needs to be 32 bits.