CFOBJECT, Calling a DLL

Hello, Du to the complexity of a task i want my CFApplication to do, i had to make a part of the program into a DLL.

My Question is, how do i call the DLL from Coldfusion? i know the CFOBJECT Tag have something to do with it, but i realy don't know what to do and how the tag work. I need to call a specific function in the DLL and to pass it a value, the function will execute some stuff and put data in the datbase, which will now be available via my CFApps...

Can anyone help me out?
LVL 1
OeilNoirAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bigbadbCommented:
You can use the custom tag CFX to call a dll.  I wrote a program to ping a mail server.  You need to setup the tag in the cold fusion admin then you will call the tag as such:

<cfx_name
Host = "#application.mailserver#">

for me host was the variable I was passing.  If you need to return a variable you can do that by simply adding that variable to the call and checking its value after the call.

This should work we have wrote a number of custom tags for this very thing.  Let me know if you need anymore help!!!
Good Luck
0
OeilNoirAuthor Commented:
Thanks for the Help, this may fix my problem and enable me to call the DLL, but so far my attempt to make it work failed... Maybe there is something i missed?

Ok

So here is what i've done :

I create an ActiveX DLL with Visual Basic. and added to it a Class Module called clsGenerateTeam. In the class module there is only one function (so far) and it's called: GenerateTeam
(the Class is set to global multi-use)

i went to the CFAdmin, in the CFX tag section, and gave a name to my Tag : CFX_GenerateTeam

i selected the right library, and finaly, i typed in the procedure name:
GenerateTeam
(i also tried clsGenerateTeam, clsGenerateTeam.GenerateTeam and etc...)

then in my coldfusion app, i called it using that Tag :
<cfx_GenerateTeam strLogin='test'>

it doesn't work, i keep getting the following message :

Error loading CFX custom tag library

The procedure associated with the custom tag CFX_GENERATETEAM (GenerateTeam) was not found in the library
 'c:\Inetpub\path\dll.dll'.

 Please check the ProcedureName entry for this tag in the custom tag database to verify that the procedure listed there is
 exported by the custom tag library.

What am i doing wrong?
Thanks for your help
0
heathprovostCommented:
That is not what he meant...  You created a normal ActiveX DLL, not a CFX Tag.  If your DLL is done properly, and functions correctly as an in-process COM server, and is regeistered on the system as a COM server, then you can use the CFOBJECT tag to call it like this:

Assuming your ProgID is "clsGenerateTeam"

<CFOBJECT ACTION="Create"
  TYPE="COM"
  CLASS="clsGenerateTeam"
  CONTEXT="InProc"
  NAME="GenTeam">
<!--This is a guess as to how you would call it, I dont know how you implemented anything-->
<CFSET GenTeam.GenerateTeam(test)>

If you want to make a CFX Tag, you need to either rewrite the DLL as a Tag or create a "wrapper" tag that calls your DLL for you.  Either way you need to use a language that supports CFX tag creation.  Allaire only supports C and C++, but there are libraries available to build tags in Borland Delphi also.

Heath
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

OeilNoirAuthor Commented:
Ok, the CFOBJECT Things, the way you described it realy make sence... and i think i understand how it should work... but unfortunatly, it doesn't work :-( now, i get the following error :

Error trying to create object specified in the tag.
 COM error 0x800401F3. Invalid class string

ì'm not very familiar with COM objects, so my error could come from the way i created the DLL... though i don't think so.

i compiled the DLL directly on this computer, so it was automaticaly registered (and data about it can be found in the registry) so, obviously it class is registred correctly, do you have an idea why it wouldn't work?
0
heathprovostCommented:
honestly, I havent ever used a COM object in CF.  What I posted is about as much as I know...  I always make CFX Tags for stuff like this, as it is much more efficient in general.  Maybe someone else has more info.

Heath
0
bigbadbCommented:
I agree with heathprovost I have always used custom tags.  They work well and basically function the same as a DLL (ie reusable, compilied, etc....)
0
dapperryCommented:
I've used CFOBJECT with some success, albeit it not total success,  One thing to remember, you must specify all arguments to a function or method, even if they are only optional.  CFOBJECT will fail elsewise.  Why don't you give an example of a time when you are getting the "invalid class string".  I'm assuming that you are not getting it at the CFOBJECT statement, but during a future CFSET.  If it is occurring at the CFOBJECT, make sure you entered the correct class string for your COM object.

:) dapperry
0
OeilNoirAuthor Commented:
YES YES YES YES!!! YOU GIVE ME THE RIGHT HINT!!! hahah
i had this :
<CFOBJECT ACTION="Create" TYPE="COM" CLASS="clsGenerateTeam" CONTEXT="InProc" NAME="GenTeam">
<CFSET GenTeam.GenerateTeam("kenny365")>

but indeed, the class string wasn,t right, i had to specify the DLL so it could find it in the registry.

so i had to put it that way: (wbbb is the name of the dll (wbbb.dll)

<CFOBJECT ACTION="Create" TYPE="COM" CLASS="wbbb.clsGenerateTeam" CONTEXT="InProc" NAME="GenTeam">
<CFSET GenTeam.GenerateTeam("kenny365")>

GREAT =)))) it work now =)

who's going to take the points now? you all helped me a lot!
0
dapperryCommented:
You can give the pts to others if you want.  If you want you can slip me a question on the side for partial pts.  Glad its working for you now.

:) dapperry
0
OeilNoirAuthor Commented:
Well... someone post a question here to get the points =)
0
dapperryCommented:
I think you can just click on one of our comments - where it says 'Accept Comment as Answer'

:) dapperry
0
rod_nolanCommented:
Hey everyone,

I recently had the exact same problem as OeilNoir so I just wanted to add a little tip that may help with this sort of thing in the future. I know the problem is solved now, but better late than never, I guess. There's a utility called OLE COM Object Viewer that you'll find in C:\Program Files\Microsoft Visual Studio\Common\Tools\oleview.exe - or simply search for the filename if you don't have that path.

It gives you all kinds of information about the COM objects registered on your system, including their ProgIDs which map to the CLASS attribute of the <CFOBJECT> tag. If you expand the All Objects node and find the classes you're interested in using the (dllname.classname) naming convention you can view the info in the right-hand pane.

Hope this helps,
Rod
0
dapperryCommented:
Ok, if no one else wants to answer I will.

:) dapperry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OeilNoirAuthor Commented:
oups i forgot about this question =) time for me to give the points =)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.