This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Calling a .dll File Function
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 28, 2009
05:33 AM
Calling a .dll File Function
Hi all
I have made an Install script file as following
//----------------------------------------------------------------------------
#include "ifx.h"
// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
prototype void AddToReg.AddtoRegistry(BYREF STRING);
export prototype MyFunction(HWND);
function MyFunction(hMSI)
NUMBER nResult;
STRING path;
begin
path = INSTALLDIR;
UseDLL (SUPPORTDIR ^ "AddToReg.dll");
MessageBox ("UseDLL successful \n\n.dll file loaded.", INFORMATION);
MessageBox(path, INFORMATION);
AddToReg.AddtoRegistry(path);//-------------> This line doesn't executed
MessageBox("AddToReg", INFORMATION);
MessageBox(path, INFORMATION);
UnUseDLL (SUPPORTDIR ^ "AddToReg.dll");
MessageBox ("UnUseDLL successful.\n\n.dll file removed from memory.", INFORMATION);
end;
//--------------------------------------------------------------------------------
Is the following line true?
DLLName.FunctionName(parameter)
AddToReg.AddtoRegistry(path);//-------------> This line doesn't executed
Thank You in advance
I have made an Install script file as following
//----------------------------------------------------------------------------
#include "ifx.h"
// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
prototype void AddToReg.AddtoRegistry(BYREF STRING);
export prototype MyFunction(HWND);
function MyFunction(hMSI)
NUMBER nResult;
STRING path;
begin
path = INSTALLDIR;
UseDLL (SUPPORTDIR ^ "AddToReg.dll");
MessageBox ("UseDLL successful \n\n.dll file loaded.", INFORMATION);
MessageBox(path, INFORMATION);
AddToReg.AddtoRegistry(path);//-------------> This line doesn't executed
MessageBox("AddToReg", INFORMATION);
MessageBox(path, INFORMATION);
UnUseDLL (SUPPORTDIR ^ "AddToReg.dll");
MessageBox ("UnUseDLL successful.\n\n.dll file removed from memory.", INFORMATION);
end;
//--------------------------------------------------------------------------------
Is the following line true?
DLLName.FunctionName(parameter)
AddToReg.AddtoRegistry(path);//-------------> This line doesn't executed
Thank You in advance
(5) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 28, 2009
12:06 PM
Does the UseDLL call succeed? In an MSI project, the SUPPORTDIR property is different from the SUPPORTDIR variable, so perhaps try getting the property value instead?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 29, 2009
01:51 AM
RobertDickau wrote:
Does the UseDLL call succeed? In an MSI project, the SUPPORTDIR property is different from the SUPPORTDIR variable, so perhaps try getting the property value instead?
First.. Thank you for your help.
I am using Basic MSI Project. I tried to debug the project and the UseDLL call succeeded.
But I don't know how to call a method from thd dll?
I followed the steps were in the InstallShield Help.
What is the difference between SUPPORTDIR as variable and SUPPORTDIR as property?
Thank You in advance
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 29, 2009
12:18 PM
The help topic "SUPPORTDIR" gives some information about the difference between the property and the variable.
What type of DLL is it? (You might post a skeleton inside [code] and [/code] tags.) If it's a C-callable DLL, you can use that type of prototype with UseDLL. For COM methods there's CoCreateObject, and for .NET methods there's DotNetCoCreateObject...
What type of DLL is it? (You might post a skeleton inside [code] and [/code] tags.) If it's a C-callable DLL, you can use that type of prototype with UseDLL. For COM methods there's CoCreateObject, and for .NET methods there's DotNetCoCreateObject...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 02, 2009
02:41 AM
Thank You for help and for this important Note which I didn't know:)
I tried the following code but it also doesn't work 😞
[code]
function MyFunction(hMSI)
// To Do: Declare local variables.
string simpleMessage,dllPath,className;
object myDLLObj;
STRING path;
OBJECT oObj;
NUMBER nResult, nvBufferSize;
STRING sDLL;
STRING svSupportDir[MAX_PATH];
NUMBER cchValueBuf;
STRING szWinDomain,szWinUser,szWinPass;
begin
// To Do: Write script that will be executed when MyFunction is called.
path = INSTALLDIR;
nvBufferSize = MAX_PATH;
try
MsiGetProperty(hMSI, "SUPPORTDIR", svSupportDir, nvBufferSize);
catch
SprintfBox( WARNING,"Error", "MsiGetProperty(SUPPORTDIR) failed with error %s", FormatMessage( Err.Number ) );
return -1;
endcatch;
sDLL = svSupportDir ^ "ManagedDLL.dll";
//sDLL = SUPPORTDIR ^ "AddToReg.dll";
if(UseDLL( sDLL )= 0)then
MessageBox("Thanks", INFORMATION);
endif;
//nResult = UseDLL(SUPPORTDIR^"ManagedDLL.dll");
//if(nResult = 0)then
//MessageBox("Loaded",INFORMATION);
//else
//MessageBox("Failed to be Loaded",INFORMATION);
//endif;
dllPath = SUPPORTDIR ^ "ManagedDLL.dll";
MessageBox("Path to DLL: " + dllPath,INFORMATION);
className = "MyClass";
//------------------------- Shaimaa -------------------------//
//Gets the domain
cchValueBuf = 512;
nResult = MsiGetProperty(hMSI, "WINDOMAINNAME", szWinDomain, cchValueBuf);
//Gets the user
cchValueBuf = 512;
nResult = MsiGetProperty(hMSI, "WINUSERNAME", szWinUser, cchValueBuf);
//Gets the password
cchValueBuf = 512;
nResult = MsiGetProperty(hMSI, "WINUSERPASSWORD", szWinPass, cchValueBuf);
//Test all properties
MessageBox("Domain name :"+ szWinDomain + " User name : " + szWinUser+ " Password : " +szWinPass, INFORMATION);
//------------------------- Shaimaa -------------------------//
try
//set myDLLObj = DotNetCoCreateObject(dllPath,className,"");
MessageBox(sDLL,INFORMATION);
//set myDLLObj = DotNetCoCreateObject(sDLL,className,"");
set myDLLObj = DotNetCoCreateObject(sDLL,"ManagedDLL.MyClass","");
catch
MessageBox(Err.Number , SEVERE);
//MessageBox("It finally worked....",INFORMATION);
endcatch;
// myDLLObj.log();
myDLLObj.MyFunc();
end;
[/code]
Error No. -2147219705 appears ... I don't know what is the problem.
Thank You in advance.
I tried the following code but it also doesn't work 😞
[code]
function MyFunction(hMSI)
// To Do: Declare local variables.
string simpleMessage,dllPath,className;
object myDLLObj;
STRING path;
OBJECT oObj;
NUMBER nResult, nvBufferSize;
STRING sDLL;
STRING svSupportDir[MAX_PATH];
NUMBER cchValueBuf;
STRING szWinDomain,szWinUser,szWinPass;
begin
// To Do: Write script that will be executed when MyFunction is called.
path = INSTALLDIR;
nvBufferSize = MAX_PATH;
try
MsiGetProperty(hMSI, "SUPPORTDIR", svSupportDir, nvBufferSize);
catch
SprintfBox( WARNING,"Error", "MsiGetProperty(SUPPORTDIR) failed with error %s", FormatMessage( Err.Number ) );
return -1;
endcatch;
sDLL = svSupportDir ^ "ManagedDLL.dll";
//sDLL = SUPPORTDIR ^ "AddToReg.dll";
if(UseDLL( sDLL )= 0)then
MessageBox("Thanks", INFORMATION);
endif;
//nResult = UseDLL(SUPPORTDIR^"ManagedDLL.dll");
//if(nResult = 0)then
//MessageBox("Loaded",INFORMATION);
//else
//MessageBox("Failed to be Loaded",INFORMATION);
//endif;
dllPath = SUPPORTDIR ^ "ManagedDLL.dll";
MessageBox("Path to DLL: " + dllPath,INFORMATION);
className = "MyClass";
//------------------------- Shaimaa -------------------------//
//Gets the domain
cchValueBuf = 512;
nResult = MsiGetProperty(hMSI, "WINDOMAINNAME", szWinDomain, cchValueBuf);
//Gets the user
cchValueBuf = 512;
nResult = MsiGetProperty(hMSI, "WINUSERNAME", szWinUser, cchValueBuf);
//Gets the password
cchValueBuf = 512;
nResult = MsiGetProperty(hMSI, "WINUSERPASSWORD", szWinPass, cchValueBuf);
//Test all properties
MessageBox("Domain name :"+ szWinDomain + " User name : " + szWinUser+ " Password : " +szWinPass, INFORMATION);
//------------------------- Shaimaa -------------------------//
try
//set myDLLObj = DotNetCoCreateObject(dllPath,className,"");
MessageBox(sDLL,INFORMATION);
//set myDLLObj = DotNetCoCreateObject(sDLL,className,"");
set myDLLObj = DotNetCoCreateObject(sDLL,"ManagedDLL.MyClass","");
catch
MessageBox(Err.Number , SEVERE);
//MessageBox("It finally worked....",INFORMATION);
endcatch;
// myDLLObj.log();
myDLLObj.MyFunc();
end;
[/code]
Error No. -2147219705 appears ... I don't know what is the problem.
Thank You in advance.