반응형

* VBNET API 를 이용한 한/영 키 상태 값 얻어 오기 예제...

 

Main

 

전체 소스 코드

Form1.vb

 

Imports System.Runtime.InteropServices

Public Class Form1

    'API 선언...
    Private Declare Function ImmGetContext Lib "imm32.dll" (ByVal hwnd As Integer) As Integer
    Private Declare Function ImmGetConversionStatus Lib "imm32.dll" (ByVal himc As Integer, ByRef lpdw As Integer, ByRef lpdw2 As Integer) As Integer

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        MyBase.OnLoad(e)

        Timer1.Start()

    End Sub

    Protected Overrides Sub OnClosed(ByVal e As System.EventArgs)
        MyBase.OnClosed(e)

        Timer1.Stop()

    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Try
            Dim hIMC As Integer
            Dim dwConversion As Integer, dwSentence As Integer
            Dim rc As Integer

            hIMC = ImmGetContext(textBox1.Handle.ToInt32)
            'TextBox 한영키 상태값 얻기...
            rc = ImmGetConversionStatus(hIMC, dwConversion, dwSentence)

            If dwConversion = 0 Then
                label1.Text = "한영키 상태 : 영문"
            Else
                label1.Text = "한영키 상태 : 한글"
            End If
        Catch ex As Exception
            Debug.WriteLine(ex.Message.ToString())
        End Try

    End Sub

End Class

*예제 결과

 

 

 

https://kdsoft-zeros.tistory.com/160

 

[C#] [API] 한/영 키 상태 값 구하기

* C# API 를 이용해 한/영 키 상태 값 구하기 예제... 전체 소스 코드 Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; usin..

kdsoft-zeros.tistory.com

 

반응형

+ Recent posts