By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,550 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,550 IT Pros & Developers. It's quick & easy.

VB6 to VB.NET dlls

P: n/a
What is the proper VB.NET way to declare these VB6 dlls?

Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Public Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Declare Function IsWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, _
lpdwProcessId As Long) As Long

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article <41**********************************@microsoft.co m>, Cutlass wrote:
What is the proper VB.NET way to declare these VB6 dlls?

Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As System.IntPtr, _
ByVal dwMilliseconds As Integer) As Integer
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As System.IntPtr) As Boolean
Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Public Auto Declare Function FindWindow Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As System.IntPtr
Public Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Declare Auto Function PostMessage Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Boolean
Public Declare Function IsWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Public Declare Function IsWindow Lib "user32" _
(ByVal hWnd As System.IntPtr) As Boolean
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Integer, _
ByVal bInheritHandle As Boolean, _
ByVal dwProcessId As System.IntPtr) As System.IntPtr
Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, _
lpdwProcessId As Long) As Long


Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByRef lpdwProcessId As System.IntPtr) As System.IntPtr

--
Tom Shelton [MVP]
Nov 21 '05 #2

P: n/a
THANKS!

No my VB6 calls fail, can you help?

Dim hWindow As Long
Dim hThread As Long
Dim hProcess As Long
Dim lProcessId As Long
Dim lngResult As Long
Dim lngReturnValue As Long
Dim iLoopCnt As Integer

hWindow = FindWindow(vbNullString, "(Inactive " & sDir & "\EDIAPIS.EXE)")
hThread = GetWindowThreadProcessId(hWindow, lProcessId)
hProcess = OpenProcess(SYNCHRONIZE, 0&, lProcessId)
lngReturnValue = PostMessage(hWindow, WM_CLOSE, 0&, 0&)
lngResult = WaitForSingleObject(hProcess, 20000)

"Tom Shelton" wrote:
In article <41**********************************@microsoft.co m>, Cutlass wrote:
What is the proper VB.NET way to declare these VB6 dlls?

Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As System.IntPtr, _
ByVal dwMilliseconds As Integer) As Integer
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long


Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As System.IntPtr) As Boolean
Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long


Public Auto Declare Function FindWindow Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As System.IntPtr
Public Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long


Public Declare Auto Function PostMessage Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Boolean
Public Declare Function IsWindow Lib "user32" _
(ByVal hwnd As Long) As Long


Public Declare Function IsWindow Lib "user32" _
(ByVal hWnd As System.IntPtr) As Boolean
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long


Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Integer, _
ByVal bInheritHandle As Boolean, _
ByVal dwProcessId As System.IntPtr) As System.IntPtr
Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, _
lpdwProcessId As Long) As Long


Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByRef lpdwProcessId As System.IntPtr) As System.IntPtr

--
Tom Shelton [MVP]

Nov 21 '05 #3

P: n/a
Can't you just add them as references and act upon them once instantiated?

"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> wrote in message
news:uB**************@TK2MSFTNGP09.phx.gbl...
In article <41**********************************@microsoft.co m>, Cutlass
wrote:
What is the proper VB.NET way to declare these VB6 dlls?

Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As System.IntPtr, _
ByVal dwMilliseconds As Integer) As Integer
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long


Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As System.IntPtr) As Boolean
Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long


Public Auto Declare Function FindWindow Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As System.IntPtr
Public Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long


Public Declare Auto Function PostMessage Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Boolean
Public Declare Function IsWindow Lib "user32" _
(ByVal hwnd As Long) As Long


Public Declare Function IsWindow Lib "user32" _
(ByVal hWnd As System.IntPtr) As Boolean
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long


Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Integer, _
ByVal bInheritHandle As Boolean, _
ByVal dwProcessId As System.IntPtr) As System.IntPtr
Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, _
lpdwProcessId As Long) As Long


Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As System.IntPtr, _
ByRef lpdwProcessId As System.IntPtr) As System.IntPtr

--
Tom Shelton [MVP]

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.