I have a visual studio C++ DLL that I need to access from Delphi xe2 and rad 10
I can call functions and get back correct data. (fnooprng)
but when calling a function and passing a parameter I get a bad value back no matter what value is sent (getooprng)
I am missing something - but what?
C++ DLL code
// ooprng.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "ooprng.h"
// This is an example of an exported variable
OOPRNG_API int nooprng=0;
// This is an example of an exported function.
OOPRNG_API int fnooprng(void)
{
return 142;
}
// get an rng value from ooprng
OOPRNG_API int getooprng(int v)
{
rngvalue = v;
return rngvalue;
}
// This is the constructor of a class that has been exported.
// see ooprng.h for the class definition
Cooprng::Cooprng()
{
return;
}
Delphi code
unit glirng1;
{
}
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Web.Win.Sockets, Data.DB,
Datasnap.DBClient, Datasnap.Win.MConnect, Datasnap.Win.SConnect,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
maxodds: integer;
rng: integer;
xfer: integer;
reqs,resp: widestring;
function getooprng(y: integer):integer; external 'ooprng.dll';
function fnooprng():integer; external 'ooprng.dll';
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
maxodds := strtoint(edit1.Text);
rng := getooprng(maxodds);
label1.Caption := inttostr(rng);
xfer := fnooprng();
label2.Caption := inttostr(xfer);
end;
end.
I am missing something