[Stackoverflow] [Progress OpenEdge ABL] How to call a mvsc dll (C++ or Rust) from Progress Open Edge

Status
Not open for further replies.
S

Stéphane

Guest
I have a dll that i want to call from Progress code but I can't complete.

I have tried with Visual Studio 2022, Windows C++ Dll and Rust Dll.

Windows C++, Visual Studio 2022 with Progress

Code:
Cpp

Code:
#include "pch.h"
#include <windows.h>
#include <string.h>
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}
//---------------------------------------------------------------------------
/*
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
    return 1;
}
*/

//---------------------------------------------------------------------------
extern "C" __declspec(dllexport) int HelloWorld(int hello)
{
    return hello * 2;
}

Code:
Progress

Code:
BLOCK-LEVEL ON ERROR UNDO, THROW.

PROCEDURE HelloWorld EXTERNAL "C:\Users\Steee\source\repos\DllHelloWorld\x64\Release\DllHelloWorld.dll" CDECL:
    DEFINE INPUT PARAMETER hello AS SHORT NO-UNDO.
    DEFINE OUTPUT PARAMETER rCode AS SHORT NO-UNDO.
END.

DEFINE VARIABLE hello AS INTEGER NO-UNDO.
DEFINE VARIABLE rCode AS INTEGER NO-UNDO.
hello = 3.

RUN HelloWorld(hello, OUTPUT rCode).

MESSAGE STRING(rCode)
VIEW-AS ALERT-BOX INFO BUTTONS OK.

The code compiles without errors and warning but I've got "0" in MESSAGE STRING(rCode), this sould get "6".

Rust with mvsc with Progress

Code:
Rust lib.rs

Code:
use std::os::raw::{c_int};

#[no_mangle]
pub extern "C" fn HelloWorld(hello: c_int) -> c_int {
    hello * 2
}

Code:
Rust Cargo.toml

Code:
[package]
name = "DllRust"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "dll_rust"
crate-type = ["cdylib"]

[dependencies]

Code:
C Header

Code:
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

int HelloWorld(int hello);

Code:
Progress

Code:
BLOCK-LEVEL ON ERROR UNDO, THROW.
PROCEDURE DllHelloWorld EXTERNAL "C:\Users\Steee\CLionProjects\DllRust\target\release\dll_rust.dll" CDECL:
    DEFINE INPUT PARAMETER hello AS SHORT NO-UNDO.
    DEFINE OUTPUT PARAMETER rCode AS SHORT NO-UNDO.
END.
DEFINE VARIABLE hello AS INTEGER NO-UNDO.
DEFINE VARIABLE rCode AS INTEGER NO-UNDO.
hello = 3.

RUN HelloWorld(hello, OUTPUT rCode).

MESSAGE STRING(rCode)
VIEW-AS ALERT-BOX INFO BUTTONS OK.

The code doesn't compile. "** 'HelloWorld' was not found. (293)"

Continue reading...
 
Status
Not open for further replies.
Top