Tcl Windows API usage examples
The examples in this section are broken out by area. Note that many of these will require administrative privileges to run. For clarity, the examples do minimal validation and error checking.
The examples may be run by passing to a Tcl interpreter. For example,
tclsh checkservicepack.example 3will print whether service pack 3 is installed.
The examples are broken up into the following categories: System information, File monitoring, Window management, Simulating user input, Playing sounds, Disk configuration, Network shares, Processes and threads, Windows services, Users and groups, Access control, Clipboard access, Network configuration, Event log and Performance monitoring.
Print OS version and configuration
Verify if Terminal Services are present
Verify a service pack is installed
Print the NETBIOS name of the computer
Monitor changes in a directory
Minimize all windows for a given application
Hide all windows for a given application
Show all windows for a given application
Move a window to the top left corner of the screen
Remove the title bar from a window
Bring a specified window to the foreground
Keep a window on top of all other windows
Change the caption of a window
Send text string to a specified window
Send menu shortcut keys to a specified window
Open the system menu of the specified window with the mouse
Start a program when a hotkey is pressed
Example: Draw a square in MS Paint using the mouse
Generate a continuous tone on the system speaker
Play a system sound continuously for 10 seconds
List all the drives on the system
List all remote drives on the system
List all fixed drives that have less than 10% free space
Modify the volume label for a drive
Check if the given drive supports Unicode file names
Check if the given drive has sufficient free space
Export a file share that can be connected to from remote clients
Map a drive to a file share exported from a server
List all network shares exported on the system
List all network shares to which the system is connected
Show information related to a mapped drive
Ask all invocations of a given program to gracefully exit
Forcibly terminate all invocations of a given program
Show the user account under which each process is running
Show the DLL's loaded in a process
Show all Windows services that are currently running
Show all Windows services that start automatically at boot time
Stop and restart a Windows service
Change a service configuration to start under a specific user account
Show the services that depend on the specified service
Show the services that the specified service depends on
List the group membership for a user
Show properties of a user account
Remove a user from a local group
Protect a file from access by a specific user
Unprotect a file, allowing access by all users
Show the access control entries on the specified file
Copy contents of the clipboard to standard output
Copy standard input to the clipboard
Transform the data in the clipboard
Get HTML format data from the clipboard
Map an IP address to a physical address
Dump event log to standard output
Show virtual memory statistics usage
Copyright © 2003, Ashok P. Nadkarni