Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to use an dll in InstallScript


2 replies to this topic

FerFemNemBem

FerFemNemBem
  • Members
  • 27 posts

Posted 25 October 2001 - 21:04

Hi,

i have to determine the version of the MFClasses during installation. Therefore i neet do extract the file "Version.txt" from a *.zip file.
Now i want to use a unzip.dll but can't find a way to use the functions of this dll.
Can anyone give me a simple example how to work with dll files from Installscript?

Thank you.

PS: IS7Dev. Standard Project.


mdoggett

mdoggett
  • Members
  • 11 posts

Posted 26 October 2001 - 11:38

First of all the need to use the UseDLL command to open the DLL (don't forget the UnUseDLL command at the end to close it)

Then specify the prototypes of the functions you wish to import. For example if you has a function called "test" in your "unzip.dll" which accepted a string and returned an integer you would define the prototype as.

prototype NUMBER UNZIP.test(STRING); (notice that you have to include the name of the DLL in the prototype.

Its important to make sure that the argument list for the function matches up. This is especially important when using a function from a C++ dll becaue of the way C++ mangles names. Therefore if using a C++ dll you must put the command "cdecl" after the word prototype.

It is then just a case of calling the function from within the script. For example to call the "test" function defined above you can use either of the following syntaxes

nResult  = test(szTestString);

or

nResult = UNZIP.test(szTestString);

The second method is useful if you have multiple DLL files containing functions with the same name.

Hope this is of some help

Mark


FerFemNemBem

FerFemNemBem
  • Members
  • 27 posts

Posted 26 October 2001 - 13:16

Hi,

Thank you verry much !
Here the codesnip, that works now for me (if any other is interested...)

Code Sample

snip
.
.
prototype  GetUnzipDllVersion();
prototype  NUMBER unzdll.GetUnzDllVersion();
.
.
.
function GetUnzipDllVersion()

   #define UNZIPDLLNAME SUPPORTDIR ^ "unzdll.dll"
   
   STRING svValue;
   NUMBER nResult;
   
begin
   if UseDLL(UNZIPDLLNAME) = 0 then
       nResult =   GetUnzDllVersion();
       NumToStr    (svValue, nResult);
       MessageBox  (svValue, INFORMATION);
       else
           MessageBox("Error load " + UNZIPDLLNAME + ".", SEVERE);
   endif;
   UnUseDLL(UNZIPDLLNAME);
end;
.
.
snap

Regards, FFNB

(Edited by FerFemNemBem at 1:17 pm on Oct. 26, 2001)