Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2005

Tip: Looking for answers? Try searching our database.

C++/CLI:  Improved linkage to legacy Win32 DLLs?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
_R - 24 Sep 2005 18:47 GMT
I've had to write a lot of code to interface C# to older Win32 DLLs.
Basically, an unmanaged C++ class talks directly to the Win32 DLL.
A managed C++ class encloses the unmanaged C++ class.
C# talks to the managed C++ class.

Lots of work.  Is this simplified in C++/CLI?  Any sample code
anywhere?

Willy Denoyette [MVP] - 24 Sep 2005 19:31 GMT
What do you mean with simplified? You still have to wrap the native class by
a managed class and delegate the method calls to their corresponding native
method implementations.

Willy.

> I've had to write a lot of code to interface C# to older Win32 DLLs.
> Basically, an unmanaged C++ class talks directly to the Win32 DLL.
[quoted text clipped - 3 lines]
> Lots of work.  Is this simplified in C++/CLI?  Any sample code
> anywhere?
_R - 25 Sep 2005 01:28 GMT
In the original version of my code I had two C++ wrappers--unmanaged
and managed.  I did my best but it was tedious.  From what little I've
read, I should be able to simplify to just one layer of C++ code,
right?  In that declarations for managed vs unmanaged data are clear,
I can probably control that inline with handles vs pointers.  Not sure
if the calls into the native Win32 DLL are more concise though.  I'd
like to avoid using PInvoke, as some of the data types get obscure.
Is this made transparent in 2005beta2?

>What do you mean with simplified? You still have to wrap the native class by
>a managed class and delegate the method calls to their corresponding native
[quoted text clipped - 9 lines]
>> Lots of work.  Is this simplified in C++/CLI?  Any sample code
>> anywhere?
_R - 25 Sep 2005 06:33 GMT
>In the original version of my code I had two C++ wrappers--unmanaged
>and managed.  I did my best but it was tedious.  From what little I've
[quoted text clipped - 18 lines]
>>> Lots of work.  Is this simplified in C++/CLI?  Any sample code
>>> anywhere?
_R - 25 Sep 2005 07:09 GMT
>>What do you mean with simplified? You still have to wrap the native class by
>>a managed class and delegate the method calls to their corresponding native
>>method implementations.
>>
>>Willy.

> In the original version of my code I had two C++ wrappers--unmanaged
> and managed.   From what I've read, I should be able to simplify to just
> one layer of C++ code,

PS:  I could have stated that more clearly:  I had two layers of C++
DLLs *in VS 2003*.  I used an unmanaged wrapper to talk to the old
Win32 DLL.  That wrapper collected functions into an organized class,
localized data, and generally imposed some structure.

A managed C++ DLL wrapped that unmanaged class so it could be called
easily from C#.  Each DLL required different compile switches.

Q:  Are there any new features in C++/CLI that would simplify this
process?
Arnaud Debaene - 25 Sep 2005 10:48 GMT
>>> What do you mean with simplified? You still have to wrap the native
>>> class by a managed class and delegate the method calls to their
[quoted text clipped - 16 lines]
> Q:  Are there any new features in C++/CLI that would simplify this
> process?

Well, you can certainly fold the 2 C++ DLLs (managed and unmanaged) into 1 :
just have the "organized class, localized data, and generally imposed some
structure" stuff be directly in the managed C++ DLL (MC++ and C++/CLI can
call directly on Win32).
Btw, you could have done the same thing in VS2003, although the syntaxic
clumsiness of MC++ would have made it cumbersome.

Arnaud
MVP - VC
_R - 26 Sep 2005 19:19 GMT
>> I had two layers of C++
>> DLLs *in VS 2003*.  I used an unmanaged wrapper to talk to the old
[quoted text clipped - 6 lines]
>> Q:  Are there any new features in C++/CLI that would simplify this
>> process?

>Well, you can certainly fold the 2 C++ DLLs (managed and unmanaged) into 1 :
>just have the "organized class, localized data, and generally imposed some
>structure" stuff be directly in the managed C++ DLL (MC++ and C++/CLI can
>call directly on Win32).

Thanks, Arnaud.  Do you happen to know of any code samples that would
illustrate the new syntax?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.