LzmTW.uSystem.uWindows.SafeNative+SafeNativeMethods

Author:水如烟  

Imports  System.Runtime.InteropServices
Imports  System.Text

Namespace  LzmTW.uSystem.uWindows.SafeNative
    
Friend   Class  SafeNativeMethods
        
Sub   New ()
        
End Sub

        
' -------------------------------------
         ' 枚举窗体,激活窗体

        
Public   Declare   Function  EnumWindows  Lib   " user32.dll "  _
            
Alias   " EnumWindows "  ( ByVal  callback  As  Win32API.EnumWindowsCallback, _
                                 
ByVal  lParam  As   Integer As   Integer

        
< DllImport( " user32.dll " , EntryPoint: = " EnumWindows " , SetLastError: = True , _
        CharSet:
= CharSet.Ansi, ExactSpelling: = True , _
        CallingConvention:
= CallingConvention.StdCall) >  _
        
Public   Shared   Function  EnumWindowsDllImport( ByVal  callback  As  Win32API.EnumWindowsCallback, _
                                                    
ByVal  lParam  As   Integer As   Integer
        
End Function

        
Public   Declare   Auto   Function  FindWindow  Lib   " user32.dll "  _
            
Alias   " FindWindow "  ( ByVal  lpClassName  As   String , _
                                
ByVal  lpWindowName  As   String As   Integer

        
Public   Declare   Auto   Function  FindWindowAny  Lib   " user32.dll "  _
        
Alias   " FindWindow "  ( ByVal  lpClassName  As   Integer , _
                            
ByVal  lpWindowName  As   Integer As   Integer

        
Public   Declare   Auto   Function  FindWindowNullClassName  Lib   " user32.dll "  _
            
Alias   " FindWindow "  ( ByVal  lpClassName  As   Integer , _
                                
ByVal  lpWindowName  As   String As   Integer

        
Public   Declare   Auto   Function  FindWindowNullWindowCaption  Lib   " user32.dll "  _
           
Alias   " FindWindow "  ( ByVal  lpClassName  As   String , _
                               
ByVal  lpWindowName  As   Integer As   Integer


        
Public   Declare   Function  GetClassName  Lib   " user32.dll "  _
           
Alias   " GetClassNameA "  ( ByVal  hwnd  As   Integer , _
                                  
ByVal  lpClassName  As  StringBuilder, _
                                  
ByVal  cch  As   Integer As   Integer


        
Public   Declare   Function  GetParent  Lib   " user32.dll "  _
            
Alias   " GetParent "  ( ByVal  hwnd  As   Integer As   Integer


        
Public   Declare   Function  GetWindow  Lib   " user32.dll "  _
            
Alias   " GetWindow "  ( ByVal  hwnd  As   Integer , _
                               
ByVal  wCmd  As   Integer As   Integer

        
Public   Declare   Function  GetWindowLong  Lib   " user32.dll "  _
            
Alias   " GetWindowLongA "  ( ByVal  hwnd  As   Integer , _
                                    
ByVal  nIndex  As   Integer As   Integer

        
Public   Declare   Sub  GetWindowText  Lib   " user32.dll "  _
            
Alias   " GetWindowTextA "  ( ByVal  hWnd  As   Integer , _
                                    
ByVal  lpString  As  StringBuilder, _
                                    
ByVal  nMaxCount  As   Integer )

        
Public   Declare   Function  IsIconic  Lib   " user32.dll "  _
            
Alias   " IsIconic "  ( ByVal  hwnd  As   Integer As   Boolean

        
Public   Declare   Function  IsPwrHibernateAllowed  Lib   " Powrprof.dll "  _
            
Alias   " IsPwrHibernateAllowed "  ()  As   Integer

        
Public   Declare   Function  IsWindowVisible  Lib   " user32.dll "  _
            
Alias   " IsWindowVisible "  ( ByVal  hwnd  As   Integer As   Boolean

        
Public   Declare   Function  SetForegroundWindow  Lib   " user32.dll "  _
            
Alias   " SetForegroundWindow "  ( ByVal  hwnd  As   Integer As   Integer

        
Public   Declare   Function  SetSuspendState  Lib   " Powrprof.dll "  _
            
Alias   " SetSuspendState "  ( ByVal  Hibernate  As   Integer , _
                                     
ByVal  ForceCritical  As   Integer , _
                                     
ByVal  DisableWakeEvent  As   Integer As   Integer

        
Public   Declare   Function  ShowWindow  Lib   " user32.dll "  _
            
Alias   " ShowWindow "  ( ByVal  hwnd  As   Integer ByVal  nCmdShow  As   Integer As   Integer

        
' -------------------------------------------
         ' 鼠标和键盘钩子

        
Public   Delegate   Function  HookProc( ByVal  nCode  As   Integer ByVal  wParam  As   Integer ByVal  lParam  As  IntPtr)  As   Integer

        
' //封送结构
         < StructLayout(LayoutKind.Sequential) >  _
        
Public   Class  POINT
            
Public  x  As   Integer
            
Public  y  As   Integer
        
End Class

        
< StructLayout(LayoutKind.Sequential) >  _
        
Public   Class  MouseHookStruct
            
Public  pt  As  POINT
            
Public  hWnd  As   Integer
            
Public  wHitTestCode  As   Integer
            
Public  dwExtraInfo  As   Integer
        
End Class

        
< StructLayout(LayoutKind.Sequential) >  _
        
Public   Class  KeyboardHookStruct
            
Public  vkCode  As   Integer   ' 1到254间的虚似键盘码
             Public  scanCode  As   Integer   ' 扫描码
             Public  flags  As   Integer
            
Public  time  As   Integer
            
Public  dwExtraInfo  As   Integer
        
End Class

        
< DllImport( " user32.dll " , CallingConvention: = CallingConvention.StdCall, CharSet: = CharSet.Auto) >  _
         
Public   Shared   Function  SetWindowsHookEx( ByVal  idHook  As   Integer ByVal  lpfn  As  HookProc,  ByVal  hInstance  As  IntPtr,  ByVal  threadId  As   Integer As   Integer
        
End Function
        
< DllImport( " user32.dll " , CallingConvention: = CallingConvention.StdCall, CharSet: = CharSet.Auto) >  _
         
Public   Shared   Function  UnhookWindowsHookEx( ByVal  idHook  As   Integer As   Boolean
        
End Function
        
< DllImport( " user32.dll " , CallingConvention: = CallingConvention.StdCall, CharSet: = CharSet.Auto) >  _
         
Public   Shared   Function  CallNextHookEx( ByVal  idHook  As   Integer ByVal  nCode  As   Integer ByVal  wParam  As   Integer ByVal  lParam  As  IntPtr)  As   Integer
        
End Function

        
< DllImport( " user32 " ) >  _
        
Public   Shared   Function  ToAscii( ByVal  uVirtKey  As   Integer ByVal  uScanCode  As   Integer ByVal  lpbKeyState  As   Byte (),  ByVal  lpwTransKey  As   Byte (),  ByVal  fuState  As   Integer As   Integer
        
End Function

        
< DllImport( " user32 " ) >  _
        
Public   Shared   Function  GetKeyboardState( ByVal  pbKeyState  As   Byte ())  As   Integer
        
End Function

        
Public   Declare   Function  GetKeyState  Lib   " user32 "   Alias   " GetKeyState "  ( ByVal  nVirtKey  As   Integer As   Integer

        
Public   Declare   Function  SetParent  Lib   " user32 "   Alias   " SetParent "  ( ByVal  hWndChild  As  IntPtr,  ByVal  hWndNewParent  As  IntPtr)  As   Integer

    
End Class
End Namespace

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值