Single Instances share Data space?
-
I'm writing a .NET version of Panorama (it changes your backgrounds in win98 but has Issues on XP/Vista -- i dont maintain it... i just like it) I have to handle It as a single instance application because i call the "ChangeDesktopBackground" command in user32.dll alot -- anywhere from 6 SECONDS to 4 HOURS... and i dont want a user going crazy because the desktop just changed 3935974958607367 times... it takes some doing too... I was considering DDE, but its dead. OLE automation is near imposible without killing the filesize (its 200kb right now -- and only takes up 400kb in memory.) I would like to have a command line param, say -a, that adds files to a listbox. Heres how i have it set up: FormMain FormMain.Desks(ListView) FormMain.AddSingle(Button) FormMain.AddDirectory(button) FormMain.RemoveItem(button) formMain.clearAllItems(button) FormMain.Timeout(spinCtl) FormMain.TimoutTimer(Timer) FormMain...... I want to be able to have it set up so that when the user calls something like "PanoNet.exe -a C:\Epic Files\Some File.jpg" "C:\Mpre FIles\Some Other FIle.BMP" the new instance tells the old instance to add the two files to the top of the end of FormMain.Desks.Items Can this be done? "Pinky, are you thinking what i'm thinking?" "I Dunno brain, who really came up with the idea for cheeze sticks?" "... apparently not ..."
-
I'm writing a .NET version of Panorama (it changes your backgrounds in win98 but has Issues on XP/Vista -- i dont maintain it... i just like it) I have to handle It as a single instance application because i call the "ChangeDesktopBackground" command in user32.dll alot -- anywhere from 6 SECONDS to 4 HOURS... and i dont want a user going crazy because the desktop just changed 3935974958607367 times... it takes some doing too... I was considering DDE, but its dead. OLE automation is near imposible without killing the filesize (its 200kb right now -- and only takes up 400kb in memory.) I would like to have a command line param, say -a, that adds files to a listbox. Heres how i have it set up: FormMain FormMain.Desks(ListView) FormMain.AddSingle(Button) FormMain.AddDirectory(button) FormMain.RemoveItem(button) formMain.clearAllItems(button) FormMain.Timeout(spinCtl) FormMain.TimoutTimer(Timer) FormMain...... I want to be able to have it set up so that when the user calls something like "PanoNet.exe -a C:\Epic Files\Some File.jpg" "C:\Mpre FIles\Some Other FIle.BMP" the new instance tells the old instance to add the two files to the top of the end of FormMain.Desks.Items Can this be done? "Pinky, are you thinking what i'm thinking?" "I Dunno brain, who really came up with the idea for cheeze sticks?" "... apparently not ..."
Yeah, it can be done. Just search the articles for "single instance" and you'll find a few that describe passing data back to the original instance of the app. You may want to check into .NET Remoting (older) or WCF (newer) if using the .NET Framework 3.0. Basically, your app is exposing a server that a new instance of the app connects to as a client.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007