Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access only what I created

Status
Not open for further replies.

sheila11

Programmer
Dec 27, 2000
251
0
0
US
Hi all,

System.Diagnostics.Process.GetProcessesByName("WINWORD")
gives me access to any existing Word application instance, irrespective of its creator.

I want to access only the instance of Word that was created by the current thread. Is this possible ?

TIA,
Sheila
 
How can I get the id of the process that I start when I create the Word application using
Dim myWord as Word.Application = New Word.Application

?

TIA,
Sheila
 
you should use the process Class. Has alot of flex. in this example I want to know when the process is closed by the user.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim proc As Process = New Process
proc.StartInfo.FileName = "notepad.exe"
proc.StartInfo.Arguments = "C:\Somefile.dat"
proc.StartInfo.WorkingDirectory = "C:\"
AddHandler proc.Exited, AddressOf Process_Exited
proc.EnableRaisingEvents = True
proc.Start()

End Sub
Private Sub Process_Exited(ByVal sender As Object, ByVal e As EventArgs)
'get reference to the process
Dim p As Process = CType(sender, Process)
MessageBox.Show("Process ID " & p.Id.ToString() & " has ended")
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top