The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Kill Origin Instance

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
peter.cook Posted - 03/30/2004 : 08:42:01 AM
HI,

I'm running Origin 7.5 from Excel via COM and I'd like to be able to check if any instances of Origin are already open and then provide the option of killing these prior to launching a new instance of Origin.

Any assist would be appreciated here..

Thanks,

Cheers,

Pete

2   L A T E S T    R E P L I E S    (Newest First)
peter.cook Posted - 03/31/2004 : 06:00:07 AM

Thanks Marko!

This is really helpful and I wouldn't have known where to start.

I had wondered about trying to kill the application but now think I might have to get user to do it manually.

Cheers,

Pete

ML Posted - 03/30/2004 : 12:54:13 PM
Here is little VBA code that could be used. The string code inside the callback EnumWindows_CallBack() looks for a match of window title which starts with the string "Origin".


 
'---------------------------------------------------------------

Declarations

Private Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long

Private Declare Function GetWindowText Lib "user32" Alias _
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long

Private Declare Function GetWindowTextLength Lib "user32" _
Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long

Dim bFound As Boolean



Public Sub Main()

bFound = False
bb = EnumWindows(AddressOf EnumWindows_CallBack, 0)

If bFound Then
MsgBox "Origin found"
Else
MsgBox "Origin not found"
End If


End Sub



' This function is called from the EnumWindows API
Private Function EnumWindows_CallBack(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim wndName As String
Length = GetWindowTextLength(hwnd)
wndName = Space$(Length + 1)
Length = GetWindowText(hwnd, wndName, Length + 1)
If InStr(wndName, "Origin") = 1 Then
EnumWindows_CallBack = 0
bFound = True
Exit Function
End If

EnumWindows_CallBack = 1
End Function
'---------------------------------------------------------------



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000