|
-
Aug 8th, 2003, 08:37 PM
#1
Enumerate class instances system wide...
Is such a thing possible? For example, I have an app that has a form, MyForm. Is it possible to find all instances of MyForm that exist at the time I look for them?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Aug 9th, 2003, 04:02 AM
#2
if you want the forms in your App, you can do the following...
otherwise , i've put a system wide enumeration below it, hope it gets you on the way 
VB Code:
[COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Button1_Click([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] System.Object, [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.EventArgs) [COLOR=BLUE]Handles[/COLOR] Button1.Click
[COLOR=BLUE]Dim[/COLOR] objType() [COLOR=BLUE]As[/COLOR] Type = Reflection.Assembly.GetExecutingAssembly.GetTypes()
[COLOR=BLUE]Dim[/COLOR] x [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]Integer
[/COLOR] [COLOR=BLUE]For[/COLOR] x = LBound(objType) [COLOR=BLUE]To[/COLOR] UBound(objType)
MessageBox.Show("forms in your app are: " & objType(x).Name)
[COLOR=BLUE]Next
[/COLOR] [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
but if you want system wide , maybe you need to enumerate the processes , like this.....
VB Code:
[COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Button2_Click([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] System.Object, [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.EventArgs) [COLOR=BLUE]Handles[/COLOR] Button2.Click
[COLOR=BLUE]Dim[/COLOR] procs() [COLOR=BLUE]As[/COLOR] Process = Process.GetProcesses()
[COLOR=BLUE]Dim[/COLOR] x [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]Integer
[/COLOR] [COLOR=BLUE]For[/COLOR] x = LBound(procs) [COLOR=BLUE]To[/COLOR] UBound(procs)
ListBox1.Items.Add(procs(x).ProcessName & " : " & procs(x).MainWindowHandle.ToInt32)
[COLOR=BLUE]Next
[/COLOR] [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 9th, 2003, 06:10 AM
#3
Frenzied Member
That enumerates all types in an assembly. But will it enumerate the instances of a type that may be created and destroyed at runtime?
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Aug 9th, 2003, 08:28 AM
#4
not tried that yet lol, but something you may recognize lunatic...
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
.....
Heading for the great escape
heading for the rave
heading for the permanent, holiday.
very good album is brave, although seasons end is my favourite post - fish marillion album. seen em around 15 times or so since the mid 1980's in concert
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 9th, 2003, 09:16 AM
#5
Frenzied Member
Originally posted by dynamic_sysop
very good album is brave, although seasons end is my favourite post - fish marillion album. seen em around 15 times or so since the mid 1980's in concert
Yes, Seasons End is my favorite too.
I love them though never had the chance to see them in concert (due to living in Iran), however I am moving to Canada soon and hope they care to come to Vancouver and play there. Recently I had a chance to see a show of them playing at MCM cafe in Paris. They played "The Great Escape" just great. As a Marrillion fan you may be an Eloy fan too? Right?
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Aug 9th, 2003, 10:10 AM
#6
i have listened to eloy, but not really got in to them. my cousin in holland has all their stuff though ( he's mad on prog rock ), he used to help running the dutch marillion fanclub. good to see someone else with great tastes in music on here
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 9th, 2003, 10:20 AM
#7
Frenzied Member
Originally posted by dynamic_sysop
good to see someone else with great tastes in music on here
Especially if from Axis of Evil
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Aug 9th, 2003, 10:49 AM
#8
Hey, stop hijacking my thread, or I'll give out some serious ass punching!
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Aug 11th, 2003, 09:54 AM
#9
Originally posted by crptcblade
Hey, stop hijacking my thread, or I'll give out some serious ass punching!
Ass punching? I thought you were supposed to kick the ass! 
If you mean for a specific project then you could use some form of factory design to control the different instances. You'd think that the GC has to track instances and we can sort of access it that we could get the info but I couldn't find away to get instance information.
Last edited by Edneeis; Aug 11th, 2003 at 12:03 PM.
-
Jul 16th, 2004, 09:08 PM
#10
Super dooper bump!
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jul 17th, 2004, 10:33 AM
#11
yay gay
Hmm I dont know if it registers classes System or App-wide but you could try designing classes that would have a static class that everytime you'd instanciate a class you'd add a reference to that static method
hmm hope you understood :S
\m/  \m/
-
Jul 17th, 2004, 12:07 PM
#12
I understand, but I was under the understanding that it only be in the scope of the application. I'll have to test some things out then, thanks.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|