 |
lao Level: Protégé
 Registered: 27-07-2005 Posts: 4
|
Close an API
How can I close a file from VB6?
I need to close a file opened with ShellExecute, but I can't close it by code.
somebody can help me?
Thanks a looot !
____________________________
Lao :o)
|
|
27-07-2005 at 02:14 AM |
|
|
Asim-GDI GURU Level: Sage
 Registered: 29-07-2005 Posts: 54
|
Re: Close an API
Hey bro,
I found a solution to your problem.Its a case study which will help you alot.Its just for your problem...
http://www.freevbcode.com/ShowCode.asp?ID=670
Hope it helps you...
Regards,
Asim Siddiqui...
|
|
29-07-2005 at 02:25 PM |
|
|
lao Level: Protégé
 Registered: 27-07-2005 Posts: 4
|
Re: Close an API
I still can't close the file.... could somebody help me please??
____________________________
Lao :o)
|
|
03-10-2005 at 06:33 PM |
|
|
lao Level: Protégé
 Registered: 27-07-2005 Posts: 4
|
Re: Close an API
I've tried but i can't.... i'm not an API's expert.. do you?
could you help me?
____________________________
Lao :o)
|
|
03-10-2005 at 06:35 PM |
|
|
Asim-GDI GURU Level: Sage
 Registered: 29-07-2005 Posts: 54
|
Re: Close an API
send your program..
we'll try what we can do...
|
|
03-10-2005 at 09:19 PM |
|
|
Asim-GDI GURU Level: Sage
 Registered: 29-07-2005 Posts: 54
|
Re: Close an API
I dont think there's any problem in your code.I think that the code is not getting the correct Window title, and so wrong window handle.See the following example from ALLAPI:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Post a message to the window to close itself
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub
THIS IS AN EDITED VERSION OF THE ORIGINAL CODE.
[Edited by Asim-GDI GURU on 04-10-2005 at 07:23 AM GMT]
|
|
04-10-2005 at 02:17 AM |
|
|
|
|
 |
 |