Link to home
Start Free TrialLog in
Avatar of jobrems
jobremsFlag for Afghanistan

asked on

Are system calls more reliable from MFC than .NET?

Are there any known problems with making system calls (such as Desktop calls, WIndowing calls, or ShellExecute or CreateProcess) in .NET? Is it better to write such an application in MFC?
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

As far you specify marshalling properly, it will have the same reliability as MFC. Indeed you don't call from MFC (unless you are using a MFC wrapper class), you call natively the WinAPI applications.
Of course there is a little cost to invoke WinAPI function from .net, since .net makes additional checkings.
Sometimes is more easy to make system calls from native code (MFC) because you can use "ready to use" include files. As jaime_olivares said you have also  little better performance.
ASKER CERTIFIED SOLUTION
Avatar of multithreading
multithreading

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jobrems

ASKER

Thanks for your detailed answer. I also wanted to know: Are there some system calls which, when made from unmanaged code in .NET, execute incorrectly or with unexpected results?
Avatar of multithreading
multithreading

It's kind of complicated. Most calls work fine. Calls that involve callbacks can get you into trouble. I've also seen people frequently get into trouble with calls that take pointers to character buffers. There are other ways to get into trouble, but the more you know the less likely that is to happen. I think the best advice would be only programmers with a solid understanding of the CLR, C/C++, and the Win32 API should be making these mappings. There is a little bit more to it than meets the eye, especially with calls that take pointers to various objects. In the hands of someone with a thorough understanding of the various issues, you will be fine.