dwight C63331

Member since: Saturday, 09 June 2018
Last login: 1 month ago
Profile viewed: 85 views

No Rank
Points: 0

dwight C63331 replied to the topic 'passing parameters from delphi to c++ DLL' in the forum. 1 month ago

thanks,
all the example I found didn't show that

Read More...

dwight C63331 created a new topic ' passing parameters from delphi to c++ DLL' in the forum. 1 month ago

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

Read More...

dwight C63331 created a new topic ' creating a visual studio C++ DLL accessable from Delphi' in the forum. 1 month ago

I need to create a DLL in visual studio c++ that I can access in delphi
I have had no problems getting functon calls and data returned to delphi
I cannot get the data passed from delphi to the c++ dll function

calling fnooprng returns the correct value

calling getooprng returns a incorrect value - no matter what value is sent

I have attached the cpp source for the DLL and the pas for the delphi routine trying to call it as txt files

thanks

Read More...

dwight C63331 replied to the topic 'consuming a net.tcp service' in the forum. 2 months ago

thanks - that is what I thought as I can find no one that knows anything about it

Read More...

dwight C63331 created a new topic ' consuming a net.tcp service' in the forum. 2 months ago

I have a wcf service using net.tcp at

net.tcp://localhost:8733/RngService/22475

How do I consume this in Delphi, XE2 and Rad Studio 10

Read More...

dwight C63331 replied to the topic 'accessing a c++ DLL from Rad Studio 10 Delphi' in the forum. 5 months ago

try creveltcomputer.com/spec.pdf
I really need to get this figured out

Read More...

dwight C63331 replied to the topic 'accessing a c++ DLL from Rad Studio 10 Delphi' in the forum. 5 months ago

attached is the documentation I have for this DLL - if you can show what I am missing I would appreciate it
I have not used a DLL that I did not create before
thanks

Read More...

dwight C63331 created a new topic ' accessing a c++ DLL from Rad Studio 10 Delphi' in the forum. 5 months ago

How do I access a DLL written in C++ that I have no access to modify from a rad 10 Delphi application
I have this info on the DLL
namespace OOP.RNG
{
public sealed class RNGInfernoServiceManager
{
public const long Zero = 0;
public const long OneBillion = 1000000000;

public static readonly RNGInfernoServiceManager
Current = new RNGInfernoServiceManager();

public RNGInfernoServiceManager()

public long[] CreateArrayOfRandomNumbers(uint arraySize = 1,
long min = Zero,
long max = OneBillion);
}
}

namespace SecurityDriven.Inferno
{
public class CryptoRandom : System.Random
{
public CryptoRandom()

public override int Next();
public override int Next(int maxValue);
public override int Next(int minValue, int maxValue);

public override void NextBytes(byte[] buffer);
public void NextBytes(byte[] buffer, int offset, int count);
public byte[] NextBytes(int count);

public override double NextDouble();

public long NextLong();
public long NextLong(long maxValue);
public long NextLong(long minValue, long maxValue);
}
}

and tried this
unit glirng1;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);


private
{ Private declarations }
public
{ Public declarations }
end;
type
trngv = class
rngvs: array[0..2] of integer;
end;

var
Form1: TForm1;

maxOdds: integer;
haswon: boolean;
rngValues: trngv;

procedure RNGInfernoServiceManager(); external 'ooprng.dll';
procedure CryptoRandom(); external 'ooprng.dll' ;
function CreateArrayOfRandomNumbers(a: integer; b:integer; c: integer):trngv; external 'ooprng.dll';

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;



procedure TForm1.Button2Click(Sender: TObject);
begin
maxOdds := 25000000;
rngValues := CreateArrayOfRandomNumbers(2, 0, maxOdds);
if (rngValues.rngvs[0] = rngValues.rngvs[1]) then haswon := true else haswon := false;

end;

end.

If I comment out the lines under button2.click the app runs but does nothing
otherwise I get a 0x000007b error
the DLL in in the appropriate directory

Read More...