473,386 Members | 1,694 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,386 software developers and data experts.

consuming unmanaged dlls in VC++

Hello everybody!

I've this problem:

I'm working on a download meter, based on wpcap. As wpcap code is
unmanaged, I decided to create the needed functions in a unmanaged
project (one for opening an an adapter and capturing the packets (and
thus counting the data downloaded), one for getting the byte-count and
one for stopping the packet capturing), and place them in a dll, which
exports functions
void capture(),
void stopping(),
long getbytes().
And now I want to import these functions into a managed C++
application.
So I created a class pcapImport, and inside it I've tried to somehow
import those functions.
I've tried this:
[DllImport("pcapDLL.dll")] extern "C" long getbytes (); but I couldn't
even compile that thing, i got an error: C2059, syntax error,
then I tried this
[DllImport("pcapDLL.dll")] extern long getbytes ();
and got an error: C2720, 'extern' storage-class specifier illegal on
members
and finally tried this:
[DllImport("pcapDLL.dll")] static long getbytes ();
In this case no compilation error occurred, but the pcapDLL.dll hadn't
been loaded (not listed among the modules) and although it doesn't
throws an exception (something like function does not exist) it just
doesn't do anything.

Well, I've Googled a lot, but hadn't find anything what's working.

I'd appreciate any help.
Thanks,
Matyi

May 23 '06 #1
1 1751
Why not create a mixed model project in VC++?
the only two things you need to do in order to mix MFC and Managed
Extensions is to set the Use Managed Extensions project property (which
equates to the /clr compiler switch) and add the appropriate #using and
using directives to your code.

"Matyi" <ma**********@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello everybody!

I've this problem:

I'm working on a download meter, based on wpcap. As wpcap code is
unmanaged, I decided to create the needed functions in a unmanaged
project (one for opening an an adapter and capturing the packets (and
thus counting the data downloaded), one for getting the byte-count and
one for stopping the packet capturing), and place them in a dll, which
exports functions
void capture(),
void stopping(),
long getbytes().
And now I want to import these functions into a managed C++
application.
So I created a class pcapImport, and inside it I've tried to somehow
import those functions.
I've tried this:
[DllImport("pcapDLL.dll")] extern "C" long getbytes (); but I couldn't
even compile that thing, i got an error: C2059, syntax error,
then I tried this
[DllImport("pcapDLL.dll")] extern long getbytes ();
and got an error: C2720, 'extern' storage-class specifier illegal on
members
and finally tried this:
[DllImport("pcapDLL.dll")] static long getbytes ();
In this case no compilation error occurred, but the pcapDLL.dll hadn't
been loaded (not listed among the modules) and although it doesn't
throws an exception (something like function does not exist) it just
doesn't do anything.

Well, I've Googled a lot, but hadn't find anything what's working.

I'd appreciate any help.
Thanks,
Matyi

May 24 '06 #2

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

Similar topics

2
by: Thomas W. Brown | last post by:
I have setup Console redirection within my Console app (via Console.SetOut and Console.SetErrror) to route console WriteLine calls to a logfile. This works just fine with one exception... I use...
0
by: Frank Lopez | last post by:
My program structure is: 1. 2. 3. => manually does the crt-init and crt-terminate calls 4. -- this is accessed by the unmanaged C++ classes in (3) using LoadLibrary and FreeLibrary
4
by: repstat | last post by:
Hi I have a project which is going to be doing some string manipulation which needs to be pretty fast. The user interface is going to be written in C#. I am going to write the string handling...
4
by: gmclean | last post by:
I have VC++ project that is unmanaged. I would like to build components like user interface dialog boxes in VB .net and call them from the unmanaged VC++ application. Is this possible? Before .net...
3
by: Dave | last post by:
I've seen at least one article on this: How to access classes, etc. managed-to-unmanaged. I can't find it. Any tricks or pointers? I guess the class name won't get munged but I'm not clear about...
3
by: gopal | last post by:
I am developing an application in CSharp - windows forms based, which copies the DLLs both unmanaged and managed DLLs from a shared folder and will overwrite the existing versions of managed &...
6
by: Stephen Walch | last post by:
Our application environment consists of three basic layers: 1. Third-party unmanaged DLLs that were written before the CLR was invented and maintain a significant amount of information (including...
6
by: Volodia | last post by:
Hi, I have a problem to find information how to add unmanaged dll build in VC++ 2005 to the asp.net web site What I have tried: 1. use DllImport("MyDll.dll") to declare function in...
13
by: =?Utf-8?B?d3BjbWFtZQ==?= | last post by:
I have a small C++/CLI application which calls an unmanaged lib. It seems like I can't use /clr:pure and link with the unmanaged lib (LNK1313 error). The problem I have is that compiling with...
0
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,...
0
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$) { } ...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
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 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.