How to use CALL DLL FUNCTION

Interested in developing new plug-ins? Got one to share? Post here!
donj
Posts: 4
Joined: Fri May 11, 2007 12:33 am

How to use CALL DLL FUNCTION

Postby donj » Fri May 11, 2007 12:44 am

I'm new to installAware....
I have a dll that carries out some custom actions... (eg like registering a service) It's written in native C++ code. The function that I want to call using CALL DLL FUNCTION property is

UINT __stdcall RegisterAction(MSIHANDLE hInstall).

I've tried using
Call DLL Function $TARGETDIR$\\CtInst.dll->RegisterAction

is this the correct way to call this function?
and if not what is the correct way of calling?
any help would be appreciated...

Thanks in advance.

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Sat May 12, 2007 9:17 am

You may want to paste the full command, so we can see the parameters.
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/

donj
Posts: 4
Joined: Fri May 11, 2007 12:33 am

Postby donj » Sat May 12, 2007 11:07 pm

This is part of the code in my custom dll. I also want to pass in the $TARGETDIR$ into the RegisterAction function. How do I do that as well???

extern "C"
UINT __stdcall RegisterAction(MSIHANDLE hInstall)
{
DWORD Size = 0;
WCHAR szFullPath[MAX_PATH] = { 0 };
WCHAR szFullPath2[MAX_PATH] = { 0 };
WCHAR szActionData[MAX_PATH] = { 0 };

Size = sizeof(szActionData);

MsiGetProperty( hInstall, L"CustomActionData", szActionData, &Size );

_snwprintf( szFullPath, ARRAY_SIZE(szFullPath), L"%s\\\\%s",
szActionData, L"CtBho.dll" );

UnRegisterComLibrary( szFullPath );
RegisterComLibrary( szFullPath );

_snwprintf( szFullPath, ARRAY_SIZE(szFullPath), L"%s\\\\%s",
szActionData, L"CtToolBand.dll" );





After copying the source files dlls etc.. I use CALL DLL FUNCTION property... I need to pass the $TARGETDIR$ not sure how to do that as well.... Is there a set msi property call of something?

If Variable SELECTED Equals TRUE
...
...

Install Files C:\\Binaries\\CtInst.dll to $TARGETDIR$
end

Set Variable ReturnVal to

Call DLL Function $TARGETDIR$\\CtInst.dll->RegisterAction (get result into Variable ReturnVal)

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Sun May 13, 2007 10:36 am

I wasn't really asking for the source code of the DLL, but the Call DLL Function command. Just copy it to the clipboard and paste it directly here, do not paste as regular text as that loses the parameters you have defined in the command.

You can choose parameters to pass in the Call DLL Function command - that is how you will pass $TARGETDIR$ in, for example.
Michael Nesmith

InstallAware

Home of The Next Generation MSI Installer

Get your free copy today - http://www.installaware.com/

donj
Posts: 4
Joined: Fri May 11, 2007 12:33 am

Postby donj » Sun May 13, 2007 7:09 pm

Sorry Michael, I'm still new in this...
Anyway here it is.... In my Dll there is a MSIGetProperty that get's the TARGETDIR from "CustomActionData". so how do I set this "CustomActionData" property from InstallAware?

~InstallAware Clipboard Data~
~Call DLL Function~
~{DD34E37B-F5E2-41BA-892D-B2E3F3627B32}~
~$TARGETDIR$\\CtInst.dll,RegisterAction,long,ReturnVal,$~
~mIDEFunc.dll\\mEXEFunc.dll~

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Mon May 14, 2007 11:22 am

Ah, I see what you are trying to do now. TARGETDIR is not an MSI property, so you cannot get it in this way. In fact, a handle to your MSI database will not even exist until Apply Install is running.

You will need to rewrite your DLL code a little. You can directly pass in TARGETDIR as a parameter without having to use MSI properties as an intermediate medium.

For instance, here is a Call DLL Function command which would pass TARGETDIR as a constant string parameter to your DLL:

~InstallAware Clipboard Data~
~Call DLL Function~
~{5AFA5FFC-AC4F-4C4D-9B07-23802ECAA0B9}~
~$TARGETDIR$\\CtInst.dll,RegisterAction,long,ReturnVal,"pointer to string",$TARGETDIR$,$~
~~mIDEFunc.dll\\mEXEFunc.dll~~


Of course you then have to change your function prototype in your DLL to accept a string value instead of a handle, but that should be easy to do!
Michael Nesmith

InstallAware

Home of The Next Generation MSI Installer

Get your free copy today - http://www.installaware.com/

pushpankar
Posts: 5
Joined: Mon Apr 16, 2012 12:46 am

Re: How to use CALL DLL FUNCTION and Run .NET Class

Postby pushpankar » Mon Apr 16, 2012 7:33 am

hi

i am using run .net installer class method which calls the assembly name.
my assemble(dll) overrides the installer method of windows and opens the New form to open a license form.
but run .net installer class method does not execute i.e it does not open any form

i also used call dll function and in the dll i have written a method which open a window form but this also not seems to be working.

Kindly reply


Is there any other way to do it

my need is i want to open a window form for license key for while installation,Kindly tell what is the appropriate way to do it

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: How to use CALL DLL FUNCTION

Postby FrancescoT » Tue Apr 17, 2012 9:41 am

Dear User,

I really suspect that it happens because you are using Managed Code Dll ... the DLL CALL requires a Native (as C\C++) dll.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

pushpankar
Posts: 5
Joined: Mon Apr 16, 2012 12:46 am

Re: How to use CALL DLL FUNCTION

Postby pushpankar » Wed Apr 18, 2012 12:57 am

hi
i am managed to call a ,net installer class using Run .net installer method of installaware script
in the Install method i need to set the Target dir path (path where product gets installed)

in windows i used to get it through

Me.Context.Parameters.Item("DIR").ToString
how should i get in a installer class using install aware.

Public Overrides Sub Install(ByVal savedState As IDictionary)
MyBase.Install(savedState)
If ProjectOpKey.OpkeyEdition <> OpkeyEditions.Lite Then
Dim LV As New LicenseValidator
LV.DirPath = Me.Context.Parameters.Item("DIR").ToString /////////here i am getting the target dir path.
If LV.ShowDialog = Windows.Forms.DialogResult.OK Then
Else
Throw New InstallException("Rolling Back Installation...")
End If
End If
End Sub

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: How to use CALL DLL FUNCTION

Postby FrancescoT » Wed Apr 18, 2012 8:32 am

Dear User,

I really think that "Run .net installer" can't be used in this way.

are you able to run an EXE that execute your code?

Or probably .... I am just proposing you a possible alternative ... if you write somewhere the PATH value, it could be an INI file or else that you prefer. After you could read the value from you net class once executed calling "Run .net installer". Probably it works!

otherwise the only solution it is to realize a DLL in C/C++ or Delphi.

Regards.
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

pushpankar
Posts: 5
Joined: Mon Apr 16, 2012 12:46 am

Re: installaware installation process.

Postby pushpankar » Wed May 23, 2012 10:39 pm

1)when install aware install product on the system,how i will get the installed path using .NET
in windows i used to get it using
System.Windows.Forms.Application.StartupPath

2)while installation i am using MSI script RUN .NET Installer class and .net installer class open a license form
my requirement is that when user click on cancel button i want to Roll Back the installer

Kindly revert how should i do.


Kindly revert

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: How to use CALL DLL FUNCTION

Postby FrancescoT » Thu May 24, 2012 6:53 am

Dear User,

1)when install aware install product on the system,how i will get the installed path using .NET
in windows i used to get it using
System.Windows.Forms.Application.StartupPath

If you want to obtain the path of an already installed product fron Net code, you can refer to Windows Registry for the value of the key "InstallLocation", under;

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{PRODUCT CODE GUI}
if the installation has been executed per machine.

or,

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\{PRODUCT CODE GUI}
If the Installation has been executed per user.

2)while installation i am using MSI script RUN .NET Installer class and .net installer class open a license form
my requirement is that when user click on cancel button i want to Roll Back the installer

The problem here is that "RUN .NET Installer class" doesn't return any value, how do you capture the cancel action from your form?

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Plug-In Development”

Who is online

Users browsing this forum: No registered users and 17 guests