PDA

View Full Version : Delphi DLL & Install Shield Exrpess 2



NewsArchive
07-29-1997, 12:00 AM
hi,

Can anybody please e-mail or post the source to a simple Delphi DLL that
can be used with Install Shield Express, any DLL I try to make causes a
Page Fault and it's driving me nuts

Thanks in Advance

Alex

NewsArchive
08-01-1997, 12:00 AM
Hi Alex,

I have quoted a Knowledge base article which discusses about using a
Delphi DLL as an Express extension. Also I have attached the compiled DLL.
This is also available in the Online Knowledge base on our website at the
following URL
http://kb.installshield.com/isxkb
=============================================================
How To: Making A Custom Delphi DLL work as an Extension

=============================================================
For Distribution: Public
This document relates to the following InstallShield Express product(s):
Professional
Target Platform(s): All Platforms

----------------------------------------------------------------------------
---------------------------------------------
ISSUE:
----------------------------------------------------------------------------
---------------------------------------------

I have a custom DLL function written in Delphi, but I can't seem to launch
it as an extension from my InstallShield Express installation.

----------------------------------------------------------------------------
---------------------------------------------
DISCUSSION:
----------------------------------------------------------------------------
---------------------------------------------

InstallShield Express can only launch DLL functions that are C-callable,
i.e. can be launched from a C program. To make sure that your Delphi DLL
function follows the standard C calling convention, be sure to include the
stdcall calling convention when declaring your function.


Following is the code for a Delphi DLL that performs in a similar fashion
to the C DLLs described in article X1068. Also attached is the compiled
32-bit DLL.

library MyDelphi;


uses
Classes,
SysUtils,
Dialogs in 'Dialogs.pas',
Windows in 'Windows.pas';


function Foo(mainwin: Hwnd; szSrcDir, szSupport, szInst, szRes: LPSTR):
Char; export; stdcall;
var
test1: String;
begin
test1 := Format('Extension Called!! HWND=%x, SRCDIR=%s, SUPPORTDIR=%s,
INSTALLDIR=%s ', [mainwin, szSrcDir, szSupport, szInst]);
MessageDlg(test1, mtInformation, [mbOk], 0);
end;


exports
Foo index 1;


begin
end.
--------------------------------------------------------
Regards,
Prabhu RP

Aditi Corp.
InstallShield Authorized Solution Provider

Alex <Darkside_of_the_Moon@msn.com> wrote in article
<01bc9c20$61cde020$8b1c86c2@zen>...
> hi,
>
> Can anybody please e-mail or post the source to a simple Delphi DLL that
> can be used with Install Shield Express, any DLL I try to make causes a
> Page Fault and it's driving me nuts
>
> Thanks in Advance
>
> Alex
>

NewsArchive
08-01-1997, 12:00 AM
ooooooooooh thanks a lot :-)))))))))))
--
for some delphi tips:

http://www.euronet.nl/users/darkside/

Aditi Corp. <prabhurp@aditi.com> wrote in article
<01bc9e33$c5422b60$2d0c36ca@nquest134>...
> Hi Alex,
>
> I have quoted a Knowledge base article which discusses about using a
> Delphi DLL as an Express extension. Also I have attached the compiled
DLL.
> This is also available in the Online Knowledge base on our website at the
> following URL
> http://kb.installshield.com/isxkb
> =============================================================
> How To: Making A Custom Delphi DLL work as an Extension
>
> =============================================================
> For Distribution: Public
> This document relates to the following InstallShield Express product(s):
> Professional
> Target Platform(s): All Platforms
>
>
----------------------------------------------------------------------------

> ---------------------------------------------
> ISSUE:
>
----------------------------------------------------------------------------

> ---------------------------------------------
>
> I have a custom DLL function written in Delphi, but I can't seem to
launch
> it as an extension from my InstallShield Express installation.
>
>
----------------------------------------------------------------------------

> ---------------------------------------------
> DISCUSSION:
>
----------------------------------------------------------------------------

> ---------------------------------------------
>
> InstallShield Express can only launch DLL functions that are C-callable,
> i.e. can be launched from a C program. To make sure that your Delphi DLL
> function follows the standard C calling convention, be sure to include
the
> stdcall calling convention when declaring your function.
>
>
> Following is the code for a Delphi DLL that performs in a similar fashion
> to the C DLLs described in article X1068. Also attached is the compiled
> 32-bit DLL.
>
> library MyDelphi;
>
>
> uses
> Classes,
> SysUtils,
> Dialogs in 'Dialogs.pas',
> Windows in 'Windows.pas';
>
>
> function Foo(mainwin: Hwnd; szSrcDir, szSupport, szInst, szRes: LPSTR):
> Char; export; stdcall;
> var
> test1: String;
> begin
> test1 := Format('Extension Called!! HWND=%x, SRCDIR=%s, SUPPORTDIR=%s,
> INSTALLDIR=%s ', [mainwin, szSrcDir, szSupport, szInst]);
> MessageDlg(test1, mtInformation, [mbOk], 0);
> end;
>
>
> exports
> Foo index 1;
>
>
> begin
> end.
> --------------------------------------------------------
> Regards,
> Prabhu RP
>
> Aditi Corp.
> InstallShield Authorized Solution Provider
>
> Alex <Darkside_of_the_Moon@msn.com> wrote in article
> <01bc9c20$61cde020$8b1c86c2@zen>...
> > hi,
> >
> > Can anybody please e-mail or post the source to a simple Delphi DLL
that
> > can be used with Install Shield Express, any DLL I try to make causes a
> > Page Fault and it's driving me nuts
> >
> > Thanks in Advance
> >
> > Alex
> >
>

NewsArchive
02-04-1998, 01:00 AM
In the same vein, is there any way to use a Delphi DLL to return a value to the
installation program, such as the application directory (for an already
installed version)

NewsArchive
02-04-1998, 01:00 AM
On Wed, 04 Feb 1998 08:35:25 -0500, John Wollner <jwollner@home.com> wrote:
>In the same vein, is there any way to use a Delphi DLL to return a value to the
>installation program, such as the application directory (for an already

No, unfortunately not. You might try to write to the memory block of the
passed variable, but I'm not sure if you are allowed to.

Stefan
ellipse data systems

NewsArchive
02-27-1998, 01:00 AM
John Wollner wrote:
>
> In the same vein, is there any way to use a Delphi DLL to return a value to the
> installation program, such as the application directory (for an already
> installed version)

I have had luck setting the setting the InstallDir through a DLL
extension. I save the InstallDir as a registry value during setup. If
during setup, the value is already in the registry, I stuff the value
into InstallDir. The following DLL function called just prior to the
Choose Destination Location works fine for me:


....

function SetTarget(hWnd: THandle; SrcDir, SupportDir, InstallDir,
Reserved: LPSTR) : Char; stdcall;
var
reg: TRegistry;
dir: String;
begin
Result := #0;
try
reg := nil;
try
dir := '';
reg := TRegistry.Create;
reg.RootKey := Shift4RegRoot;
if reg.OpenKey(Shift4RegBase,False) then
dir := reg.ReadString('Installation Path');
if dir<>'' then
StrPCopy(InstallDir,dir);
finally
if Assigned(reg) then
reg.Free;
end;
Result := #1;
except
on e: Exception do
ShowMessage(e.Message);
end;
end;

exports
SetTarget;

....


DISCLAIMER: I never got an answer on the what the preallocated size of
"InstallDir", so I imagine if your path is very long, at some point,
memory might get corrupted.

Hope this helps...

--
Steve Sommers
Vice President of Applications Development
Shift4 Corporation -- Transaction Technology
http://www.shift4.com

NewsArchive
02-28-1998, 01:00 AM
On Fri, 27 Feb 1998 15:47:20 -0800, Steve Sommers <Steve@Shift4.com> wrote:
>I have had luck setting the setting the InstallDir through a DLL
>extension. I save the InstallDir as a registry value during setup. If
>during setup, the value is already in the registry, I stuff the value

Is this for Express or for IS5? If it is for Express, how do you get
Express to read it back?

Stefan
ellipse data systems

NewsArchive
03-02-1998, 01:00 AM
--------------741A6DD11275E7857A139196
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Dear Stefan,

If I might put in my two cents worth, I am using IS Express 2 and Delphi
1.02 DLLs.
The key to changing IS variables is in the fact that the parameters
passed to the custom DLL are merely pointers to the actual content of
the variables being used by IS. It is therefore possible to test, alter
or completely replace the current values assigned to any one of the
three directory specifiers that IS has passed a DLL pointer too. By the
way I use the following declarations and syntax:

function
ChkDir(HWnd:HWND;SrcDir,SupportDir,InstallDir,FutureUse:PChar):Char;export;

To extract the value InstallDir, I use TempDir := StrPas(InstallDir);
TempDir is type String.
To replace the value of InstallDir, I use StrPCopy(InstallDir,TempDir).

Now what would have been nice is if the return code was a little more
useful. As of this writing the return code of #0 terminates your install
whereas a value greater than #0; IS would assume success and continue
with the install process (using your new values for <INSTALLDIR>) It
would be even more useful if say the return value dictated what dialog
box would come up next.

Hope this helps,

Jamie Carper


Stefan Paetow wrote:

> On Fri, 27 Feb 1998 15:47:20 -0800, Steve Sommers <Steve@Shift4.com>
> wrote:
> >I have had luck setting the setting the InstallDir through a DLL
> >extension. I save the InstallDir as a registry value during setup.
> If
> >during setup, the value is already in the registry, I stuff the value
>
> Is this for Express or for IS5? If it is for Express, how do you get
> Express to read it back?
>
> Stefan
> ellipse data systems



--------------741A6DD11275E7857A139196
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Dear Stefan,

<P>If I might put in my two cents worth, I am using IS Express 2 and Delphi
1.02 DLLs.
<BR>The key to changing IS variables is in the fact that the parameters
passed to the custom DLL are merely pointers to the actual content of the
variables being used by IS. It is therefore possible to test, alter or
completely replace the current values assigned to any one of the three
directory specifiers that IS has passed a DLL pointer too. By the way I
use the following declarations and syntax:

<P><B>function</B> ChkDir(HWnd:HWND;SrcDir,SupportDir,InstallDir,FutureUse:PChar):Char;<B>export</B>;

<P>To extract the value InstallDir, I use <I>TempDir := StrPas(InstallDir)</I>;
TempDir is type <B>String.</B>
<BR>To replace the value of InstallDir, I use <I>StrPCopy(InstallDir,TempDir)</I>.

<P>Now what would have been nice is if the return code was a little more
useful. As of this writing the return code of #0 terminates your install
whereas a value greater than #0; IS would assume success and continue with
the install process (using your new values for &lt;INSTALLDIR>) It would
be even more useful if say the return value dictated what dialog box would
come up next.

<P>Hope this helps,

<P>Jamie Carper
<BR><B></B>&nbsp;

<P>Stefan Paetow wrote:
<BLOCKQUOTE TYPE=CITE>On Fri, 27 Feb 1998 15:47:20 -0800, Steve Sommers
&lt;Steve@Shift4.com> wrote:
<BR>>I have had luck setting the setting the InstallDir through a DLL
<BR>>extension.&nbsp; I save the InstallDir as a registry value during
setup.&nbsp; If
<BR>>during setup, the value is already in the registry, I stuff the value

<P>Is this for Express or for IS5? If it is for Express, how do you get
<BR>Express to read it back?

<P>Stefan
<BR>ellipse data systems</BLOCKQUOTE>
&nbsp;&nbsp;</HTML>

--------------741A6DD11275E7857A139196--

NewsArchive
03-04-1998, 01:00 AM
Stefan Paetow wrote:
>
> On Fri, 27 Feb 1998 15:47:20 -0800, Steve Sommers <Steve@Shift4.com> wrote:
> >I have had luck setting the setting the InstallDir through a DLL
> >extension. I save the InstallDir as a registry value during setup. If
> >during setup, the value is already in the registry, I stuff the value
>
> Is this for Express or for IS5? If it is for Express, how do you get
> Express to read it back?
>
> Stefan
> ellipse data systems

I am using Install Shield Express 2.0. As to how the information is
returned to ISX, read Jamie Carper's reply (if you haven't already done
so). He does a good job in explaining why my example works...

--
Steve Sommers
Vice President of Applications Development
Shift4 Corporation -- Transaction Technology
http://www.shift4.com

NewsArchive
03-05-1998, 01:00 AM
On Wed, 04 Mar 1998 16:32:07 -0800, Steve Sommers <Steve@Shift4.com> wrote:
>I am using Install Shield Express 2.0. As to how the information is
>returned to ISX, read Jamie Carper's reply (if you haven't already done
>so). He does a good job in explaining why my example works...

I've noticed :)

Very nifty :) - Thanks :)

Stefan
ellipse data systems

NewsArchive
04-02-1998, 01:00 AM
Stefan Paetow <owner@ellipse-data.com> wrote in article
<34f854a7.31679142@news.installshield.com>...
> On Fri, 27 Feb 1998 15:47:20 -0800, Steve Sommers <Steve@Shift4.com>
wrote:
> >I have had luck setting the setting the InstallDir through a DLL
> >extension. I save the InstallDir as a registry value during setup. If
> >during setup, the value is already in the registry, I stuff the value
>
> Is this for Express or for IS5? If it is for Express, how do you get
> Express to read it back?
>
> Stefan
> ellipse data systems
>
How do you use Delphi DLL's with IS5? I've tries this declaration without
much success:

function CreateSerialNumber : PChar; stdcall;

I can get this function to work from another Delphi app but not from
InstallShield. What do you have to do?

Shaun Parry

NewsArchive
04-02-1998, 01:00 AM
On 2 Apr 98 15:46:31 GMT, "Shaun Parry" <sparry@castle-cadenza.demon.co.uk>
wrote:
>How do you use Delphi DLL's with IS5? I've tries this declaration without
>much success:
>
>function CreateSerialNumber : PChar; stdcall;

InstallShield 5.1 uses a different calling scheme. If you change your call
to a procedure in Delphi you might get it working, since you then call your
function with parameters using the BYREF reserved word, e.g:

procedure CreateSerialNumberP(SerialNum: PChar); stdcall;

Then you can call this function using the following call:

SERDLL.CreateSerialNumberP(BYREF szSerialNum);

SERDLL is the NAME of your DLL without the .DLL extension.

Stefan
ellipse data systems