Google Answers Logo
View Question
 
Q: (Experience w/ Unix C++, Not With Windows) Translating few C# lines to C++ ( No Answer,   1 Comment )
Question  
Subject: (Experience w/ Unix C++, Not With Windows) Translating few C# lines to C++
Category: Computers > Programming
Asked by: darlingm-ga
List Price: $30.00
Posted: 16 Jan 2005 11:55 PST
Expires: 15 Feb 2005 11:55 PST
Question ID: 458182
*** I don't believe this would take much time for someone experienced
with C++ and C# to answer.  If I'm wrong, and a Google Researcher
feels this will take a while and would only do it for a higher price,
let me know.  If it's more time consuming to answer than I think it
will be, I'd be willing to pay for that extra time. ***



I have been programming C++ on Unix for years.  I have to write my
first application using Visual Studio .NET (which I've never used
before), and interact with A DLL written in C# (which I've never used
before.)

The DLL interaction is extremely simple, and all the documentation
fits on one screen without scrolling.  This should be fairly easy for
someone familiar with both C++ and C#.

The website for the DLL file I am trying to use is:
http://www.softontechnologies.de/theeye/
(Scroll down on this page for the documentation - under the ' 
"TheEye" API  ' section)

[Question] My understanding is that although the DLL author wrote the
DLL in C# that I should still be able to use it in a C++ program.  Am
I correct?

I am trying to "translate" those C# commands in the API documentation
area to C++.  I have some of them figured out.



"
   1. The API Class:
   TheEye.Comm.API api = new TheEye.Comm.API();
"

This seems to work:
   TheEye::Comm::API* apiPtr = new TheEye::Comm::API;

[Question] Is this correct?  If not, please help me with author's
points 4-6 because how simple these lines are, these translations seem
very simple to me.



"
   2. Receiving feed back:
   api.AreaChanged += new TheEye.Comm.AreaChanged(TheEye_AreaChanged);
   api.StatusChanged += new TheEye.GUI.StatusEventHandler(TheEye_StatusChanged); 

   where:
   public delegate void AreaChanged(object sender, ElementCollection elems); 
   public delegate void StatusEventHandler(object sender, string
newStatus, Status status);

   ElementCollection is collection of Element class instances, having 3 properties:
   public string AreaType; 
   public string AreaGroup; 
   public string AreaName; 
   public string AreaValue; 
"

[Question] I get that this is where I'm supposed to link up one of my
functions to the API to get results back from it.  This is where I am
stuck.
[Question] What is the author meaning here?
[Question] What should my function prototypes be?
[Question] How do I hook my functions into the api object?
[Question] How do I use ElementCollection?  I assume it can't be as
easy as "vector<TheEye::Comm::Element> ElementCollection"?  Is it
instead an array of "TheEye::Comm::Element"?  If so, how do I figure
out the size?
[Question] Is there any way to figure out possible values for
"Status"?  The website doesn't say anything about this, or even what
status events are.



"
   3. Starting "TheEye" through the API
   public void Start(string projectName, int windowHandle)
   public void Start(string projectName, string windowTitle)
   public void StartWithRegEx(string projectName, string windowTitle)
"

This seems to work: 
   apiPtr->Start("C:\TheEye\CalculatorExample.eye", "Calculator");

[Question] Is this correct?

[Question] Can you send me in the right direction (website) showing
how to get windowHandles from Windows?

I won't be using the RegEx capability.

Clarification of Question by darlingm-ga on 16 Jan 2005 12:19 PST
I started posting this question, and on the preview page, decided to
add a something to the top.  As soon as I confirmed the question, it
forwarded me to see the live question.  On the FIRST LOAD, it was
showing "You cannot modify or comment this question right now. It is
currently being answered."

Either a google researcher was extremely quick at grabbing the
question (which I'd be very thankful for) or I'm wondering if I
somehow locked the question myself by editing the comment text before
posting it.  I didn't use the back or forward buttons, just used the
HTML buttons supplied by google.

Can anyone check into this?  If someone actually is answering, thanks
for your prompt attention, and I look forward to hearing from you.

Request for Question Clarification by mathtalk-ga on 16 Jan 2005 19:37 PST
If I understand the context, there is a DLL which you want to call from C++ code.

You have documentation for how to call it (the API) in C#, and you
want this translated into equivalent C++ commands.

I think this can be done and that the price offered is reasonable. 
Just to clarify, you are writing .Net code using C++?  I ask because
it is also possible to compile a "native" application from C++ in
Visual Studio .Net, and presumably your application is otherwise
dependent upon the .Net environment.

regards, mathtalk-ga

Clarification of Question by darlingm-ga on 16 Jan 2005 20:05 PST
Your understanding is correct.

I am used to C++, so I hope that I will be able to use C++ rather than
have to learn and use the .Net language.

The dll file I am trying to use, "TheEye.dll" had a front-end testing
interface that required the .Net framework to be installed before it
would run.  I don't know if that just means their testing interface
(that I will not be using with this program) requires .Net framework
-- or if the dll file also requires it.  Either way, I am hoping to
just write C++ without the .Net environment being in my own code.

If I didn't clearly answer your question, it is because of my
unfamiliarity with Windows programming.  Feel free to ask again.  :)

Request for Question Clarification by mathtalk-ga on 17 Jan 2005 04:45 PST
According to the link you cited:

  "TheEye" is written in C# and requires .Net runtime.

So your application will require installation of the .Net "framework".
 However I would imagine that this will have already happened on your
development machine if you installed Visual Studio .Net.

It is possible to treat the entire .Net runtime as a COM component and
call it from "native" code compiled from C++, but this neither removes
the necessity of installing the .Net runtime nor simplifies the
programming model.

I recommend the approach of writing your code in C++ and compiling it
as a .Net executable.  Visual Studio .Net can create a variety of
"base" projects to give you a starting point.  Will your application
be a "console" application that runs from a command line, or will you
have a GUI (graphical user interface) design?  I suspect the latter,
because "The Eye" seems to target that sort of application.

regards, mathtalk-ga

Request for Question Clarification by mathtalk-ga on 21 Jan 2005 15:02 PST
Hi, darlingm-ga:

Will you still be interested in translation of those C# API calls to
C++, knowing that the .Net framework is required by "The Eye"?

regards, mathtalk-ga
Answer  
There is no answer at this time.

Comments  
Subject: Re: (Experience w/ Unix C++, Not With Windows) Translating few C# lines to C++
From: robert_hostetter-ga on 11 Feb 2005 08:25 PST
 
With either a wrapper, or access to the source code for theeye, you
could very easily turn it into a COM object, which you can use in your
C#.  This is quite easy to do.  You just need to create a GUID for it
and put it in the correct location on the code (or write a wrapper,
and do the same thing).  Another option would be to write managed C++,
which you have already expressed disinterest in doing.  If theeye is
written in C# it WILL be requiring the .NET framework, which is 21MB
or so.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy