Single-line code -vs- 7K version 
Author Message
 Single-line code -vs- 7K version

Got a question for the VB/MS experts here... someone recently asked how
to shut down Windows via code, and two answers were given: one by myself,
and one pointing to a MS Knowledge Base article.  My example was a single
line of code (Shell "rundll32.exe shell32.dll,SHExitWindowsEx 1") and the
MS example was a full 7K routine (which can be found at this URL:
http://www.*-*-*.com/ ).

My question is: Is there anything wrong with using the small example that
I gave, as opposed to using MS's "official" routine?  What problems can
I expect to run into by not bloating my software like MS seems to do?

This is NOT meant to be an anti-MS post, but I really want to know why
their 7K code can be reduced to one single line and still work?

Regards, Otser.



Sat, 09 Aug 2003 12:39:39 GMT  
 Single-line code -vs- 7K version
| This is NOT meant to be an anti-MS post, but I really want to know why
| their 7K code can be reduced to one single line and still work?

1) Your method has no error checking whatsoever
2) Your method doesn't take into account people using NT / 2000, where your
program has to get security privileges in order to restart the computer.
3) Your method doesn't include comments, procedure headers, etc.

Basically, yours is fine if you are always running it on a guarenteed 9x
system (95, 98 or ME) and you also know that there is no way that your method
will throw an error (for example if a running program cancels the shutdown
process) then you are OK. The MS example is more robust, will work on all
Win32 systems, and also lets you retrieve error information if an error did
occur.

steve



Sat, 09 Aug 2003 22:20:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VS.Net Version vs .Net Framework version

2. Data Type Usage: Single vs Currency vs Decimal

3. Dim multiple lines or single line

4. stored procedures vs. in-line SQL code

5. HELP - Manually Place Long Lines of Code over Several Lines in Code Window

6. Jer version vs. VB version

7. Single user versus network version #2

8. Single user versus network version

9. Vertical, single-row version of DataList control ?

10. Vertical, single-row version of DataList control ?

11. Vertical, single-row version of DataList control ?

12. How to test two versions of a DLL on a single server

 

 
Powered by phpBB® Forum Software