GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  C#
Next Question 
 C#  |  Question 1 of 436    Print  

Why does DllImport not work for me?

All methods marked with the DllImport attribute must be marked as public static extern.


  
Total Answers and Comments: 3 Last Update: January 05, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 22, 2005 15:18:13   #1  
Timothy Marin        

RE: Why does DllImport not work for m...
be sure to referance System.Runtime.InteropServices;
 
Is this answer useful? Yes | No
April 17, 2007 07:18:48   #2  
jbanx Member Since: February 2007   Contribution: 38    

RE: Why does DllImport not work for m...
Following is the example to use it properly This is from msdn for more visit
http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx


using
System;
using System.Runtime.InteropServices;

class Example
{
// Use DllImport to import the Win32 MessageBox function.
[DllImport("user32.dll" CharSet CharSet.Auto)]
public static extern int MessageBox(IntPtr hWnd String text String caption uint type);

static void Main()
{
// Call the MessageBox function using platform invoke.
MessageBox(new IntPtr(0) "Hello World!" "Hello Dialog" 0);
}
}

 
Is this answer useful? Yes | No
January 05, 2008 20:17:54   #3  
Robertxie Member Since: January 2008   Contribution: 1    

RE: Why does DllImport not work for me?
It works perfectly. You can find the dialogue window by using "ALT+Tab" key
Robert

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape