PaulZ Posted September 2, 2004 Posted September 2, 2004 I one instance of my program running. When i start a second instance, I want to pass the commandline from the second instance to the first. How do I do that? Thanks in advance, Paul Quote
*Experts* Nerseus Posted September 2, 2004 *Experts* Posted September 2, 2004 What did you have in mind to pass? If you're just looking to display a message "You already have this app open, fool! - Mr. T", you can show the message from the second instance then have the 2nd instance show the 1st (bringing it to front) and then close down the 2nd instance. -ner PS Sorry about the Mr. T reference, I love putting Mr. T comments in a MessageBox. :) Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
PaulZ Posted September 2, 2004 Author Posted September 2, 2004 This is what has to happen: First instance of program: 1. program starts with a clientnr in the commandline 2. user has to log in 3. user gets a screen with information about this client Second: 1. second program starts with a clientnr in the commandline 2. commandline has to be passed to the first so that the user does not have to log in again 3. first program shows new clientinformation 4. second program closes BTW My program is called from another application. Quote
*Experts* Nerseus Posted September 3, 2004 *Experts* Posted September 3, 2004 Don't you expect the first program to already be logged in? And you want the second program to have the first log in as a different client? I'm trying to see what the bigger picture is (what your app is doing or providing) to see if there's an easier way to get what you want... I would guess there's a way to get the process of the first running program and maybe there's a way, via reflection, to call some code in there. If that's not available (never tried it) you could probably do it through standard Windows messages (SendMessage via PInvoke and have the first instance trapping a WndProc to receive the "raw" windows messages). -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Administrators PlausiblyDamp Posted September 3, 2004 Administrators Posted September 3, 2004 Do these processes need to be seperate applications? Or could they not all be part of the same application. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PaulZ Posted September 4, 2004 Author Posted September 4, 2004 It IS the same application, but it is started twice (or more times) by another program that does not know that my program is allready running. So, to prevent the user to log in every time my program starts, I want to use the first program that is started and where the user has logged in. I will certainly get complaints from the users when they know they have allready logged in (and that is correct, but only for the first instance of the program) and do not want to do that every time. See my problem? Am i clear now or do you need more info? Quote
Administrators PlausiblyDamp Posted September 4, 2004 Administrators Posted September 4, 2004 Could the other program not prompt for the login details and pass them to the other application? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Nerseus Posted September 4, 2004 *Experts* Posted September 4, 2004 When someone opens the 2nd instance, are they are just opening your app generically, or are they passing the 2nd instance some params? Example 1 - passing something to 2nd instance: I open UltraEdit (a text editor) with a readme.txt file. I then go to explorer and find another text file and double click to open. I'm guessing at this part: UltraEdit opens a 2nd instance, sees that there is already one open and communicates to the 1st instance that it needs to open File X. Example 2 - nothing to pass to 2nd instance: User opens your application which makes them log in. You have their credentials stored somehow - we assume this is all working. User opens another instance of your application, or another app that needs to use your first app somehow. If there's truly nothing to pass to the 1st instance, why not just bring the first instance to the front (it's already logged in and has things "cached") and then close the newly opened 2nd instance. The user would not even know that you did this - to them, the app they wanted came up. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
PaulZ Posted September 6, 2004 Author Posted September 6, 2004 Example 2 is now working. But it is not what I want. I will explain it in detail: 1. My program is started from another program and the user logges in. 2. My program reads the commandline (startingparams). In this commandline it will find a clientnumber (by example 1000). 3. My program opens a window with details of client 1000 4. My program is started again from the other program, but now with client 2000 in the commandline. 5. The second instance of my program has to terminate because the user is logged in at instance one and instance one has to receive clientnr 2000. 6. First instance closes client 1000 and shows client 2000. That's it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.