give u a example:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: [email protected]
    Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
    'Ask for a Window title
    Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
    'Search the window
    WinWnd = FindWindow(vbNullString, Ret)
    If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
    'Show the window
    ShowWindow WinWnd, SW_SHOWNORMAL
    'Create a buffer
    lpClassName = Space(256)
    'retrieve the class name
    RetVal = GetClassName(WinWnd, lpClassName, 256)
    'Show the classname
    MsgBox "Classname: " + Left$(lpClassName, RetVal)
    'Post a message to the window to close itself
    PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub

解决方案 »

  1.   

    ShowWindow VB声明 
    Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long 
    说明 
    控制窗口的可见性(在vb里使用:针对vb窗体及控件,请使用对应的vb属性) 
    返回值 
    Long,如窗口之前是可见的,则返回TRUE(非零),否则返回FALSE(零) 
    参数表 
    参数 类型及说明 
    hwnd Long,窗口句柄,要向这个窗口应用由nCmdShow指定的命令 
    nCmdShow Long,为窗口指定可视性方面的一个命令。请用下述任何一个常数 
    SW_HIDE 隐藏窗口,活动状态给令一个窗口 
    SW_MINIMIZE 最小化窗口,活动状态给令一个窗口 
    SW_RESTORE 用原来的大小和位置显示一个窗口,同时令其进入活动状态 
    SW_SHOW 用当前的大小和位置显示一个窗口,同时令其进入活动状态 
    SW_SHOWMAXIMIZED 最大化窗口,并将其激活 
    SW_SHOWMINIMIZED 最小化窗口,并将其激活 
    SW_SHOWMINNOACTIVE 最小化一个窗口,同时不改变活动窗口 
    SW_SHOWNA 用当前的大小和位置显示一个窗口,不改变活动窗口 
    SW_SHOWNOACTIVATE 用最近的大小和位置显示一个窗口,同时不改变活动窗口 
    SW_SHOWNORMAL 与SW_RESTORE相同 Top
     
      

  2.   

    在module1.bas中加入:
    Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Public Const SW_HIDE = 0
    Public Const SW_SHOW = 5
    Public Const SW_MAXIMIZE = 3
    Public Const SW_MINIMIZE = 6
    Public Const SW_NORMAL = 1
    在需要调用的地方:
     showwindow form1.hWnd,SW_MAXIMIZE其返回值为Long. 成功>0,否则=0
      

  3.   

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As LongPrivate Sub Command1_Click()
        Dim meWin As Long, ret As String
        meWin = FindWindow(vbNullString, "Form1")
        Call ShowWindow(meWin, 2) '最小
        Call ShowWindow(meWin, 1) '普通
        Call ShowWindow(meWin, 4) '普通
        Call ShowWindow(meWin, 2) '最小
        Call ShowWindow(meWin, 3) '最大
        Call ShowWindow(meWin, 0) '隐藏
        Call ShowWindow(meWin, 5) '显示
    End Sub
      

  4.   

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As LongPrivate Sub Command1_Click()
        Dim meWin As Long, ret As String
        meWin = FindWindow(vbNullString, "Form1")
        Call ShowWindow(meWin, 2) '最小
        Call ShowWindow(meWin, 1) '普通
        Call ShowWindow(meWin, 4) '普通
        Call ShowWindow(meWin, 2) '最小
        Call ShowWindow(meWin, 3) '最大
        Call ShowWindow(meWin, 0) '隐藏
        Call ShowWindow(meWin, 5) '显示
    End Sub
      

  5.   

    在API函数中,所有有返回值的函数都可以把返回数值的类型定义为long
    这是有32位操作系统决定的。
      

  6.   

    给你一个能运行的例子:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Const SW_SHOWNORMAL = 1
    Const WM_CLOSE = &H10
    Const gcClassnameMSWord = "OpusApp"
    Const gcClassnameMSExcel = "XLMAIN"
    Const gcClassnameMSIExplorer = "IEFrame"
    Const gcClassnameMSVBasic = "wndclass_desked_gsk"
    Const gcClassnameNotePad = "Notepad"
    Const gcClassnameMyVBApp = "ThunderForm"
    Private Sub Form_Load()
        'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
        'Ask for a Window title
        Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
        'Search the window
        WinWnd = FindWindow(vbNullString, Ret)
        If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
        'Show the window
        ShowWindow WinWnd, SW_SHOWNORMAL
        'Create a buffer
        lpClassName = Space(256)
        'retrieve the class name
        RetVal = GetClassName(WinWnd, lpClassName, 256)
        'Show the classname
        MsgBox "Classname: " + Left$(lpClassName, RetVal)
        'Post a message to the window to close itself
        PostMessage WinWnd, WM_CLOSE, 0&, 0&
    End Sub
      

  7.   

    C语言的Boolean是32位的
    所以定义为Long