?
Solved

Help!!!  Multi-Platform DLL Integration with Delphi

Posted on 1997-06-13
3
Medium Priority
?
578 Views
Last Modified: 2010-10-05
I work in a multi-platform development environment and NEED to be able to share functionality between:
      Delphi 2.0/3.0
      Clarion 2.0
      Visual Basic 4.0/5.0
      Visual FoxPro 5.0

Our development team has experts in each of these platforms.  We want to be able to share particular functions developed in one platform with the ALL ot the other platforms. Through the use of DLLs, we want to be able call a function, pass it parameters, have it act upon the parameters, and return a result, and potentially modify the input parameters.

This process sounds VERY simple in theory (every development platform's manuals make it sound soooo easy), but, in fact, we have had "limited successes".

I know that everyone has their "Favorite" platform, but has anyone successfully demonstrated that what I describe is possible.

ANY SAMPLE CODE/DLLS THAT DEMONSTRATES ANY OF THE ABOVE PLATFORMS WORKING TOGETHER WOULD GREATLY BE APPRECIATED.  Please include any instructions and specifics, such as compiler directive, additional support DLLS, yadayadaya...

I don't mean to be blunt, BUT!!!  If you have not actually been successful with what I have described above, please don't speculate.
0
Comment
Question by:jlm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Expert Comment

by:kangadru
ID: 1337019
First of all, the DLL's need to be written in either Delphi or C/C++ using stdcall.  Next, you can NEVER use pascal strings as params in the calling conventions.  All strings must be passed as PCHAR, ByVal in VB.  PCHAR is roughly equal to CSTR or CHAR in C/C++.  Below you will find both the code for a Delphi DLL and the code for a corresponding VB call to it.  This is tested code, so if you have problems following it please feel free to ask.The same basic code is usable in Visual FoxPro.  I have never used Clarion, but I suspect that it's DLL calling conventions are very similarAndyDelphi DLL (kdExt.dll) - Preferably in the Windows System dir.library kdExt;

uses
  Forms,
  classes,
  dialogs,
  windows,
  registry,
  sysutils,
  uSplash in 'uSplash.pas' {frmSplash},
  uRegister in 'uRegister.pas' {frmRegister},
  uEnterpas in 'uEnterpas.pas' {frmRegEnter};

{$R *.RES}

var
  frmSplash   : TfrmSplash;
  frmRegister : TfrmRegister;

procedure ShowSplashScreen; stdcall; export;
  begin
    frmSplash := TfrmSplash.Create(Application);
    frmSplash.Show;
  end;

procedure FreeSplashScreen; stdcall; export;
  begin
    frmSplash.Free;
  end;

procedure SplashSetAction(szAction : pchar); stdcall; export;
  begin
    frmSplash.pnlAction.Caption := string(szAction);
  end;

function DisplayRegistration: integer;  stdcall; export;
  begin
    frmRegister := TfrmRegister.Create(Application);
    result := frmRegister.ShowModal;
    frmRegister.Free;
  end;

exports
  ShowSplashScreen,
  FreeSplashScreen,
  DisplayRegistration,
  SplashSetAction;

begin
  // hide the froms created in the DLL from the Task Bar
  IsLibrary := True;
  Application.CreateHandle;
  ShowWindow(Application.Handle, SW_HIDE);
  Application.ShowMainForm := FALSE;
end.VB Code - Module to define the DLL callsDeclare Sub ShowSplashScreen Lib "kdExt.dll" ()
Declare Sub SplashSetAction Lib "kdExt.dll" (ByVal action As String)
Declare Sub FreeSplashScreen Lib "kdExt.dll" ()


VB Code Calling the DLL Private Sub Command1_Click()
  ShowSplashScreen
  SplashSetAction ("Loading")
End Sub

Private Sub Command2_Click()
  FreeSplashScreen
End Sub
Andy
0
 
LVL 2

Accepted Solution

by:
icampbe1 earned 200 total points
ID: 1337020
I have done this in a similar environment.  First of all if you are working completely in a 32bit platform environment, its just a matter of calling conventions.  Thats no big deal for an experienced coder.  

If you must cross platform between 16 and 32 bit, don't bother trying thunking.  The more 'current' practice is to use COM.  It was developed for exactly what you want.  If you need to come up to speed on this, I would begin with a good understanding of OLE Automation  (NOT OLE Linking and Embeding).  You build the equivalent of DLLs but they contain COM objects which are all callable from EVERYONE!

Even the platform can be ignored because of the 'Marshalling' that takes place for the call.   If I understand your question correctly, this is the corrent answer.

Ian C.

0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1337021
Thanks for grading me.  You might also want to keep in mind that there is a WM_CopyData windows message designed for inter-platform messages.  It automatically adjusts the handles and buff addresses to be correct across platforms.

Cheers,
Ian C.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question