473,395 Members | 1,996 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.

Call unmanaged .exe from c#

Hi all,
I want to load an unmanaged c++ exe file and then invoke methods inside it by using c#. I can load and invoke methods in .net exe files by using reflection but couldn't do that on unmanaged exe files.

Is there a way to do that by using c#?

Thanks in advance.
Feb 19 '09 #1
9 7339
shweta123
692 Expert 512MB
Hi,

Please refer the following link :
http://msdn.microsoft.com/en-us/magazine/cc301501.aspx
Feb 19 '09 #2
shweta123 thanks for the reply. Actually i just want to load .exe files by using c# not dll files. Because i don't want to write a wrapper class to handle unmanged dll files. What i need is accessing the methods in simple unmanaged c++ applications. I think just sending inputs to exe files and getting the outputs automatically would be enough to do what i want. Thanks for your helps.
Feb 19 '09 #3
babai28
59
Check for the intricacies of the Diagnostic class.
May be this is what you want:

Expand|Select|Wrap|Line Numbers
  1. System.Diagnostics.Process.Start("myexe.exe");
Since you also want to pass arguements to the exe you will need to use a property of the Process class (Jus check in the Visual Studio, iI forgot the name) before you can acually call the method called "Start()". Does this solve your problem?

Regards,
Siddhartha
Feb 20 '09 #4
babai28
59
Hey,

I think this code will solve your purpose:

Expand|Select|Wrap|Line Numbers
  1. Process process = new Process();
  2.     process.StartInfo.UseShellExecute = false;
  3.     process.StartInfo.RedirectStandardOutput = true;
  4.     process.StartInfo.RedirectStandardError = true;
  5.     process.StartInfo.CreateNoWindow = true;
  6.     process.StartInfo.FileName = FileName;
  7.     process.StartInfo.Arguments = Arguments;//here your aruguements will go
  8.     process.StartInfo.WorkingDirectory = WorkingDirectory;
  9.     process.Start();
I took the code from here.
You may visit this page for more information.


Regards,
Siddhartha
Feb 20 '09 #5
vekipeki
229 Expert 100+
P/Invoking should still be the preferred way to do it. Why do you want to avoid it?

There is a tool from Microsoft which generates P/Invoke signatures for you (if you have a native header file, which I presume you do ), google for "P/Invoke Interop Assistant".
Feb 20 '09 #6
Thank u all for your helps. Actually first i thought using P/Invoke to invoke methods of the unmanaged program. But it will not have a dll file what i have is just an exe file and i need to write a wrapper class to handle an unmanaged dll file to be able to use it in c# program. I want to write a program that automatically invokes the called methods in the main method of the exe file. Is it possible to manage that?
Feb 20 '09 #7
vekipeki thanks for the help. I will check it out. Regards.
Feb 20 '09 #9
@blackirish
Hello,

I try to do the same thing, using an exe in C# inside another C# code, but i don't know how i can use method or class from the first exe, any help please
May 6 '19 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gnanaprakash Rathinam | last post by:
Hi Expert, Is there a way to obtain assembly name in an unmanaged call? During Interop call between managed to unmanaged, I would like to know in unmanaged code about the caller of assembly file...
3
by: rasa | last post by:
I am able to instantiate and make calls to a com module that use only primitive data types, but I simply don't know what the c# equivalent is for a function expecting short*. Any help would be...
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
2
by: hykim | last post by:
I want to call a unmanaged dll's function returning some STRUCT's pointer. the next is definition of a STRUCT. ----------------------------------------------------------------------- typedef...
4
by: Andreas Ntalakas | last post by:
hello is it possible to call functions implemented in a C# .dll from unmanaged C++ code Thank you
2
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
0
by: Ken Durden | last post by:
A little more info. I have a unmanaged C++ DLL, compiled without /CLR. Inside a Managed C++ DLL, I have the following class: MarshalWrapper.h ---- #ifdef _MANAGED __nogc #endif
28
by: Peter Olcott | last post by:
I want to double check my understanding about how the .NET framework works. From what I understand every call to the .NET framework is ultimately translated into one of more API calls, is this...
1
by: lingchen_email | last post by:
Hi, Is there a way to call an API in unmanaged DLL from C# application in a way that the name of the API is generated programmatically? For example, I have API_AAA(p1,p2) & API_BBB(p1,p2,p3)...
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
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: 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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.