C
Conteacky
Перенес код из VB6, где он без проблем работает в VB 2005 (NET 2.0) и сразу проблемы. Помогите разобраться - ошибка или NET и API несовместимы ?
Код:
Imports System
Public Class Form1
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _
(ByVal hwnd As IntPtr) As Integer
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" _
(ByVal hwnd As IntPtr, _
ByVal lpString As String, _
ByVal cch As Long) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim hwnd As IntPtr = FindWindow(vbNullString, "Form1")
Dim Length As Integer = GetWindowTextLength(hwnd)
Dim sName As String = Space$(Length)
GetWindowText(hwnd, sName, Length)
TextBox1.Text = sName
End Sub
End Class