PDA

View Full Version : How to make a custom dll



NewsArchive
02-21-2008, 03:39 AM
My program has several modules.
The program checks for a file in %DATAFOLDER% stamlic.tps open/close the
different modules.
I have made a script, which installs the modules password protected.
Now i want my stamlic.tps file updated.

I have tried to write a Clarion dll, which should make the task.
I am really not dll expert, and untill now I am stuck.

I have attached the app and dct file for the dll - If someone would take a
look.
The dll is compiled 'local' because I want it to be able to work As Is -
Thats perhaps the first fault.

Edvard Korsbęk

NewsArchive
02-21-2008, 03:39 AM
Your app gives an unknown template type error (BFET, NetTalk).

But there are 4 example DLL source code projects in the Examples Package.

Friedrich

NewsArchive
02-22-2008, 01:27 AM
OK, I can manipulate my stamlic.tps file now based in %datafolder%.
First time ever I work with a source project.
It has some quirks whwen its me who is doing the job.
If I try to make my own project file, it do not create a .exp file.
So I use yours first demo example.

Edvard

By the way - We sold app. 600 licences today of the BB-J 16:07....
That will be celebrated!

NewsArchive
02-22-2008, 01:27 AM
Hi Edvard,

> By the way - We sold app. 600 licences today of the BB-J 16:07....
> That will be celebrated!

Now that is very good news. Wow. Congratulations!!!!

Friedrich

NewsArchive
02-24-2008, 07:20 AM
Still strugling a bit
I have a procedure, which i can call from a Clarion program with
stamlic(string1,string2,string4,string5,string6)
It gives me errorcode -1
What does it mean...

Edvard Korsbęk

NewsArchive
02-24-2008, 07:20 AM
Are you sure it's not that line that gives you error -1?

Call DLL "%TMPDIR%\sbdll.dll" -- Function "CALLMYFUNCTION" (long)
(%_SB_RETURN%)

You are not including sbdll.dll in the project you posted.

Friedrich

NewsArchive
02-24-2008, 07:21 AM
And make sure you really export from the DLL what you call in the installer.

You call a function named "stamlic", so make sure the function is not
exported like this:

StamLic
__stamlic
stamlic@whatever

and so on.

In Windows, functions are case-sensitive!

Friedrich

NewsArchive
02-24-2008, 07:23 AM
The procedure is - You can recognize where it comes from!:
I have included your dll as well - You were right, it was not present.
I have changed the call to stamlictest, as the filename was stamlic. Still
no joy...



MEMBER('stamlicdll.clw') ! This is a
MEMBER module

stamlictest PROCEDURE (STRING DATAFOLDER,STRING INDGANG,STRING
BILLED,STRING SMS,STRING ADM,STRING WWW) ! Declare Procedure
CODE ! Begin processed
code
!CALLTHISFUNCTION2 FUNCTION(DATAFOLDER,INDGANG,BILLED,SMS,ADM,WWW)
! CODE
Message(CLIP(DATAFOLDER)&'\stamlic.tps')
STAMLIC{prop:name}=CLIP(DATAFOLDER)&'\stamlic.tps'
OPEN(stamlic)
IF ERRORCODE()
CREATE(stamlic)
OPEN(Stamlic)
END
STA:STAMLIC_ID = 1
GET(stamlic,STA:BY_STAMLIC_ID)
IF ERRORCODE()
STA:STAMLIC_ID = 1
STA:INDGANG = INDGANG
STA:BILLEDMODUL = BILLED
ADD(STAMLIC)
ELSE
STA:BILLEDMODUL = 45
STA:INDGANG = iNDGANG
PUT(stamlic)
END
CLOSE(stamlic)
! Change szText value
DATAFOLDER = 'Opdateret'

! Return to installer
! RETURN 0

Edvard Korsbęk

NewsArchive
02-24-2008, 07:24 AM
Your source code does not help because it does not tell us what is exported.
Perhaps nothing is exported at all!

Open the DLL with LibMaker and you can see what is exported. If you are
interested, post the libmaker screenshot after you have opened your
stamlicdll DLL and we know what is going on ;-)

Friedrich

NewsArchive
02-24-2008, 07:25 AM
OK, whats going on <G>
Edvard

NewsArchive
02-24-2008, 07:26 AM
> OK, whats going on <G>

There you have the answer ;-) You do *not* export "stamlic" from your
Clarion DLL!

You export a function named STAMLICTEST@Fsbsbsbsbsbsb <g>

You call "stamlic" from the installer so you have to export "stamlic" from
your DLL :) Similar to calling PleaseDisplayMessageNow() instead of
Message() in Clarion. PleaseDisplayMessageNow() simply does not exist. Do
you see what I mean? You call a function from the installer that does not
exist.

Look at the attached screenshot. It shows the exported functions from the
sbdll.dll example.

Friedrich

NewsArchive
02-24-2008, 07:30 AM
OK, NAME() was a new word.
stamlictest is exported.
It makes the installer disapear withoot any notice.
If called from a Clarion program, it does what is expected.

Edvard

NewsArchive
02-24-2008, 07:31 AM
If it does not work then you are still doing something in your DLL that is
not allowed in a standard Windows DLL. It doesn't matter if it "seems" to
work fine in Clarion.

What you do is you call a Clarion DLL in a Windows "C" application (the
installer) now. In other words, if you would call your Clarion DLL in a
Visual Studio, etc. application then that app would also GPF immediately.
The script (.sb6) does not help because it's *not* an SetupBuilder problem.

Just follow the examples in the Examples package and you are done :) IMO,
your calling convention is incorrect (that's why your application simply
disappears).

BTW, why don't you use one of the examples as a template and just add your
code? All the example source codes compile into perfectly valid Win32 DLLs
(can be called from any Clarion, Visual Studio, Delphi, etc. app).

Does this help?

Friedrich

NewsArchive
02-24-2008, 07:32 AM
> BTW, why don't you use one of the examples as a template and just add your
> code? All the example source codes compile into perfectly valid Win32
> DLLs (can be called from any Clarion, Visual Studio, Delphi, etc. app).
[SNIP]

That was vhere i started, and I will go back.
Problem was the exp file, when i began to be a bit advanced, and wanted to
clean up and rename functions from myFunctionCall2

I will have to read a bit on Clarionmag (Jeff Slarve) to catch that part.

And- As usual - Thanks for your patience and willingness to help even the
slower understanding..

edvard

NewsArchive
02-24-2008, 07:32 AM
Hi Edvard,

You are welcome!

BTW, did the .app DLL demo help? It should work as expected.

Friedrich

NewsArchive
02-24-2008, 07:33 AM
Hi Friedrich,

>BTW, why don't you use one of the examples as a template and just add your
>code? All the example source codes compile into perfectly valid Win32 DLLs
>(can be called from any Clarion, Visual Studio, Delphi, etc. app).
>
>Does this help?

Don't know if it will help Edvard, but it WILL help me in combining
calls to Clarion, C and Delphi dlls alike in my new project<g>
Getting all these things to work together is like herding cats;)

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
02-24-2008, 07:33 AM
Hi Arnór,

>>BTW, why don't you use one of the examples as a template and just add your
>>code? All the example source codes compile into perfectly valid Win32
>>DLLs
>>(can be called from any Clarion, Visual Studio, Delphi, etc. app).
>>
>>Does this help?
>
> Don't know if it will help Edvard, but it WILL help me in combining
> calls to Clarion, C and Delphi dlls alike in my new project<g>
> Getting all these things to work together is like herding cats;)

<G> ;-)

Friedrich

NewsArchive
02-24-2008, 07:35 AM
Hi Edvard,

I have developed an .APP dll demo for you (see attached).

Please compile the mytest.app - this compiles the mytest.dll Clarion DLL
(local). Then compile the "Call Dll.sb6" SetupBuilder project.

The testfunc Clarion DLL does the following:

MESSAGE('Hello ' & Param1 & '. This is a message from the ' & Param2 & '
DLL')
RETURN(2008)

The installer calls the testfunc function. The Param1 value is Edvard, the
Param2 value is Clarion. That means the Clarion DLL will display "Hello
Edvard. This is a message from the Clarion DLL). The DLL returns 2008 to
the installer. The installer will display this value.

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
02-24-2008, 07:36 AM
This works, and coold be a very good example project.
I am not acustomed to projects - I am an APP programmer, which is a
completely other animal.
It is extremly easy to change it to take 6 parameters - My 6 modules, and to
make the nessecary changes to the file.
If you look at the NG's of today, you will find that I have been working
with this since 5:23 (AM) this morning.
Thanks to everybody, who has followed this over the day.
We will send app. 1500 out on march 1.st, and just the thought of sending 1
to 6 CD's to every customer...
+ an indivudual licence cd.

Just wonder a bit of what to do with the Citrix customers (MSI Scripts
developed with SetUpBuilder).
OK, I think they will get a program based upon my dll, and a licence to make
licence files. After all, the Citrix customers are all cities, and they
generally are quite trustworthy.

The better call you can get from thar sort of customer is: 'I have tried
your programme from another customer in this city. Please send me an
invoice'. Alternative to: Send a consultant.

Edvard

NewsArchive
02-24-2008, 07:36 AM
Hi Edvard,

> This works, and coold be a very good example project.
> I am not acustomed to projects - I am an APP programmer, which is a
> completely other animal.
> It is extremly easy to change it to take 6 parameters - My 6 modules, and
> to make the nessecary changes to the file.
> If you look at the NG's of today, you will find that I have been working
> with this since 5:23 (AM) this morning.
> Thanks to everybody, who has followed this over the day.

The advantage of the .prj/.clw examples is that everything is in one place
(the .clw source file). In an .APP there are several different places to
look at to find out how it works.

In fact, there is not much difference between the technique used in an .APP
and .PRJ to develop DLLs in Clarion.

But I'll add the .app demo to the Examples package.

> We will send app. 1500 out on march 1.st, and just the thought of sending
> 1 to 6 CD's to every customer...
> + an indivudual licence cd.

Cool!

> Just wonder a bit of what to do with the Citrix customers (MSI Scripts
> developed with SetUpBuilder).
> OK, I think they will get a program based upon my dll, and a licence to
> make licence files. After all, the Citrix customers are all cities, and
> they generally are quite trustworthy.

The advantage of EXE installations compiled with SetupBuilder is that they
are secure.

In contrast to this, MSI installations are absolutely insecure! You can use
freely available Microsoft tools to open the SQL database (an MSI is nothing
more or less than a SQL database) and manipulate it. Remove a table or
change a value and the verification process is disabled. I am always
shocked when I see that software companies (even some "big boys") do serial
number verification from within a MSI install.

So it does not make any sense to use your protection mechanism in the MSI.

> The better call you can get from thar sort of customer is: 'I have tried
> your programme from another customer in this city. Please send me an
> invoice'. Alternative to: Send a consultant.

<g>

Friedrich