Results 1 to 3 of 3

Thread: Delaring API's ***RESOLVED***

  1. #1

    Thread Starter
    Addicted Member d.patrick's Avatar
    Join Date
    Nov 2004
    Location
    Oshkosh, WI
    Posts
    172

    Resolved Delaring API's ***RESOLVED***

    I am new to C# and need to convert a VB.NET library to C#. The library uses some API's and I haven't got a clue. Can anyone help? Below are the API's:

    Code:
    Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Integer) As Integer
        Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Integer, ByVal un As Integer, ByVal b As Integer, ByRef lpMenuItemInfo As MENUITEMINFO) As Integer
        Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
        Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Integer) As Integer
        Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
        Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
        Private Declare Function SetFocusAPI Lib "user32" Alias "SetFocus" (ByVal hwnd As Integer) As Integer
    Last edited by d.patrick; Jan 14th, 2005 at 04:17 PM.

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: Delaring API's

    To use APIs a quick example
    Code:
    using System;
    using System.Runtime.InteropServices;
    using System.Diagnostics;
    
    class myClass
    {
      [DllImport("user32.dll")]
      public static extern int MessageBox(int hParent,string Message,string Caption,int Type);
    
      static void Main()
      {
        MessageBox(0,"Hello","Message",0);
      }
    }

  3. #3

    Thread Starter
    Addicted Member d.patrick's Avatar
    Join Date
    Nov 2004
    Location
    Oshkosh, WI
    Posts
    172

    Re: Delaring API's

    Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width