home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeJava and XSLTSearch this book

Chapter 22. Win32 Modules and Extensions

If you use Perl on a Win32 system, a number of extension modules are available to provide Windows-specific functionality. Extension modules consist of a regular module written in Perl and a library written in C or C++ that can implement native Windows calls. The core of available modules is bundled together as lib-win32 on CPAN, and with ActivePerl, Activestate's version of Perl for Win32. They provide such functionality as managing Windows processes, NT user administration, registry modification, and OLE automation.

The Win32 modules were originally written for Windows NT systems, so much of the functionality of the Win32 library is applicable only to Perl running on Windows NT. Many modules check to see which system they are on before installing. Many of the NT-specific modules such as NetAdmin and EventLog do not install at all on Windows 95. Modules such as Registry do their best to work on both systems, despite the differences in their registries.

This chapter covers most of the modules and extensions included in lib-win32 and distributed with ActivePerl. Additional Windows modules are available at CPAN.

The following modules are described in this chapter:

Win32::Clipboard
Provides Windows clipboard interaction

Win32::Console
Provides Windows console interaction

Win32::ChangeNotify
Creates and uses ChangeNotify objects

Win32::EventLog
Reads from and writes to the Windows NT event log

Win32::File
Manages file attributes (read-only, system, hidden, etc.)

Win32::FileSecurity
Manages ACLs in Perl

Win32::Internet
Provides extensions for Internet services

Win32::IPC
Waits for objects (processes, mutexes, semaphores)

Win32::Mutex
Creates and uses mutexes

Win32::NetAdmin
Administers users and groups

Win32::NetResource
Manages resources (servers, file shares, printers)

Win32::PerfLib
Accesses the Windows NT Performance Counter

Win32::Pipe
Creates a named pipe under Win32

Win32::Process
Starts and stops Win32 processes

Win32::Registry
Reads and manages the Win32 Registry

Win32::Semaphore
Creates and uses semaphores

Win32::Service
Manages Windows NT services

Win32::Shortcut
Provides shell link interface

In addition to this chapter, Chapter 23, "OLE Automation" covers the Win32::OLE modules, and Chapter 24, "ODBC Extension for Win32" covers the ODBC extension for Win32.

The reference material for the Clipboard, Console, Internet, and Shortcut modules was graciously provided by Aldo Capini, author and maintainer of many Win32 modules (http://dada.perl.it/).

22.1. Win32::Clipboard

The Win32::Clipboard module allows you to manipulate the Windows clipboard. You can use the clipboard as an object with the following syntax:

$clip = Win32::Clipboard( );

This functions as an implicit constructor. If you include a text string as an argument, that text will be placed on the clipboard. You can use the package-qualified method names instead of the object syntax, since the clipboard is a single entity:

$text = Win32::Clipboard::Get( );
Win32::Clipboard::Set("blah blah blah");
Win32::Clipboard::Empty( );

Alternatively, you can use the clipboard as an object with this syntax:

$Clip = Win32::Clipboard( );
$text = $Clip->Get( );
$Clip->Set("blah blah blah");
$Clip->Empty( );


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.