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

calling unmanaged c++

Can someone provide a small snippet of how to call unmanaged c++ from within
a c# application. The code is in a .lib file, and not in a .dll. Can you
include headers in c# !!???
Nov 15 '05 #1
6 1285
Jacob,
The code is in a .lib file, and not in a .dll.
In that case you must first link it into a DLL to be able to use it
from C#.

Can you include headers in c# !!???


No

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2
You cannot link a lib directly with a C# program.

Write a c++ wrapper for the lib and access it using pInvoke.

--
Bob Powell [MVP]
C#, System.Drawing

September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

"Jacob Gladish" <ja**********@yahoo.com> wrote in message
news:#n**************@TK2MSFTNGP09.phx.gbl...
Can someone provide a small snippet of how to call unmanaged c++ from within a c# application. The code is in a .lib file, and not in a .dll. Can you
include headers in c# !!???

Nov 15 '05 #3
Even for a dll file, if not a COM, can we use it in C#? If we could,
is there any sample project which show the way to do it? Thanks

Mattias Sjögren <ma********************@mvps.org> wrote in message news:<O$**************@TK2MSFTNGP12.phx.gbl>...
Jacob,
The code is in a .lib file, and not in a .dll.


In that case you must first link it into a DLL to be able to use it
from C#.

Can you include headers in c# !!???


No

Mattias

Nov 15 '05 #4
chrisben wrote:
Even for a dll file, if not a COM, can we use it in C#? If we could,
is there any sample project which show the way to do it? Thanks


I have a managed C++ class that calls AdjustTokenPrivileges, from the
MS Win32 call list.
I just use (my namespace is ACLabLoginUtil)
using ACLabLoginUtil

and that allows my C# program to use the C++ functions.

I had to include the file in my project though, as a reference, but
that was it.

Nov 15 '05 #5
chrisben wrote:
Even for a dll file, if not a COM, can we use it in C#? If we could,
yes
is there any sample project which show the way to do it? Thanks


even better, here's a tutorial:

http://msdn.microsoft.com/library/de...keTutorial.asp

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)
Nov 15 '05 #6


thanks for the help

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #7

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

Similar topics

4
by: jarmopy | last post by:
Hi, I have made a service with C# and calling that service class from another C# program with remoting. (Referendes from the calling program) That service class is configured so that garpage...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
0
by: monika.saxena | last post by:
Hi all, In one of my projects which is a web based application in asp.net, a third party tool - "Frontline Solver DLL" (It is an unmanaged DLL and ..NET is calling it using the PInvoke) is used....
1
by: Leftie | last post by:
Folks, I'm trying to call an unmanaged function from VB.NET and keep getting "Object reference not set to an instance of an object" error. The code that i wrote can be found at:...
1
by: MC-Advantica | last post by:
Does anyone have a simple "Hello World" like application that demonstrates unmanaged C++ calling managed C++ developed in VS2005? I'm confused by many posts as they discuss managed extensions from...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
3
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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,...
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
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,...

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.