[DllImport("user32.dll")]
  private static extern long GetForegroundWindow();

解决方案 »

  1.   

    long t;
    t=GetForeGroundWindow();
      

  2.   

    [DllImport("user32.dll",CharSet=CharSet.Auto)]
    private static extern IntPtr GetForegroundWindow();[DllImport("user32.dll", CharSet=CharSet.Auto)]
    public static extern long SetWindowLong(IntPtr hWnd, int nIndex, long dwNewLong);[DllImport("user32.dll", CharSet=CharSet.Auto)]
    public static extern long GetWindowLong( IntPtr hWnd,int nIndex);
      

  3.   

    [DllImport("user32.dll", CharSet=CharSet.Auto)]
    public static extern int GetWindowRect (IntPtr hWnd , ref System.Drawing.Rectangle lpRect);
      

  4.   

    [DllImport("user32.dll", EntryPoint="GetForegroundWindow")]
    public static extern int GetForegroundWindow ();
      

  5.   

    去下一个
    api精灵FOR C# 2.35
      

  6.   

    都这怎么快啊!这些看看可能有所帮助。
    http://www.webtropy.com/articles/Win32-API-DllImport-art9.asp
    http://msdn.microsoft.com/vstudio/default.aspx?pull=/library/en-us/dndotnet/html/win32map.asp
      

  7.   

    using System.Runtime.InteropServices;使用API都要上面那一句。
      

  8.   

    能不能给个例子怎么用啊
    例如:这个函数
    [DllImport("kernel32.dll", EntryPoint="GetWindowsDirectory")]
    public static extern int GetWindowsDirectory (
    string lpBuffer,
    int nSize
    ); 
    写在那里
    怎么调用啊
    是不是还要使用这个using System.Runtime.InteropServices;语句啊?
      

  9.   

    对,加入System.Runtime.InteropServices命名空间
    在你需要使用的地方声明
    [DllImport("kernel32.dll", EntryPoint="GetWindowsDirectory")]
    public static extern int GetWindowsDirectory (
    string lpBuffer,
    int nSize
    ); 
    在需要调用的地方 int a = GetWindowsDirectory (lpBuffer,nSize);