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.
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
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@...
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@...
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/
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/
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/
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.
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.
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&
----------------------------------------------------------------------------
----
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.
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
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/
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/
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
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
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
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
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/
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
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
______________________________________________________________________
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
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.
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.
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.