Usuario
Problemas al cambiar la version del Framework

Pregunta
-
En mi programa utilizo una funcion para recibir los datos de un listview de una aplicacion externa. Si compilo mi programa con la version 3.5 de Framework, funciona todo perfecto. Pero si lo compilo con la version 4.0 de Framework, no recibo ningun dato del listview externo..
¿Alguien sabria decirme por que ocurre esto?
No puedo poner todo el codigo ya que es demasiado, pero estas son las declaraciones:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function GetWindowText(ByVal hwnd As IntPtr, ByVal lpString As StringBuilder, ByVal cch As Integer) As Integer End Function <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function GetWindowTextLength(ByVal hwnd As IntPtr) As Integer End Function <DllImport("user32.dll", SetLastError:=True)> _ Private Shared Function PostMessage(ByVal hWnd As IntPtr, <MarshalAs(UnmanagedType.U4)> ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean End Function <DllImport(kernel32, SetLastError:=True)> Private Shared Function CloseHandle(ByVal handle As IntPtr) As Boolean End Function <DllImport(user32, SetLastError:=True)> Private Shared Function EnumChildWindows(ByVal hWndParent As IntPtr, ByVal enumProcDelegate As EnumChildProcDelegate, ByVal lParam As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean End Function <DllImport(user32, CharSet:=CharSet.Unicode, SetLastError:=True)> Private Shared Function FindWindow(ByVal className As String, ByVal windowName As String) As IntPtr End Function <DllImport(user32, CharSet:=CharSet.Unicode, SetLastError:=True)> Private Shared Function GetClassName(ByVal hWnd As IntPtr, ByVal className As StringBuilder, ByVal bufferSize As Integer) As Integer End Function <DllImport(kernel32, SetLastError:=True)> Private Shared Function OpenProcess(ByVal dwDesiredAccess As UInteger, ByVal bInheritHandle As Boolean, ByVal dwProcessId As Integer) As IntPtr End Function <DllImport(kernel32, SetLastError:=True)> Private Shared Function ReadProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As StringBuilder, ByVal nSize As Integer, ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean End Function <DllImport(kernel32, SetLastError:=True)> Private Shared Function ReadProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByRef lpBuffer As LV_ITEM, ByVal nSize As Integer, ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean End Function <DllImport(user32, SetLastError:=True)> Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal message As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer End Function <DllImport(user32, SetLastError:=True)> Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal message As UInteger, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer End Function <DllImport(user32, SetLastError:=True)> Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal message As UInteger, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer End Function <DllImport(kernel32, SetLastError:=True)> Private Shared Function VirtualAllocEx(ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal flAllocationType As UInteger, ByVal flProtect As UInteger) As IntPtr End Function <DllImport(kernel32, SetLastError:=True)> Private Shared Function VirtualFreeEx(ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal dwFreeType As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean End Function <DllImport(kernel32, SetLastError:=True)> Private Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByRef lpBuffer As LV_ITEM, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean End Function Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer Private Declare Auto Function SetProcessWorkingSetSize Lib "kernel32.dll" (ByVal procHandle As IntPtr, ByVal min As Int32, ByVal max As Int32) As Boolean Private Delegate Function EnumChildProcDelegate(ByVal hWnd As IntPtr, ByVal lParam As IntPtr) As Boolean <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _ Public Structure LV_ITEM Public mask As UInteger Public iItem As Integer Public iSubItem As Integer Public state As UInteger Public stateMask As UInteger Public pszText As IntPtr Public cchTextMax As Integer Public iImage As Integer Public lParam As IntPtr Public iIndent As Integer Public iGroupId As Integer Public cColumns As Integer Public puColumns As IntPtr Public piColFmt As IntPtr Public iGroup As Integer End Structure
- Cambiado Enrique M. Montejo miércoles, 1 de febrero de 2017 7:07 Pregunta relacionada con aplicación de Windows Forms.
Todas las respuestas
-
-
Hola, no entiendo para que declarar todas esa API apara trabajar con listview...?
En .net se puede usar las API, pero para usar un listview la verdad no veo la necesidad de usar APIs, ademas el codigo que colocas de ejemplo no da ningun indicio de como te conectas a las bd y como colocas los datos en el listview.
para ayudarte mejor, coloca mas informacion y con mas claridad.
Saludos