Go Back  Xtreme Visual Basic Talk > General Discussion > Tech Discussions > Enlisting Processes which are running at your PC


Reply
 
Thread Tools Display Modes
  #1  
Old 11-28-2007, 12:24 AM
Q_tarantino's Avatar
Q_tarantino Q_tarantino is offline
Junior Contributor
 
Join Date: Oct 2007
Posts: 287
Default Enlisting Processes which are running at your PC


Enlisting Processes which are running at your PC

Just attaching vb project
anyone is free to delete it or look into.
Unpack and run

One component I used is MS FlexGrid. Add it.

Also, processes are listed alphabetically, to sort them that way I used collection and optional parameter [Before]
Attached Files
File Type: zip ENLIST PROCESSES.zip (4.3 KB, 16 views)
Reply With Quote
  #2  
Old 11-28-2007, 07:17 AM
lebb's Avatar
lebb lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

A couple suggestions for you....

If you would use consistent indentation and vertical spacing, your code would be a great deal easier to read and maintain (for that reason, I'll keep this review brief). Also, you should never use End to close your application (there are many, many discussions of that here, so I won't rehash the details); instead, unload all objects and forms.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #3  
Old 11-28-2007, 07:29 AM
Q_tarantino's Avatar
Q_tarantino Q_tarantino is offline
Junior Contributor
 
Join Date: Oct 2007
Posts: 287
Default

As I said, Lebb, anyone can look into the project, or delete it. Or just not download it.
The point of it --> not how to use or not to use END statements, identation, comments and Hungarian notation - the point is use of some API's in some circumstances --> as the thread named.
Reply With Quote
  #4  
Old 11-28-2007, 07:33 AM
lebb's Avatar
lebb lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

I understand the purpose, but because of the way the code is structured, it makes it unlikely to be useful for any instructional purpose, regardless of the focus. And poor programming practice in one area makes all of the rest seem suspect. So I was just offering some advice on how to make it more useful.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #5  
Old 11-28-2007, 03:16 PM
Q_tarantino's Avatar
Q_tarantino Q_tarantino is offline
Junior Contributor
 
Join Date: Oct 2007
Posts: 287
Default

I apologise deeply, Lebb
The project has a little amount of code and writing extensive routines for exiting App - is just overloading it.
It has the essence - detecting and enlisting current processes - those, which are otherwise displayed in a Task Manager.
And anyone, who would like to see APIs in action, I am sure knows a lot about proper way of exiting the Application, as well as poorness and richness of programming practice, and rules of commenting and naming variables.
So it is just about proper choice of API for particular task.

You wouldn't take GPS device when going to take MVA Driving Test for driving license, would you .
You'll take it later for other trips and other purposes.
Reply With Quote
  #6  
Old 11-28-2007, 04:29 PM
mkaras's Avatar
mkaras mkaras is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Mar 2004
Location: Beaverton, OR
Posts: 1,874
Default

It is common practice to put your best image forward. The reason this is done is because the public impression is the one you get remembered by. Inside your house and back yard could be beautiful and immaculate but leave spilled garbage out at the end of your driveway and it is certain what the impression is!!

Everything one does should be done to the best of ability toward perfection. Following this path leads to pride in what we do and eliminates any need to carry on silly discussion to try to justify something we did not do that way. One negative image swallows up the effect of a hundred positive ones. Justifications also have the trait of sounding phony and often end up causing more harm to positive image.

Michael Karas
Reply With Quote
  #7  
Old 11-28-2007, 05:47 PM
Roger_Wgnr's Avatar
Roger_Wgnr Roger_Wgnr is offline
CodeASaurus Hex

Forum Leader
* Expert *
 
Join Date: Jul 2006
Location: San Antonio TX
Posts: 2,427
Default

Just to add my 2 cents.

When I was new to VB6 I downloaded a number of example projects to learn from and many were examples of API functions. It is extreemly important when you provide sample projects to take the time to fully comment the code, Use proper declartion, and properly close the application. While you may think only individuals that are versed in such things will be looking at your code I can tell you that there will be those that do not know the proper methods will also be looking at the code.

Just look at some of the posts on this site there are many examples of individuals that are very new to programming that try to use advanced methods because they think it would be cool but still don't know some very basic operations such as proper declaration of variables, Variable scope, even how to add and use basic controls. This makes it important that when we provide example projects that we take extra time to ensure the code is easy to follow, Easy to read and understand what is going on, and finally follows good programming practices and demonstrates the proper methods of doing things.

Lastly I think it worth mentioning that while many people have and will use advanced methods such as API calls. Many of them (such as myself) may not have any true programming instruction and as such may be doing things incorrectly. We have seen it many times in threads that people use END to close there applications and we inform them of why this is not a good practice. Then if the sample programs available use END it may very well indicate to someone who is already in the habbit of using it to continue to use it, rather that causing him to question why don't they just END the program instead of writing all this extra code. When they wonder about something like that they will ask the question and learn the reasons for it.

Just a little food for thought.
__________________
Code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ~Martin Golding
The user is a peripheral that types when you issue a read request. ~Peter Williams
MSDN Visual Basic .NET General FAQ
Reply With Quote
  #8  
Old 11-28-2007, 06:02 PM
Q_tarantino's Avatar
Q_tarantino Q_tarantino is offline
Junior Contributor
 
Join Date: Oct 2007
Posts: 287
Default

Thank you guys, I understand u
Reply With Quote
  #9  
Old 11-29-2007, 08:07 AM
lebb's Avatar
lebb lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Another thing to consider (slightly off-topic), which may or may not be relevant to your situation, is that if you're looking at a career in software development, potential employers are likely to go looking for code you've published, and this site is a prime place to look (I know I've evaluated candidates before based on their code here and elsewhere). So if that's a possibility for you, it's to your advantage to demonstrate with each post that you care about your work and show attention to detail.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #10  
Old 11-29-2007, 09:03 AM
Q_tarantino's Avatar
Q_tarantino Q_tarantino is offline
Junior Contributor
 
Join Date: Oct 2007
Posts: 287
Default

Lebb, I am not looking of a career in software development - I already have a career of 12 + years experience in IT (mostly VB family development plus ASP,Javascript and SQL Server.)

So from the point of view of a guy looking for examples in code - I know that people look for ESSENCE in code - if the essence is presented in couple of lines - that's ok even if there is no comments.

Imagine this scenario:

You are the guy responsible for coding in company XYZ. Your boss wants you ti fix some code. Let's say SHELL (some file) is not working the way it is supposed to be working. You register in a vb web site, ask your question. You expect the answer - the essence - how to make SHELL to execute a file -> while application waits until SHELL finishes its job.

Instead of solution - you are given sidekick answers about how to use END statement or not to use it --> how and where to use
comments ---> and so on.

First of all --> you probably will look somwhere else.
Second, ---> a software company has already a policy of NAMING CONVENTIONS in regards of variables and other objects as well commenting procedures , code and so on.--> that is for sure, and you already know that. And you are not looking sidekickk suggestion - you are looking exatctly the answer for your question. Comments you can add later if even you add them.
In case any line of code is not clear - but you like the answer and the code works well for you --> you always can come back, knowing, that you will again get exact ansdwer whatever you ask.

That was my point.

Last edited by Q_tarantino; 11-29-2007 at 09:12 AM.
Reply With Quote
  #11  
Old 11-29-2007, 02:44 PM
HardCode's Avatar
HardCode HardCode is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Feb 2004
Location: New Jersey
Posts: 3,338
Default

Bad code is bad code. There's really no two ways about it. Good code is not only code that works, but is also code that another programmer can look at and, with minimal effort, quickly and easily understand how it works.
__________________
DON'T CLICK HERE

Useful forum tags: [VB][/VB], [CODE][/CODE], [HTML][/HTML]
Reply With Quote
  #12  
Old 11-29-2007, 06:31 PM
Q_tarantino's Avatar
Q_tarantino Q_tarantino is offline
Junior Contributor
 
Join Date: Oct 2007
Posts: 287
Default

Bad code is that code which you fix.
Reply With Quote
  #13  
Old 11-29-2007, 11:15 PM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

The other major problem with the code is that it doesn't work. When maximising the Form the application freezes (Win ME)

From a user perspective, not being able to adjust the width of the columns makes the results fairly useless - in the 2nd column where the full path is displayed I never see the actual name, only the first 'n' characters of the Path. The constant re-displaying of the entire contents of the form is also quite off putting, there's no way of stopping the automatic refresh or adjusting the refresh rate. I'm glad I'm not epileptic. Also, it only displays a maximum of 35 processes, I have quite a few more than that running, there's no way to scroll the display.

From a coding perspective, I totally agree with the other comments already made and would add that, to be instructional (eg to be useful to a Programmer wanting to get to grips with API and Collections) comments in the code are, to my mind, a must.

Remember our Mission Stetement
Quote:
This Forum exists to promote the personal and professional development of its members. We believe that this development stands on three legs. (a) Programming Skill, (b) Social Skills and (c) Ethical Behaviour. As such, we promote programming skills by exchanging code, knowledge, and ideas. We promote social skills by posting in a polite and tolerant manner. We keep our sense of humour and avoid flames. We promote ethics by encouraging honest interaction and by refusing to engage in or support software piracy, malicious code or other illegal activity.
and you can see how and why our Posting Guidelines are as they are.

Code published for review, and possible addition to the Code Library must adhere to the spirit of our Mission Statement. As well as performing a useful function it must also be of considerable educational value, since we are not a 'Code Handout' site. Remember, the reviewing audience has, potentially, a few thousand combined years of programming experience (making your 12 and my 35 pale into insignificance. ) so be prepared for the type of constructive criticism, and honest interaction, that publication will attract. This, of course, equally applies to code snippets that may be given in answer to specific questions asked in the Forums as there are always many solutions to a given problem, and whatever we may think, some will be better than others. (All IMHO, of course)
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data

Last edited by DougT; 11-29-2007 at 11:48 PM. Reason: Punctuation
Reply With Quote
  #14  
Old 11-30-2007, 08:51 AM
lebb's Avatar
lebb lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

A couple responses, and I do hope I'm not beating a dead horse, as the advice is intended as constructive, not just criticism for criticism's sake.

Quote:
Originally Posted by Q_tarantino
You are the guy responsible for coding in company XYZ. Your boss wants you ti fix some code. Let's say SHELL (some file) is not working the way it is supposed to be working. You register in a vb web site, ask your question. You expect the answer - the essence - how to make SHELL to execute a file -> while application waits until SHELL finishes its job.

Instead of solution - you are given sidekick answers about how to use END statement or not to use it --> how and where to use
comments ---> and so on.
And you'll note that I would never give that kind of answer as an initial response to someone who posted here with a question. If I made the suggestions at all, it would be as an aside along with an answer (or at least a request for further clarification, depending on the question).

However, when you post code in this forum that isn't in response to a question, I assume you're doing so for one of two purposes: (1) to request a code review from your peers, and/or (2) to share it as an example for others it may help. In the first case, this sort of advice is what one would expect from a code review, and in the second, we work very hard on this site to keep our example code to a high standard so that we don't introduce less experienced programmers to poor practices.

Quote:
Originally Posted by Q_tarantino
In case any line of code is not clear - but you like the answer and the code works well for you --> you always can come back, knowing, that you will again get exact ansdwer whatever you ask.
In case a line of code isn't clear, most good developers won't bother going far enough to see if the code works; they'll have wasted their time reading an unclear post and will move on to another that appears to have more potential. And most poor developers won't ever ask because they don't particularly care. (Note that I'm not using "good" and "poor" here to relate to experience level, but rather to overall discipline, aptitude, and professionalism.)
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #15  
Old 11-30-2007, 03:19 PM
loquin's Avatar
loquin loquin is offline
Google Hound

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,386
Default

The cost of maintaining code often far exceeds the cost of developing it in the first place.

With that in mind, it only makes sense to make that code as easy to maintain as is possible, when it is written... Maintainable code is modular in nature, it is clear and easy to understand, with lots of white space and adequate comments. It uses a consistent and logical naming convention.

ref the Standards & Practices Tutorial
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Reply With Quote
  #16  
Old 12-01-2007, 03:20 AM
Q_tarantino's Avatar
Q_tarantino Q_tarantino is offline
Junior Contributor
 
Join Date: Oct 2007
Posts: 287
Default

You, guys, are simply taking the bureaucratic approach over constructive one.
And one can clearly see it. There were no one comment on the essence of the code - that is APIs themself . Are you programmers or Ethics specialists?

Naturally, that is the approach of big corporations towards the little guy - the end user.

Well , anyone can choose whatever he wants to.
Reply With Quote
  #17  
Old 12-01-2007, 04:16 AM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

Funny that, I thought I made some outstanding constructive comments about the code - like it didn't work when the window was maximised, and some comments about the user interface. (ie it would be nice to be able to have control over the refresh rate, and to scroll the output so all the processes can be displayed.) Now is that bureaucratic, or does that support the end user?

Why would we need to comment about the APIs? - they're published and there's plenty of examples around showing how those particular ones can be used to obtain all sorts of interesting information.

Why do you think that Programming and Ethics are mutually exclusive?
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data

Last edited by DougT; 12-01-2007 at 04:22 AM.
Reply With Quote
  #18  
Old 12-01-2007, 06:18 AM
Q_tarantino's Avatar
Q_tarantino Q_tarantino is offline
Junior Contributor
 
Join Date: Oct 2007
Posts: 287
Default

Doug,

1.
Quote:
Funny that, I thought I made some outstanding constructive comments about the code - like it didn't work when the window was maximised
it would've been outstaning, if not vb form had Maxbutton/Minbutton properties - and one can change it as how he sees fit - that is why I posted source code in the form of project, and not executable.

But if you still want the form to be maximizable I attach the same project with one small fix.


2.
Quote:
, and some comments about the user interface. (ie it would be nice to be able to have control over the refresh rate,
If you please type in the text box whatever value in milliseconds you want the refresh rate to be (any integer from 100 to,say, 20000) - and press Enter - the refresh rate changes accordingly - that feature have been there from very first post



3.
Quote:
and to scroll the output so all the processes can be displayed.)
Now is that bureaucratic, or does that support the end user?
constructive comment would be:
any MSFlexGrid has a scroll bar. Vertical. Anyone can use it
Attached Files
File Type: zip ENLIST PROCESSES.zip (4.2 KB, 5 views)

Last edited by Q_tarantino; 12-01-2007 at 06:32 AM.
Reply With Quote
  #19  
Old 12-01-2007, 06:52 AM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

I finally looked at the code because, for the life of me, when I read that it didnt work when the form was maximized I just had to see why..
Reply With Quote
  #20  
Old 12-01-2007, 11:17 PM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

Q_T: In case you haven't found it, the problem lies in the ListProcesses Subroutine, the error trapping routine assumes that the only error that can happen is "5" (and there's an Exit Sub missing) Maximising the Form causes an error 384 ("A Form can't be moved or sized while minimised or maximised") when Me.Width = msfg1.Width + 100 is executed in Subroutine IntGrid. This error is not handled properly ("Resume Next") thus ......

Of course, on my display, because I can't maximise the form, I can't see the label, textbox or command button !!(actually, when maximised, I still can't see them since you've also made some assumptions about my screen resolution)

Remind me, what does 'assume' make?

EDIT:
Quote:
that is why I posted source code in the form of project, and not executable
BTW, please review our Posting Guidelines you'll see that executables are not allowed in attachments.
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data

Last edited by DougT; 12-01-2007 at 11:47 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->