Examples

Tcl Windows API usage examples

DESCRIPTION

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 3

will 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.

System information

Print OS version and configuration

Verify if Terminal Services are present

Verify a service pack is installed

Print the NETBIOS name of the computer

File monitoring

Monitor changes in a directory

Window management

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

Simulating user input

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

Playing sounds

Generate a continuous tone on the system speaker

Play a system sound

Play a system sound continuously for 10 seconds

Play a WAV sound file

Disk configuration

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

Network shares

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

Processes and threads

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

Windows services

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

Install a service

Remove a service

Users and groups

List the users on a system

List the group membership for a user

List the users in a group

Show properties of a user account

Create a new user account

Delete a user account

Add a user to a local group

Remove a user from a local group

Add a local group account

Delete a local group account

Access control

Protect a file from access by a specific user

Show the access control entries on the specified file

Clipboard access

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

Network configuration

Show network interfaces

Map an IP address to a physical address

Event log

Dump event log to standard output

Performance monitoring

Chart CPU utilization

Show virtual memory statistics usage

Show network statistics

COPYRIGHT

Copyright © 2003, Ashok P. Nadkarni

Tcl Windows API 2.2.3 Privacy policy