473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to work with 3rd party SDK

The 3rd party SDK that I would like to use in C# (I am an C/C++
programmer) is designed to be used from C/C++. This is how it
works:

The vendor is abstracting things a bit. The real DLL has only one
actual exported method, one of the parameters on the DLL takes an
enum which determines which internal function is being called.
Then the vendor provides a header file with a very large number of
enums and structs. There is also a file called function.c with
the sample which contains all the different "internal" functions
and wraps up the parameters to send through the on entry point.

To top it all off, one of the functions in the function.c goes off
to the registry, learns where the DLL is located and then does a
LoadLibrary().

I know that I re-write the whole function.c file in C# and port
the 1000+ lines of header files, too. But my objective in
working in C# is to speed things up, not slow them down;)

Is there an easier way of calling this SDK? I know that I can
compile the function.c as a DLL, but then the issue of the header
files remain, is there any way to include them into the managed
world without having to re-write all the structs and enums?

Sam

Nov 17 '05 #1
1 1235
"Sam Carleton" <sc**************@miltonstreet.com> wrote in message
news:tA******************@fe2.columbus.rr.com...
The 3rd party SDK that I would like to use in C# (I am an C/C++
programmer) is designed to be used from C/C++. This is how it
works:

The vendor is abstracting things a bit. The real DLL has only one
actual exported method, one of the parameters on the DLL takes an
enum which determines which internal function is being called.
Then the vendor provides a header file with a very large number of
enums and structs. There is also a file called function.c with
the sample which contains all the different "internal" functions
and wraps up the parameters to send through the on entry point.

To top it all off, one of the functions in the function.c goes off
to the registry, learns where the DLL is located and then does a
LoadLibrary().

I know that I re-write the whole function.c file in C# and port
the 1000+ lines of header files, too. But my objective in
working in C# is to speed things up, not slow them down;)

Is there an easier way of calling this SDK? I know that I can
compile the function.c as a DLL, but then the issue of the header
files remain, is there any way to include them into the managed
world without having to re-write all the structs and enums?


In your place, I might be asking myself now, "What in the hell am I doing
re-writing this ^%$$& &^%$##& in C# for? :-)

Assuming you have a reason ...

Table C# for know. Define a class structure that you like in MC++ or
C++/CLI, whatever floats your boat. Make sure the class' member return types
and arguments are CLS types so that C# can use the class.

public __gc class YourClass
{
public:

YourClass();

t1 fn1(argList1);
t2 fn2(argList2);
...
tn fnn(argListn);
};

where the fns() are proxies for what you call "internal" functions and the
ts are return types. Then decide how you want to get these managed wrappers
to call the native functions. You can either put the native functions in an
unmanaged segment in the same source file and use "it just works" to call
them:
#pragma unmanaged

t1 fn1Unmanaged(argList1)
{
//....
return t1(x);
}
#pragma managed

t1 fn1(arg1List1)
{
fn1Unmanaged(argList1);
}

or you can use Platform/Invoke if you have the unmanaged proxies in an
external DLL.

As for the issue of the structs, that depends. If it seems natural in C++,
it _may_ be natural in C#. On the other hand, if the vendor just got lazy
and used a structure where he should have used an argument list than your
unmanaged implementation can take the parameter list and build a structure.
But you don't have to expose that composition, just expose the parameter
list.

Once you have the managed (__gc in MC++) class defined, C# can use it as
easily as any other class written in a CLS language.

Regards,
Will


Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex | last post by:
Thank you in advance. My ASP page 1 redirect user to third party's website, after the process at third party is finished, in 3rd party's page, there is one link to route user back to my...
2
by: Graham Mattingley | last post by:
Hi Group, I have been building a search engine for about 9 months now of links to other site that I have admin Access to. This has been simple for me to keep mySQL record of page hits, as I...
1
by: Donald Canton | last post by:
Hi, I just changed my browser settings to override automatic cookie handling and block all third party cookies. Now I'm curious. How are third party cookies allowed in the first place? I thought...
0
by: |-|erc | last post by:
-- J o i n I n T h e 1 s t O n l i n e N e w Y e a r s B a s h ! <^> <(·¿·)> <^> ---- <^> <(·¿·)> <^> 2004 <^> <(·¿·)> <^> --- <^> <(·¿·)> <^> Chat at www.chatty.net THE...
1
by: Samuel R. Neff | last post by:
We're using a 3rd party C DLL in a project that we don't have source for. When we call the DLL from a console app everything works fine. However, when we call it from a Windows Service, the DLL...
0
by: UKPostie | last post by:
I am writing a solution using C# under ASP.NET that must make use of a 3rd party DLL (written in C I believe). This DLL handles messaging between my location and a third party location. I have...
4
by: Rob R. Ainscough | last post by:
The task is brain dead simple - Uninstall prior Windows Service and Install newer version of Windows Service Background: 1. My Windows Service written in .NET 1.1 and deployed via MSI (Windows...
4
by: Tarren | last post by:
Hi, All: I am tasked with the following. I need to write a service to monitor an Exchange mailbox and take action when an email is received, put it in a db, etc. I do not need to send emails...
6
by: Ben Finney | last post by:
Howdy all, I'm improving an existing application that's partly written using Python and the standard library. Many of the improvements I want to make can be done by using third-party free...
69
by: Edward K Ream | last post by:
The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.