So, I am writing an application in C#, and I have some old C code that I want
to use. Now, i tried to convert it to a DLL, and while I easily got it
working, it didn't work like it was supposed to. The problem, is that there
are global structures, with values that change as you write to certain
functions.
To be less vague, the C code is an old FM Chip emulator, so most of the
structures' values have to be stored in memory, as I make calls to change
them. Then I render the sound wave, based on the structure's values, with
another function call. The DLL idea didn't work, because it's making
seperate calls to the functions, and all data used is reset each call.
So, with DLLs out of the question, I'm asking for people's opinions on what
would be the best way to use the code in C#. I was considering converting it
to managed C, and using multiple file assemblies, but I'm unsure if it would
keep the data in memory between calls.
Any ideas are appreciated.
Thanks 2 983
You could use in-line unsafe code to create a managed class that uses unsafe
C code.
--
HTH,
Kevin Spencer
Microsoft MVP
Bit Player http://unclechutney.blogspot.com
A pea rants as candy be sieving.
"ccurrens" <cc******@discussions.microsoft.comwrote in message
news:8C**********************************@microsof t.com...
So, I am writing an application in C#, and I have some old C code that I
want
to use. Now, i tried to convert it to a DLL, and while I easily got it
working, it didn't work like it was supposed to. The problem, is that
there
are global structures, with values that change as you write to certain
functions.
To be less vague, the C code is an old FM Chip emulator, so most of the
structures' values have to be stored in memory, as I make calls to change
them. Then I render the sound wave, based on the structure's values, with
another function call. The DLL idea didn't work, because it's making
seperate calls to the functions, and all data used is reset each call.
So, with DLLs out of the question, I'm asking for people's opinions on
what
would be the best way to use the code in C#. I was considering converting
it
to managed C, and using multiple file assemblies, but I'm unsure if it
would
keep the data in memory between calls.
Any ideas are appreciated.
Thanks
If you're using Visual C++ 2005 you can simply create a C++/CLI project and
add all the C/C++ files to the project. You can then simply create managed
C++ classes that access these C/C++ functions/classes to provide a managed
wrapper... This is called C++ Interop. With Visual C++ 2003 a similar thing
was called IJW or "It just works".
--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote. http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"ccurrens" wrote:
So, I am writing an application in C#, and I have some old C code that I want
to use. Now, i tried to convert it to a DLL, and while I easily got it
working, it didn't work like it was supposed to. The problem, is that there
are global structures, with values that change as you write to certain
functions.
To be less vague, the C code is an old FM Chip emulator, so most of the
structures' values have to be stored in memory, as I make calls to change
them. Then I render the sound wave, based on the structure's values, with
another function call. The DLL idea didn't work, because it's making
seperate calls to the functions, and all data used is reset each call.
So, with DLLs out of the question, I'm asking for people's opinions on what
would be the best way to use the code in C#. I was considering converting it
to managed C, and using multiple file assemblies, but I'm unsure if it would
keep the data in memory between calls.
Any ideas are appreciated.
Thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: James |
last post by:
What is the best method for creating a Web Page that uses both
PHP and HTML ?
<HTML>
BLA
BLA
BLA
BLA
BLA
|
by: Chris S. |
last post by:
Is there a purpose for using trailing and leading double underscores for
built-in method names? My impression was that underscores are supposed
to imply some sort of pseudo-privatization, but would...
|
by: Jon Slaughter |
last post by:
I'm trying to get into web development for creating a professional web site
and I'm confused on which language I should use. I've read some comparisons
between the major languages and I was...
|
by: RickPowell |
last post by:
I wrote a VB .NET Service to restart the computer when certain business rules
are triggered (such as not being rebooted in x days, no users logged on, time
is 1-3 am, etc.).
I am currently using...
|
by: John Swan |
last post by:
Which one is best?
Java is slow but can be ran on every machine.
C# kicks the crap out of MFC but can only be run on M$ platforms.
C++ is class :) but is harder work so ultimately makes you...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their...
|
by: Daniel Portal |
last post by:
Hi there,
I'm in 3-tier project and I'm thinking about having Try / Catch
statements in each method, just in case you know!
If the case is that I don't have a special treatment for the error in...
|
by: CptDondo |
last post by:
I have a small, embedded app that uses a webserver to serve up pages
showing status, etc.
Right now all the pages are hard-coded in English. We need to provide
multi-lingual support.
All of...
|
by: Sarath |
last post by:
I'm so much font of working with C++ . That's the reason why I'm not
yet looked or craze about any other language. Still a question exists,
really C++ is the best language in its category?
|
by: Gladen Blackshield |
last post by:
Hello All!
Still very new to PHP and I was wondering about the easiest and simplest way
to go about doing something for a project I am working on. I would simply
like advice on what I'm asking...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |