If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Problem with the exe i create

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-04-04, 13:01
Swaroopa Swaroopa is offline
Registered User
 
Join Date: Dec 2003
Location: Mumbai, India
Posts: 7
Red face Problem with the exe i create

Hi. Actually i am almost done with my VB project, still have some problems. When i create an exe file, i am able to open any number of instances of my application. But i want only one instance.

So is there any code which will open the existing one instead of opening a new one. Some code which will disable more than 1 instance of the application. Please help me.

Thank you.
Reply With Quote
  #2 (permalink)  
Old 04-04-04, 18:55
SCIROCCO SCIROCCO is offline
Registered User
 
Join Date: Mar 2004
Location: www.scirocco.ca
Posts: 346
Re: Problem with the exe i create

Use App.PrevInstance to see if a previous instance is already running.

Private Sub Form_Load()
' See if there is already and instance.
If App.PrevInstance Then
' Activate the previous instance
AppActivate App.Title

' Send a key (here SHIFT-key) to set the
' form from the previous instance to the
' top of the screen.
SendKeys "+", True

' Terminate the new instance
Unload Me
End If
End Sub
__________________
http://www.scirocco.ca/images/banner...occobanner.gif

Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

Or try our Ask An Expert service to answer any of your questions!
Reply With Quote
  #3 (permalink)  
Old 04-05-04, 06:20
Swaroopa Swaroopa is offline
Registered User
 
Join Date: Dec 2003
Location: Mumbai, India
Posts: 7
Re: Problem with the exe i create

Thank you. It did work in the sense it doesnt open a second instance, but it shows an error saying

Runtime error 364
Object was unloaded

What should i do now? If u can tell me, plz do. For your information i wrote it in the splash scrren. I hope thats ok. Anyways Thanx a lot.
Reply With Quote
  #4 (permalink)  
Old 04-05-04, 09:53
SCIROCCO SCIROCCO is offline
Registered User
 
Join Date: Mar 2004
Location: www.scirocco.ca
Posts: 346
Re: Problem with the exe i create

Try putting the code in the activate event instead of the load event. Does that help?
__________________
http://www.scirocco.ca/images/banner...occobanner.gif

Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

Or try our Ask An Expert service to answer any of your questions!
Reply With Quote
  #5 (permalink)  
Old 04-08-04, 12:22
Swaroopa Swaroopa is offline
Registered User
 
Join Date: Dec 2003
Location: Mumbai, India
Posts: 7
Thumbs up Re: Problem with the exe i create

Thanx a lot. Writing it in the activate event worked fine without errors. Really.... thank you very much.
-Swaroopa.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On