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
- :
- another 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
‎Aug 19, 2008
02:21 AM
calling a dll function
Hi,
I'm facing some problems in calling dll functions.
The problem is as:
I need to call some dll functions namely: Start, Get and Stop.
The call to these may look like(in C++):
byte bNos = 0xfff;
short handle = Start(0x03000001, bNos);
//Call to the Get() function as : handle = Get(parameters);
handle = Stop();
I tried calling 'em but got everytime got the error: Unhandled Exception
Error No:0x80040707
Dll function call crashed: MyDll.Start()
Setup will now Terminate.
Could some one plz help me with, how to call all of the functions with the datatypes, I think i'm getting stuck in 'em.
Thanks in advance. 🙂
I'm facing some problems in calling dll functions.
The problem is as:
I need to call some dll functions namely: Start, Get and Stop.
The call to these may look like(in C++):
byte bNos = 0xfff;
short handle = Start(0x03000001, bNos);
//Call to the Get() function as : handle = Get(parameters);
handle = Stop();
I tried calling 'em but got everytime got the error: Unhandled Exception
Error No:0x80040707
Dll function call crashed: MyDll.Start()
Setup will now Terminate.
Could some one plz help me with, how to call all of the functions with the datatypes, I think i'm getting stuck in 'em.
Thanks in advance. 🙂
(8) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 19, 2008
12:37 PM
What do the InstallScript prototypes look like? What are the actual C++ function prototypes (as opposed to sample calls)?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 19, 2008
11:12 PM
Hi Robert,
Thx for your response.
The function prototype is like:
prototype cdecl NUMBER MyDll.Start( NUMBER, NUMBER );
And the C++ function prototype looks like:
int Start(int,int &);
Ok. I got your point.
But how to pass the value by ref in installscript?
This didn't help:
NUMBER nNos;
prototype cdecl NUMBER MyDll.Start (NUMBER, BYREF NUMBER);
.
.
.
nNos = 0xfff;
handle = MyDll.Start(0x3000001, BYREF nNos);
Compilation Error:-
'BYREF' : missing expression.
If I change the call to:-
handle = MyDll.Start(0x3000001, nNos);
Error thrown:-
Function call resulted in bad stack.
How to call the function? Plz help.
Thanks in advance. 🙂
Thx for your response.
The function prototype is like:
prototype cdecl NUMBER MyDll.Start( NUMBER, NUMBER );
And the C++ function prototype looks like:
int Start(int,int &);
Ok. I got your point.
But how to pass the value by ref in installscript?
This didn't help:
NUMBER nNos;
prototype cdecl NUMBER MyDll.Start (NUMBER, BYREF NUMBER);
.
.
.
nNos = 0xfff;
handle = MyDll.Start(0x3000001, BYREF nNos);
Compilation Error:-
'BYREF' : missing expression.
If I change the call to:-
handle = MyDll.Start(0x3000001, nNos);
Error thrown:-
Function call resulted in bad stack.
How to call the function? Plz help.
Thanks in advance. 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 20, 2008
09:06 AM
To pass by reference, the BYREF keyword is needed only in the prototype and not the function call (as in your last example). With the bad-stack error, perhaps try leaving out the cdecl modifier?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 21, 2008
12:51 AM
Hi Robert,
Thanks for the reply & help.
I declared the prototype with the BYREF keyword & the removal of cdel modifier also seems to work fine for the function Start. But how come the cdecl modifier was the culprit?
I'll check with the Get & Stop functions and if I face any problems, then shall post a reply very soon.
Thanks a lot. 🙂
Thanks for the reply & help.
I declared the prototype with the BYREF keyword & the removal of cdel modifier also seems to work fine for the function Start. But how come the cdecl modifier was the culprit?
I'll check with the Get & Stop functions and if I face any problems, then shall post a reply very soon.
Thanks a lot. 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 21, 2008
07:05 AM
Hi Robert,
The removal of cdecl modifier stopped the error: function call resulted in bad stack. But the call to the function is not returning the desired output through the output parameter.
Could you please suggest a suitable prototype for the same function?
The C++ version of the function looks like:
int Start(parameter1, paramenter2);
The parameter1 is of the type DWORD and then parameter2 is of the type byte(parameter2 is ouput parameter).
In installscript I've declared the prototype as:
prototype NUMBER MyDll.Start( NUMBER, BYREF NUMBER ); //prototype declaration.
and in the function call also I've passed the parameters as:
NUMBER nParam1,nParam2;
MyDll.Start(nParam1,nParam2); //function call
Is the usage correct? I'm not getting the output as desired from the param2. It is always returning the value 0. :confused: And the problem is that i need to use the same value in calling another (Get()) function.
Could you provide a sample code? 😮
Thanks in advance. 🙂
The removal of cdecl modifier stopped the error: function call resulted in bad stack. But the call to the function is not returning the desired output through the output parameter.
Could you please suggest a suitable prototype for the same function?
The C++ version of the function looks like:
int Start(parameter1, paramenter2);
The parameter1 is of the type DWORD and then parameter2 is of the type byte(parameter2 is ouput parameter).
In installscript I've declared the prototype as:
prototype NUMBER MyDll.Start( NUMBER, BYREF NUMBER ); //prototype declaration.
and in the function call also I've passed the parameters as:
NUMBER nParam1,nParam2;
MyDll.Start(nParam1,nParam2); //function call
Is the usage correct? I'm not getting the output as desired from the param2. It is always returning the value 0. :confused: And the problem is that i need to use the same value in calling another (Get()) function.
Could you provide a sample code? 😮
Thanks in advance. 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 21, 2008
08:03 AM
Hi,
One of the functions which I need to call from the installscript project is the Get function. The parameters of which are as follows:(in C++)
Get(param1,param2)->param1 & param2 are both output parameters.
They can be stated as:
TYPE: NAME: POINTER
DWORD Param1 PTR TO
WORD Param2 PTR TO
Please help me calling the function as i'm confused on how to call the function in installscript with the correct paramter types.:confused: Please provide a sample code.
Thanks in advance. 🙂
One of the functions which I need to call from the installscript project is the Get function. The parameters of which are as follows:(in C++)
Get(param1,param2)->param1 & param2 are both output parameters.
They can be stated as:
TYPE: NAME: POINTER
DWORD Param1 PTR TO
WORD Param2 PTR TO
Please help me calling the function as i'm confused on how to call the function in installscript with the correct paramter types.:confused: Please provide a sample code.
Thanks in advance. 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 21, 2008
09:44 AM
In general, a function that returns a value and has two in-out parameters might look like this:
prototype int MyFunction(BYREF NUMBER, BYREF NUMBER);
And a sample use of the function (leaving out UseDLL and UnUseDLL) might be:
prototype int MyFunction(BYREF NUMBER, BYREF NUMBER);
And a sample use of the function (leaving out UseDLL and UnUseDLL) might be:
function OnBegin( )
NUMBER ret;
NUMBER arg1, arg2;
begin
// specify in-values, if necessary
arg1 = 220;
arg2 = 284;
// all the function: not necessary to compute pointers since
// prototype uses BYREF
ret = MyDLL.MyFunction(arg1, arg2);
// display what the DLL sent back
SprintfBox(INFORMATION, "MyFunction",
"After calling MyFunction:\n\n" +
"ret = %d\narg1 = %d\narg2 = %d", ret, arg1, arg2);
end;
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 22, 2008
02:34 AM
Hi Robert,
Thanks for the reply . I called the function the same way you explained in the example but before calling the Get function, the Start function needs to be called and this function is not returning the desired output.
The Start function is called in this way(installscript):
prototype INT MyDll.Start(NUMBER, BYREF NUMBER);
.
.
MyDll.Start(param1,param2);
The function call can be seen in C++ as:
byte param2;
short nReturn=Start(0x03000001,param2);//param2 is the output parameter.
The output parameter, param2 - is always returning the value 0 (installscript) where it should have returned 1 or 2, as desired:confused: . Please tell me if there are any changes required in the function call or is the byte type hindering the return value? please provide with an example as help.
You had also suggested to remove the cdecl modifier which removed the bad stack error, I was getting earlier. But why does this removal of the modifier, removes the error as well:confused: ?
Thanks in Advance. 🙂
Thanks for the reply . I called the function the same way you explained in the example but before calling the Get function, the Start function needs to be called and this function is not returning the desired output.
The Start function is called in this way(installscript):
prototype INT MyDll.Start(NUMBER, BYREF NUMBER);
.
.
MyDll.Start(param1,param2);
The function call can be seen in C++ as:
byte param2;
short nReturn=Start(0x03000001,param2);//param2 is the output parameter.
The output parameter, param2 - is always returning the value 0 (installscript) where it should have returned 1 or 2, as desired:confused: . Please tell me if there are any changes required in the function call or is the byte type hindering the return value? please provide with an example as help.
You had also suggested to remove the cdecl modifier which removed the bad stack error, I was getting earlier. But why does this removal of the modifier, removes the error as well:confused: ?
Thanks in Advance. 🙂
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)