Solved

Calling a C++ dll with ColdFusion, ColdFusion cannot pass pointers as required

Posted on 2007-12-05
12
644 Views
Last Modified: 2013-12-20
We have an existing C++ dll for processing data the has been used for a few years in our products. We are not develolping a web based SAAS version of our product, and need to integrate ColdFusion in with the .dll. The trouble is the C++ dll expects an array of data, passed as a pointer to the start of the array, but ColdFusion cannot deal with pointers.
The dll function prototype is
void SpeechAnalyseRT::storeAndAnalyseChunk(short int* data, unsigned long dataLength)
and has virtual function
virtual void CALL storeAndAnalyseChunk(short int* data, unsigned long dataLength) = 0;
How do we change this to pass by value? it has been suggested that we use a struct with an array inside. What is the syntax to make this work, i.e. declaring the struct etc?
Is this the right thing to do?
Thanks
Thor

0
Comment
Question by:ThorRussell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
12 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 20417014
The easiest way would be to pass an array of size 1:

data Data;

// fill struct

storeAndAnalyseChunk(&Data,1);
0
 
LVL 86

Expert Comment

by:jkr
ID: 20417017
...or

data Data[1];

// fill struct

storeAndAnalyseChunk(Data,1);

respectively.
0
 
LVL 86

Expert Comment

by:jkr
ID: 20417020
um, make the last one
data Data[1];

// fill struct
Data[0].nSampleMember = 42;

storeAndAnalyseChunk(Data,1);
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

Author Comment

by:ThorRussell
ID: 20417231
The array needs to be of size somewhere between 44,100 to 441,000 size 1 definitely wont do!
0
 
LVL 86

Expert Comment

by:jkr
ID: 20417268
If you cannot supply such aq range, there definitely is a problem... a conceptional one. Pointers and arrays are interchangeable in C/C++, so you should be fine with both. Changing an existing function is out of question, unfortunately.
0
 

Author Comment

by:ThorRussell
ID: 20423136
Are you trying to say it cant be done? There must be a way to let coldfusion call a C++ dll.
What do you mean by changing an existing function is out of the question? The dll is mine, so I can change it how I like. I want it to accept the array by value rather than pointer.
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 20423624
Well, if you are creating the DLL you can of course change anything you want. But in C/C++, array *are* in fact pointers to the 1st element in the array, and that is something which is going to be hard to change.
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 20428782
"There must be a way to let coldfusion call a C++ dll. "

i'm not familiar with the internals of c++ but i do know how to use them with cf...

just register a cfx custom tag

cfadmin -> cfx tags -> Register C++ CFX -> name tag cfx_yourDLLName -> choose path to dll

note that if your dll is called foo you need to name the tag cfx_foo

then call the dll like so

<cfx_foo expectedInputparameter1="#somevar1#"
              expectedInputparameter2="#somevar2#">

then the output would be something like

<cfoutput>
#outputParamStuct.outputParam1#
</cfoutput>  

where outputParamStruct is the struct containing value or values returned by the dll and outputParam1 is the value itself.




0
 
LVL 36

Expert Comment

by:SidFishes
ID: 20428797
"note that if your dll is called foo you need to name the tag cfx_foo"

to be more specific

note that if your dll is called FOO.DLL you need to name the tag CFX_FOO (no extension)
0
 
LVL 86

Expert Comment

by:jkr
ID: 25397274
I'd say http:#20423624 clears up the issue, so I tend to object to a delete.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do i run a c++ file? 15 58
Where are the c++ header files to use in Eclipse? 4 75
Dreamweaver code color same as CS6 or CS2015 2 70
Winapi.Windows.hpp problem 7 44
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question