Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ WPF
i have one dll Apms.dll which is not supported to WPF (.net).
 
So i need to write a wrapper in C++ and use it in WPF appln.
 
iam new to wrapper creation . i have some API calls for Apms.dll .They are
 
RETCOND API1090 ApmsApiSrvConnect
( LPTSTR szServerName, LPDWORD dwClientNbr,
LPDWORD dwReserved );
 
Return code is of
 
R_NORMAL
 
R_NOCONN
 
R_NOACTIVE ..
 
can anybody help me in writing this Wrapper for the Api method in C++ and connect with my WPF application?
Posted 17-Apr-13 3:24am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to look into the use of P/Invoke[^] for accessing C style DLL functions from .NET applications.
  Permalink  
Comments
Espen Harlinn at 17-Apr-13 10:40am
   
Right, or use C++/Cli :-D
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Using a mixed mode C++/CLI DLL might be an easy way to provide a .NET friendlier interface for calling code in APms.dll. However if you only have a few functions to call, then the P/Invoke approach would be a better choice.
 
Typically, if P/Invoke is sufficient then you should go with it. On the other hand, if the DLL is relatively complex to use, wrapper might also help to simplify the use of its function.
 
I guess that Apms.dll is external to your company and that you only have the DLL (and its library for linking).
 
Because, if you have the full source code, you might consider compiling the DLL in mixed mode and have the .NET wrapper in the same DLL,
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 520
1 Maciej Los 290
2 Richard MacCutchan 265
3 BillWoodruff 265
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,764
1 Sergey Alexandrovich Kryukov 7,437
2 DamithSL 5,639
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 17 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100