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

Problem in accessing DLL functions in IS6.31


5 replies to this topic

pari

pari
  • Members
  • 2 posts

Posted 21 March 2002 - 01:32

Hi,
I have external DLL which I load and access its functions inside the script.
I have doen it successfully in IS5.5.
Since I am upgrading to IS6.31 , same DLL functions are not working.
e.g. Dll name : MyDLL
Function : MyFunction(STRING str)

UseDLL is working fine : DLL is loaded properly.
When accessing function , MyFunction(str) , it displays error message "an error occured while launching the setup.(0x80040704)".

Is there anything changed from IS5.5 to IS6.31 which is giving problem ?

Is there any special requirement on DLL side ?

I would appreciate your help.

Ide Nentjes

Ide Nentjes
  • Members
  • 222 posts

Posted 21 March 2002 - 10:04

Hi Pari,

The problem might be thta IS expect the function to have its argument passed by reference. To circumvent this you can try this:

prototype MyDll.Myfunction(BYREF STRING);

and use it in your scripts as

svString = "blahblah";
MyFunction(svString);

(so not! MyFunction("blahblah"); )

HtH, Ide

EberhardH

EberhardH
  • Members
  • 137 posts

Posted 21 March 2002 - 15:02

Hi Pari,

some days ago I experienced just the same problem: using a function inside of a DLL worked fine with IS 5.5 but failed with 6.31.

I succeeded with modifying the declaration:

Instead of (5.5 like)
prototype SHORT MyDLL.Function(STRING);

write this (successful with 6.31):
prototype cdecl SHORT MyDLL.Function(BYREF STRING);
//the cdecl is the important thing!

Regards,
Eberhard

MKaiser

MKaiser
  • Full Members
  • 88 posts

Posted 21 March 2002 - 16:26

besides the problem with cdecl IS has changed the default behaviour of STRING parameters in function prototypes.

In IS 5.5

prototype INT my_dll.tralala(STRING);

means that STRING is passed byref.

In IS6.x

prototype INT my_dll.tralala(STRING);

means that STRING  is passed byval. You have to explicitely define
prototype INT my_dll.tralala(BYREF STRING);

to achieve the same results.

Regards,
Marko

pari

pari
  • Members
  • 2 posts

Posted 21 March 2002 - 17:04

Dear Friends,

1. I was already using BYREF which is required.
2. I was not using cdecl. I changed my defination with cdecl as suggested and It worked.

Thanks a lot for all of you who have replied.

Keep up the good work.

Cheers,
pari

Blake Miller Wonder

Blake Miller Wonder
  • Members
  • 121 posts

Posted 21 March 2002 - 18:14

Inside the C or C++ DLL I declare and functions to be accessed by InstallShield as follows:

extern "C"
LONG WINAPI MyFunction(LPTSTR);

This prevents the name from being mangled and it declares it to use the PASCAL calling convention.  I also add each function name (case sensitive) that is to be exported to a module definition file (.DEF).

Within the header file the InstlalShield includes, the prototype would be as follows:

protoype MyDll.MyFunction(BYREF STRING);

I do not need the cdecl and I do not need to tell it it is returning LONG, since the function is doing that already and that is apparently the default assumption of InstallShield.

Then I do not need to change the header file or the DLL for either version of InstallShield.