DLL in Delphi 4

I am trying to do a DLL in Delphi for an 3rd application in Visual Basic, I always worked with Delphi and i don't have trouble to do DLLs and use them in my Delphi applications, but when i am trying to use the simplest DLLs in Visual Basic i don get the parameters right ( I have checked how to call a DLL in VB and i think is right) the other think is that when i run the dll in the RegSvr32 I get an error of DllRegisterServer no beign called, I have looked in several sites and tutorials and i didn't found the right answer, please help me with this one
Thanx in advance
hhuertaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rwilson032697Commented:
Two things you need to consider:

1. Make sure your calling convention is the same in your VB app and the delphi dll. You should declare your delphi DLL procedures like this:

procedure DoSomething(AnArg : SomeType); stdcall;

2. DLLs to not need to be registered with regsvr32 - this is only for COM/ActiveX objects etc.

Cheers,

Raymond.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hhuertaAuthor Commented:
I tried to do the same thing but now i call the dll and show in the body of the function a MessageDlg with the values of the parameters passed by VB but i get a lot of garbage in the messages and in the return value of the function i get garbage too?

I think is something with the data types, but at the moment I am using only inegers and reals.

Thank you!
0
rwilson032697Commented:
Hmm.. Could you post the Delphi DLL code?

You might also want to try changing the calling convention to cdecl or pascal.

Cheers,

Raymond.
0
hhuertaAuthor Commented:
library datos;


  {$D 'My Application'}

uses
  ShareMem,SysUtils,Windows,
  Unit2 in 'Unit2.Pas';

exports
   MultIntD     index 1 name 'MultInt';
   

begin

end.
--------------
unit Unit2;


interface

uses SysUtils,dialogs;

function MultIntD(X,Y:integer) : integer;  stdcall;



implementation

function MultIntD(X,Y: integer): integer;
begin
ShowMessage(IntToStr(X));
ShowMessage(IntToStr(Y));
//I Get numbers like 83452
  Result := X * Y;
{for example}
end;

end.
--------------
And Here is how i cal the function in VB

Module:
Declare Function MultInt Lib "datos.dll" (X, Y As Integer) As Integer

Form:
Private Sub Command2_Click()
Dim X%, Y%, Z%
X% = 5
Y% = 9
Z% = 0
Z% = MultInt(X%, Y%)
//I get results like -2345
Label2.Caption = Str(Z%)
End Sub
----------------------
Thanx in advance, you see this is a very simple dll and I can't get it to work!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.