Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-22-2005, 01:07 PM   #1 (permalink)
otakuj462
Registered User
 
Join Date: Sep 2005
Posts: 1
otakuj462 is on a distinguished road
How to use legacy C code in a C# application

Hi, I'm building a Windows application in C#. The goal is to be able to read data off of a particular kind of scangun. The scangun manufacturer provides a .dll file, and some sample code written in MSVC. As the sample code fulfills all of my requirements a far as fetching data from the gun, I want to use it, and write the front-end and database management parts in C#. Is there a way to use the C code, perhaps as even as a precompiled executable? Or would it make more sense to change it at the code level, perhaps making it look more like C++, and then using it as a class? I think this would ultimately be the cleaner option...
If anyone has any advice, I'd appreciate it. Thanks.

-Jake
otakuj462 is offline   Reply With Quote
Old 09-22-2005, 07:01 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
In terms of ugly hacks, couldn't you turn the C code into a command line function that outputs the data you need, then call that with C#'s equivalent of system()?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 09-22-2005, 08:18 PM   #3 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 745
DJMaze is on a distinguished road
The dll is probably using something like:
Code:
#ifdef __cplusplus
extern "C" {
#endif
DLL_API DSQL * CreateDB(void)
{
    return new DSQL();
}
#ifdef __cplusplus
}
#endif
All C apps should allow you to work with that even C# just include the .h files or use LoadLibrary()
DJMaze is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perplexing Error on C Code etorres Standard C, C++ 6 03-24-2005 09:16 PM
Techniques for improving ANSI C code asc01001 Standard C, C++ 1 03-19-2005 12:26 AM
edit? anon Lounge 10 11-21-2002 04:02 PM


All times are GMT -8. The time now is 07:14 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting