cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Sweetie
Level 3

Need help for DLL custom action

Hi Guys,

I am new to installshield and need your help. We have created our project in Basic MSI and now we would like to convert our project to pure installscript. I know if we convert our project from Msi to Installscript we will miss our custom action and we should use installscript code to achieve this. We have created our DLL by using the Vc++ (by use of visual studio). Now I would like to use this DLL in my Installscript project... Can you please let me know the way with sample example to do this.
how to call the functions that used in the DLL and how to return the DLL function results.

Thanks for your help

Regards
Sweetie
Labels (1)
0 Kudos
(9) Replies
sandeep_madhu14
Level 6

What package you are creating either full inatallation or patch?
Which installashield version you are using?

thanks
madhu.
0 Kudos
ChandanOmkar
Level 8

Copy your VC++ dll to SupportFIles/Billboards ->SupportFiles ->Language Independent. It will copy your file to the tempfolder during installation.

Then you can use this dll to diiferent functions of installscript. But first you need to load this dll before using it. Also you need to unload it after using.

e.g.

function load()

STRING dllPath;
begin

dllPath = SUPPORTDIR ^ "Test.dll";
if ( 0 != UseDLL(dllPath) ) then
MessageBox("Failed to load dependency file", SEVERE);
abort;
endif;
end;


Let me know if need any more help.
0 Kudos
sandeep_madhu14
Level 6

After copying dll in to components you can use the following function to check the dll exists and then you can use the dll..

Here i have taken ldf_jpm_dotNET.dll as an example..

function DllInfo()
NUMBER nResult;
begin

nResult = Is(FILE_EXISTS, INSTALLDIR^ "ldf_jpm_dotNET.dll");
if nResult = TRUE then
// SprintfBox (INFORMATION, "DELETE DLL", "%s is Present .", INSTALLDIR^ "ldf_jpm_dotNET.dll");

// Delete the file specified by DEL_FILE from the target directory.

End;
thanks
madhu
0 Kudos
Sweetie
Level 3

Thank you for your reply.

Yes, I know how to load and unload the DLL. My problem is we are using the DLL custom action in Basic MSi and calling the function in the variouse sequence for example,

DLL Filename - aaaInstall.dll
Function name- CheckXPSystem
In-script Execution- Immediate Execution
Execution Scheduling -Always Execute
Install UI sequence - After launchCondition

and some other function in After InstallFinalize, After PublishProduct

now, where I have to call this function in Pure installscript events and how to call the function?

I am creating Full Installation with Installshield 2010.

Thanks
0 Kudos
Sweetie
Level 3

Please help me with this, it's very urgent. Thanks

Sweetie wrote:
Thank you for your reply.

Yes, I know how to load and unload the DLL. My problem is we are using the DLL custom action in Basic MSi and calling the function in the variouse sequence for example,

DLL Filename - aaaInstall.dll
Function name- CheckXPSystem
In-script Execution- Immediate Execution
Execution Scheduling -Always Execute
Install UI sequence - After launchCondition

and some other function in After InstallFinalize, After PublishProduct

now, where I have to call this function in Pure installscript events and how to call the function?

I am creating Full Installation with Installshield 2010.

Thanks
0 Kudos
sandeep_madhu14
Level 6

sweetie,

check the following link it may help you.........

http://community.installshield.com/showthread.php?t=137881&highlight=call+dll+function

if it is not helpful let me know......

thanks
madhu
0 Kudos
ChandanOmkar
Level 8

I am attaching you a piece of code which is working for me. This piece of code gets executed during uninstall of the product. Actually installscript does not have the FOREACH function, and only due to that i need to use the C++ dll to remove the websites/Virtual directories from the IIS which are linked to a particular physical folder only. You can call these functions in your custom actions also.
Choose the option "Run the installscript code" in the custom action wizard, and then select the function name. The function name will apppear here only if the function prototype is defined with the export keyword.

export prototype Foo();


Hope this will help you.
0 Kudos
forcet
Level 4

ChandanOmkar is right. create an object using CoGetObject function, then u can call its method. the example from installshield manual is attached.

CoGetObject Example
InstallShield 2010 » InstallScript Language Reference

/*-----------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the CoGetObject function.

*

* This example shows how to create a virtual

* directory on IIS server.

*

\*-----------------------------------------------------------*/


#include "ifx.h"


#define VIRTUALDIR "My Virtual Dir"

#define VIRTUALDIRPATH "c:\inetpub\wwwroot\MyDir"


function OnBegin()

OBJECT objIIS_Root, objVirtDir;


begin


set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");


if (IsObject(objIIS_Root)) then

try

set objVirtDir = objIIS_Root.Create("IISWebVirtualDir", VIRTUALDIR);


if (IsObject(objVirtDir)) then

objVirtDir.Path = VIRTUALDIRPATH;

objVirtDir.AccessRead = TRUE;

objVirtDir.AccessScript = TRUE;

objVirtDir.SetInfo();

objVirtDir.AppCreate(TRUE);

objVirtDir.SetInfo();

endif;

catch

MessageBox("Unable to create Virual Directory.", INFORMATION);

endcatch;

endif;



end;
0 Kudos
Raghvendra
Level 4

ChandanOmkar wrote:
Copy your VC++ dll to SupportFIles/Billboards ->SupportFiles ->Language Independent. It will copy your file to the tempfolder during installation.

Then you can use this dll to diiferent functions of installscript. But first you need to load this dll before using it. Also you need to unload it after using.

e.g.

function load()

STRING dllPath;
begin

dllPath = SUPPORTDIR ^ "Test.dll";
if ( 0 != UseDLL(dllPath) ) then
MessageBox("Failed to load dependency file", SEVERE);
abort;
endif;
end;


Let me know if need any more help.


Hi Sir,

I need to call a function of my loaded dll. And I am trying to do it but I am getting an error (2147219709). please help me on this. I am posting my code below


prototype stdcall INT SocialSafeDll.Add(INT,INT);
export prototype ExFn_UseDLL(HWND);


function ExFn_UseDLL(hMSI)

NUMBER nResult;
STRING supportDirPath, szPath;
NUMBER nLength;
INT returnValue;

begin

nLength = 256;
// Returns path to the Support files path extracted on the target machine.
MsiGetProperty(hMSI, "SUPPORTDIR", supportDirPath,nLength);
szPath = supportDirPath ^ "SocialSafeDll.dll";

// Load the .dll file into memory.
nResult = UseDLL(szPath);
if (nResult = 0) then
MessageBox ("UseDLL successful \n\n.dll file loaded.", INFORMATION);
else
MessageBox ("UseDLL failed.\n\nCouldn't load .dll file.", INFORMATION);
abort;
endif;


try
MessageBox ("before loading in try block", INFORMATION);
returnValue = SocialSafeDll.Add(2,3);
MessageBox ("after loading in try block", INFORMATION);
catch
MessageBox ("in catch block" + Err, INFORMATION);
endcatch;

SprintfBox (INFORMATION, "UseDLL", "MydllReturn() changed the string " +"to: %d", returnValue);




// Remove the .dll file from memory.
if (UnUseDLL (szPath) < 0) then
MessageBox ("UnUseDLL failed.\n\n.dll file still in memory.", SEVERE);
else
MessageBox ("UnUseDLL successful.\n\n.dll file removed from memory.",
INFORMATION);
endif;
end;
0 Kudos