Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Interview Questions
Can you call a WIN32 API function from c# Program?
Posted By :
Posted Date :
November 21, 2011
Yes ,you can.
You can also find related Interview Question to
Can you call a WIN32 API function from c# Program?
Can I call a Win32 API function from a C# program?
Yes, you can.The .NET Framework provides a set of services called Platform Invoke, also known as PInvoke. Refer to the .NET Framework documentation for examples of using PInvoke services.
How to use Win32 API from a .NET Framework program?
Using platform invoke, .NET Framework programs can access native code libraries by means of static DLL entry points.
Here is an example of C# calling the Win32 MessageBox function:
public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);
public static void Main()
MessageBox( 0, "Hello, this is PInvoke in operation!", ".NET", 0 );
How do you directly call a native function exported from a DLL?
public static extern int MessageBoxA(int h, string m, string c, int type);
In a Java multithreading program, under what circumstances will you call the yield() method of a thread?
1, To give other runnable threads a chance to execute.
2, To start a new thread.
3, To terminate the current thread.
4, To stop the current thread for a specific time.
Answer : 1
Why do we need to call CG.SupressFinalize?
Requests that the system not call the finalizer method for the specified object.
public static void SuppressFinalize(
The method removes obj from the set of objects that require finalization. The obj parameter is required to be the caller of this method.
Objects that implement the IDisposable interface can call this method from the IDisposable.Dispose method to prevent the garbage collector from calling Object.Finalize on an object that does not require it.
What is Method Overriding? How to override a function in C#?
Use the override modifier to modify a method, a property, an indexer, or an event. An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.
You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.
Can we call a base class method without creating instance?
Its possible If its a static method.
Its possible by inheriting from that class also.
Its possible from derived classes using base keyword.
The default way of passing arguments to a function is ?
Define precondition and post-condition to a member function.
A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold.
For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation.
A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false.
For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.
Difference between a sub and a function.
A Sub Procedure is a method will not return a value
-A sub procedure will be defined with a "Sub" keyword
Sub ShowName(ByVal myName As String)
Console.WriteLine("My name is: " & myName)
-A function is a method that will return value(s).
-A function will be defined with a "Function" keyword
Function FindSum(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
Dim sum As Integer = num1 + num2
Can I use COM objects from a .NET Framework program?
Any COM component you have deployed today can be used from managed code, and in common cases the adaptation is totally automatic.
Specifically, COM components are accessed from the .NET Framework by use of a runtime callable wrapper (RCW). This wrapper turns the COM interfaces exposed by the COM component into .NET Framework-compatible interfaces. For OLE automation interfaces, the RCW can be generated automatically from a type library. For non-OLE automation interfaces, a developer may write a custom RCW and manually map the types exposed by the COM interface to .NET Framework-compatible types.
Can .NET Framework components be used from a COM program?
Managed types you build today can be made accessible from COM, and in the common case the configuration is totally automatic. There are certain new features of the managed development environment that are not accessible from COM. For example, static methods and parameterized constructors cannot be used from COM. In general, it is a good idea to decide in advance who the intended user of a given type will be. If the type is to be used from COM, you may be restricted to using those features that are COM accessible.
Depending on the language used to write the managed type, it may or may not be visible by default.
Specifically, .NET Framework components are accessed from COM by using a COM callable wrapper (CCW). This is similar to an RCW (see previous question), but works in the opposite direction. Again, if the .NET Framework development tools cannot automatically generate the wrapper, or if the automatic behavior is not what you want, a custom CCW can be developed.
What is the Transport Protocol you use to call a Web Service ?
SOAP (Simple Object Access Protocol) is the preferred protocol.
Quick Links For Interview Questions Categories:
Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.
So, Start looking our
section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.
Hall of Fame
Terms of Service
Tell A Friend