View Full Version : Creating DLL functions to call from Setupbuilder
NewsArchive
03-19-2008, 03:22 AM
I'm having very mixed results creating functions (in Clarion) in DLLs
for SB to call. Some work out fine, others in the same DLL crash SB
even when the prototypes and calling sequences are the same.
I'm wondering if other people have had, and solved <g>, similar
problems.
Thanks
John Newman
Software Partners Australia
NewsArchive
03-19-2008, 03:25 AM
Hi John,
It's definitely a problem in your DLL or how you call the functions. You
would get the very same "crash" problem with this DLL if you called it from
a, say, Visual Studio application.
So you have to fix it in your DLL. Post your code or send it to support at
lindersoft dot com and I am sure we can help you.
--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910
"point. click. ship" - that's SetupBuilder 6.7
Create Windows Vista ready installations in minutes
-- Official Comodo Code Signing and SSL Certificate Partner
NewsArchive
03-19-2008, 03:47 AM
> It's definitely a problem in your DLL
I'm sure of that<g>
Here's a sample, This is the code of one that fails. The window opens fine,
but on exit I crash SB:
************************************************** *****************
Activate FUNCTION (pcDataDir,pcVersion) ! Declare
Procedure
llRetVal long
lsVersionKey string(12)
Window WINDOW('Enter version activation key'),AT
(,,210,66),FONT('MS Sans
Serif',8,,FONT:bold,CHARSET:ANSI),CENTER,GRAY,DOUB LE
STRING('Activate Version :'),AT(2,14,63,10),USE(?
String2),RIGHT
STRING('Version'),AT(69,14,49,10),USE(?
S_Version),LEFT,FONT(,,COLOR:Blue,,CHARSET:ANSI)
STRING('For Site :'),AT(16,3,49,10),USE(?
String3),RIGHT
STRING('Site name'),AT(69,3,135,10),USE(?
S_Site),LEFT,FONT(,,COLOR:Blue,,CHARSET:ANSI)
PROMPT('Version Key :'),AT(21,37),USE(?
lsVersionKey:Prompt)
ENTRY(@s10),AT(69,37,,10),USE(lsVersionKey),LEFT
(1),MSG('version key'),TIP('version key'),UPR
BUTTON('OK'),AT(157,44,45,14),USE(?OK),DEFAULT,REQ
BUTTON('Cancel'),AT(157,24,45,14),USE(?Cancel)
END
CODE ! Begin
processed code
open(Window)
accept
case event()
of EVENT:Accepted
if field() = ?Cancel
llRetVal = false
break
end
if field() = ?OK
llRetVal = true
break
end
end
end
close(window)
return(llRetVal)
************************************************** ********
...this is the EXP:
**********************************
MANIFEST
LIBRARY 'STATDLL' GUI
EXPORTS
MAIN@F @?
LOOKUPSTATION_GEN @?
LOOKUPSTATION @?
ACTIVATEOLD @?
ACTIVATENEW @?
ACTIVATE @?
$GlobalRequest @?
$GlobalResponse @?
$VCRRequest @?
$FN_STA @?
$FN_CON @?
**********************************
...and this is the script:
**********************************
#include support file "E:\Release\V10.0\bin\statDLL.dll"
Set Variable %TMPDIR% to "{TMPDIR}"
Set Variable %DATADIR% to "c:\pos"
Set Variable %VERSION% to "[PRODUCTVER]"
Call DLL "%TMPDIR%\statDLL.DLL" -- Function "ACTIVATE" (*CSTRING,*CSTRING)
(%DATADIR%,%VERSION%)
Display Message Box "Return: %_SB_RETURN%\nError: %_SB_ERRORCODE%\nSt..."
-- "Result from function"
**********************************
John Newman
Software Partners Australia
NewsArchive
03-19-2008, 03:48 AM
The most important part is missing (how you prototype the function). If it
crashed SB on exit then the function prototype/declaration is incorrect.
Should be something like:
Activate(long, string),long,raw,c
But I would suggest:
Activate(long, *cstring),long,raw,c
Did you see this one?
http://www.lindersoft.com/forums/showthread.php?p=17768#post17768
Does this help?
Friedrich
--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910
"point. click. ship" - that's SetupBuilder 6.7
Create Windows Vista ready installations in minutes
-- Official Comodo Code Signing and SSL Certificate Partner
NewsArchive
03-19-2008, 03:48 AM
By the way, and you have this in your script:
Call DLL "%TMPDIR%\statDLL.DLL" -- Function "ACTIVATE" (*CSTRING,*CSTRING)
But this in your DLL:
Activate FUNCTION (long, string)
So you have two problems here. I thing your prototype per-se is incorrect
(no "RAW,C" to pass the address-only to a C function) and you are mixing
*cstring (in your script) and string (in your DLL).
Friedrich
NewsArchive
03-19-2008, 03:49 AM
Correction. You did not say what type pcDataDir and pcVersion have. So I
assume it's a *CSTRING in both cases.
The following should fix it for you:
Activate(*cstring, *cstring),long,raw,c
Friedrich
NewsArchive
03-19-2008, 01:47 PM
> Correction. You did not say what type pcDataDir and pcVersion have. So I
> assume it's a *CSTRING in both cases.
Sorry, I left out the prototype!
Activate(*cstring,*cstring),long,pascal
(Which is the same as the one in your example 'myapp')
????
John Newman
Software Partners Australia
NewsArchive
03-19-2008, 01:47 PM
John,
You did also not mention what calling convention you used in your script.
That's why I suggested "long,raw,c" because it's definitely caused by an
incorrect use of the calling convention.
Did you check the previously mentioned testdll.zip example source codes?
This should help you.
Friedrich
NewsArchive
03-19-2008, 01:52 PM
> You did also not mention what calling convention you used in your script.
> That's why I suggested "long,raw,c" because it's definitely caused by an
> incorrect use of the calling convention.
I used ___stdcall, as in the 'Call Dll' example.
Really, I have copied the example in every way that I can think of, and the
function 'LookupSTATION' in the same DLL works just fine (it is only
different in having four cstring parameters), but 'Activate' does not...
I feel that there is something I do not know, but I don't know what!!
John Newman
Software Partners Australia
NewsArchive
03-19-2008, 01:52 PM
> I used ___stdcall, as in the 'Call Dll' example.
>
> Really, I have copied the example in every way that I can think of, and
> the function 'LookupSTATION' in the same DLL works just fine (it is only
> different in having four cstring parameters), but 'Activate' does not...
>
I know what it is. I'll send a source code demo in a minute...
Friedrich
NewsArchive
03-19-2008, 01:54 PM
John,
The attached source code demo works fine now. Unzip it into a temporary
folder, compile "mytest.app" with Clarion and then "Call DLl.sb6" with
SetupBuilder.
BTW, this line in your Window definition causes problems and cannot be used
when called from a standard Windows VC++ application.
ENTRY(@s10),AT(69,37,,10),USE(lsVersionKey),LEFT(1 ),MSG('version
key'),TIP('version key'),UPR
The Clarion TIP() command seems to corrupt the stack.
This works fine:
ENTRY(@s10),AT(69,37,,10),USE(lsVersionKey),LEFT(1 ),MSG('version key'),UPR
Does this work for you now?
For the record: all your codes including calling conventions are correct.
It's caused by the TIP() Clarion command.
Friedrich
--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910
"point. click. ship" - that's SetupBuilder 6.7
Create Windows Vista ready installations in minutes
-- Official Comodo Code Signing and SSL Certificate Partner
NewsArchive
03-19-2008, 01:55 PM
Does PROP:Tip have the same effect?
--
Russell B. Eggen
www.radfusion.com
Skype Clarion chat: http://tinyurl.com/2273lm
NewsArchive
03-19-2008, 01:55 PM
> Does PROP:Tip have the same effect?
Yes. When adding:
?lsVersionKey{PROP:Tip} = 'version key'
it also crashes on return to a VC++ application.
Friedrich
--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910
"point. click. ship" - that's SetupBuilder 6.7
Create Windows Vista ready installations in minutes
-- Official Comodo Code Signing and SSL Certificate Partner
NewsArchive
03-19-2008, 01:56 PM
BTW, having the TIP('version key') attribute in a control definition is
enough to "crash" the app.
Using SYSTEM{PROP:NoTips} = 1 before the OPEN(window) command to disabled
balloon help text for an entire application does not help.
Friedrich
NewsArchive
03-19-2008, 01:57 PM
Hi Russ,
>
> Does PROP:Tip have the same effect?
>
I have developed a quick and dirty tooltip on my own and this works fine.
See attached file. Unzip into a temporary folder. Compile "mytest.app"
using Clarion 6. This generates the mytest.dll. Then compile "Call
Dll.sb6" with SetupBuilder and test or run it. The "Test version activation
key" dialog is displayed. Hoover over the "Version Key" entry field and it
displays a "balloon help" text. Click OK and it does not crash.
Friedrich
NewsArchive
03-19-2008, 01:58 PM
Friedrich....
Don't know whether you remember the David Niven movie "The Brain"...
We may need to get you a metal support to keep that cranium vertical. <g>
What a brilliant piece of detective work and programming! (This DLL works
fine!)
Now what are you doing AFTER lunch ?????
Jane
NewsArchive
03-19-2008, 01:59 PM
Jane,
> Don't know whether you remember the David Niven movie "The Brain"...
> We may need to get you a metal support to keep that cranium vertical. <g>
>
> What a brilliant piece of detective work and programming! (This DLL works
> fine!)
>
> Now what are you doing AFTER lunch ?????
<VBG>
I have to confess that the cause for this issue was not easy to find <g>
My high-school teacher for computer science once told me: "Friedrich, you
will never learn it. You'll never understand how this complex machine works
and you'll never ever learn how to write software".
Friedrich
NewsArchive
03-19-2008, 02:00 PM
I bet he's still teaching and you are busy running an empire <g>. You
should show him how to do his tax returns in hex <vbg>.
--
Russell B. Eggen
www.radfusion.com
Skype Clarion chat: http://tinyurl.com/2273lm
NewsArchive
03-19-2008, 02:01 PM
> The Clarion TIP() command seems to corrupt the stack.
Well spotted! That does seem to be the issue.
Thank you very much for your time and effort!
John Newman
Software Partners Australia
NewsArchive
03-19-2008, 02:01 PM
Hi John,
>> The Clarion TIP() command seems to corrupt the stack.
>
> Well spotted! That does seem to be the issue.
>
> Thank you very much for your time and effort!
Thank you for the good news!! My apologies for blaming your source codes.
Friedrich
--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910
"point. click. ship" - that's SetupBuilder 6.7
Create Windows Vista ready installations in minutes
-- Official Comodo Code Signing and SSL Certificate Partner
NewsArchive
03-19-2008, 02:03 PM
Hi Friedrich,
>Activate(*cstring, *cstring),long,raw,c
If I'm not mistaken RAW doesn't work on Clarion prototypes - or it
used to not work. Has this changed?
Also, when dealing with external dlls I always, without exception, use
PASCAL or __stdcall. I believe the C calling convention used in
Topspeed C is not the same as used in for example Borland C. I
remember having problems with prototypes for my Borland C++ dll when I
used the Clarion C attribute. Changed it to __stdcall and PASCAL and
all my problems went away:) I now use __stdcall in both Borland C and
Visual C++ with no problems at all:)
Best regards,
Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com
Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php
NewsArchive
03-19-2008, 02:04 PM
Hi Arnór,
>>Activate(*cstring, *cstring),long,raw,c
>
> If I'm not mistaken RAW doesn't work on Clarion prototypes - or it
> used to not work. Has this changed?
>
> Also, when dealing with external dlls I always, without exception, use
> PASCAL or __stdcall. I believe the C calling convention used in
> Topspeed C is not the same as used in for example Borland C. I
> remember having problems with prototypes for my Borland C++ dll when I
> used the Clarion C attribute. Changed it to __stdcall and PASCAL and
> all my problems went away:) I now use __stdcall in both Borland C and
> Visual C++ with no problems at all:)
Yes, you are absolutely right. The "LONG,RAW,C" suggestion for a Clarion
created DLL was nonsense. It should always be __stdcall and PASCAL for
Clarion DLLs (like it is in all the SB Examples).
When using a C DLL in a Clarion application (EXE or DLL) you should use
LONG,RAW,C
For example, in the tooltip.zip demo that I uploaded today:
AddBalloonTip(LONG, *CSTRING, *CSTRING),LONG,RAW,C
The installer calls into a Clarion DLL (LONG,PASCAL). That Clarion DLL
itself calls into a Visual Studio VC++ DLL (LONG,RAW,C).
Friedrich
--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910
"point. click. ship" - that's SetupBuilder 6.7
Create Windows Vista ready installations in minutes
-- Official Comodo Code Signing and SSL Certificate Partner
NewsArchive
03-19-2008, 02:30 PM
> My high-school teacher for computer science once told me: "Friedrich, you
> will never learn it. You'll never understand how this complex machine works
> and you'll never ever learn how to write software".
Charge them double for SB:)
--
Mark Riffey
http://www.rescuemarketing.com/blog/
The Wall Street Journal staff reads it,
maybe you should too.
NewsArchive
03-20-2008, 02:08 AM
> key" dialog is displayed. Hoover over the "Version Key" entry field and it
> displays a "balloon help" text. Click OK and it does not crash.
Neat. Clearly SV needs to some work. Maybe they need you!
John Newman
Software Partners Australia
NewsArchive
03-20-2008, 02:09 AM
> My apologies for blaming your source codes.
Yeah, I apologised to them too!
best regards,
John Newman
Software Partners Australia
NewsArchive
03-20-2008, 02:10 AM
Hi Friedrich,
>When using a C DLL in a Clarion application (EXE or DLL) you should use
>LONG,RAW,C
I have had problems with using the C attribute in Clarion when using
Borland C++ and I think also with VC++ 2005 to create dlls that I use
from Clarion compiled code. Using __stdcall in C and PASCAL in
Clarion solved those problems right away:)
Since then I always use __stdcall in my C++ dlls and Pascal in Clarion
and have zero problems.
Best regards,
Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com
Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php
NewsArchive
03-21-2008, 03:02 AM
>I bet he's still teaching and you are busy running an empire <g>. You
>should show him how to do his tax returns in hex <vbg>.
<VBG>
Yes, he is still teaching PASCAL.
Friedrich
NewsArchive
03-21-2008, 03:03 AM
Well, at least he stopped teaching RPG II <seg>
--
Russell B. Eggen
www.radfusion.com
Skype Clarion chat: http://tinyurl.com/2273lm
NewsArchive
03-21-2008, 03:04 AM
>
> Well, at least he stopped teaching RPG II <seg>
>
<G> :)
Friedrich
NewsArchive
03-21-2008, 03:05 AM
Hey! RPG II and RPG III payed a LOT of my bills in the old days... :)
Michael Melby
NewsArchive
03-21-2008, 03:05 AM
Roger Staubach and Troy Aikman won Superbowls. So what have either done for
me lately? <g>
--
Russell B. Eggen
www.radfusion.com
Skype Clarion chat: http://tinyurl.com/2273lm
NewsArchive
03-21-2008, 03:06 AM
>> My high-school teacher for computer science once told me: "Friedrich, you
>> will never learn it. You'll never understand how this complex machine
>> works
>> and you'll never ever learn how to write software".
>
> Charge them double for SB:)
He is still teaching PASCAL and SetupBuilder does not run on his DOS machine
<g>
Friedrich
NewsArchive
03-22-2008, 02:42 AM
Russ,
Actually I was still doing some RPG II programming for a very old client
a couple of months ago. So I guess it's still paying some bills. <g>
Michael Melby
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.