The code works when I spawn notepad, it doesn't when I use my exe.
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
"95isalive" wrote:
> If you're using GetProcessbyName use the short or shell name of the process
>
> GetProcessByName("cmd") or GetProcessByName("command") instead of using cmd.exe or
> command.com
>
> There's an example script in the MSDN library for closing instances of notepad, but once
> again I'm away from that machine.
>
> --
> Steve Easton
> Microsoft MVP FrontPage
> 95isalive
> This site is best viewed..................
> ...............................with a computer
>
>
> "Cutlass" <(E-Mail Removed)> wrote in message
> news
BD65DA4-A943-439C-A099-(E-Mail Removed)...
> > Thanks
> > I tried all afternoon and can't get it to work, it's as if the DOS window
> > doesn't exist.
> > I must be coding something wrong ... when I go into task manager after the
> > spawn I can see the exe listed and I see it in the taskbar/screen too...I
> > just can't seem to program a Close for it.....HELP Very Appreciated...I can
> > use the API method..that works...but I want to code pure .NET if you know
> > what I mean...
> >
> > "95isalive" wrote:
> >
> > > Check help for GetProcessbyID or GetProcessbyName
> > >
> > > I'm not at my VS.Net / MSDN machine right now or I'd post some syntax.
> > >
> > >
> > > --
> > > Steve Easton
> > > Microsoft MVP FrontPage
> > > 95isalive
> > > This site is best viewed..................
> > > ...............................with a computer
> > >
> > > "Cutlass" <(E-Mail Removed)> wrote in message
> > > news:3C8900D3-6CC7-45A0-8515-(E-Mail Removed)...
> > > > Hi,
> > > > I'm using the following code to spawn another app from VB.NET..
> > > >
> > > > Dim ShellProcess As New Process
> > > > ShellProcess.StartInfo.FileName = "xxxx.exe"
> > > > ShellProcess.StartInfo.UseShellExecute = True
> > > > ShellProcess.StartInfo.WorkingDirectory = "C:\Windows\System32"
> > > > ShellProcess.Start()
> > > > ShellProcess.WaitForInputIdle()
> > > >
> > > > xxxx.exe creates a DOS window
> > > > I am unable to close it via.... ShellProcess.CloseMainWindow()
> > > > or kill it via....ShellProcess.Kill()
> > > > I know I can use API FindWindow, PostMessage etc. I'm looking for a true
> > > > .NET clean way to do this. Nothing I try works! Anybody run into this?
> > > >
> > > >
> > >
> > >
> > >
>
>
>