NAME

Win32Util - a collection of Win32 related functions

SYNOPSIS

use Win32Util;

DESCRIPTION

This is a collection of Win32 related functions. There are no strict prerequirements for this module, however, full functionality can only be achieved if some CPAN modules (Win32::Registry, Win32::API, Win32::DDE, Win32::Shortcut ...) are available. By default, most of these modules are already bundled with the popular ActivePerl package.

PROGRAM EXECUTION FUNCTIONS

start_any_viewer($file)

Based on extension of the given $file, start the appropriate viewer.

start_html_viewer($file)

Start a html viewer with the given file. This is mostly a WWW browser.

start_ps_viewer($file)

Start a postscript viewer with the given file.

start_ps_print($file)

Print a postscript file via a postscript viewer.

start_mail_composer($mailaddr)

Start a mail composer with $mailaddr as the recipient.

start_cmd($cmd, @args...)

Start an external program named $cmd. $cmd should be the full path to the executable. @args are passed to the program. The program is spawned, that is, executed in the background.

normalize_env

Return a hash reference with all environment variable names changed to uppercase.

start_dde($app, $topic, $arg)

Start a program via DDE. (What is $app and $topic?)

EXTENSION AND MIME FUNCTIONS

get_reg_cmd($filetype[, $opentype])

Get a command from registry for $filetype. The "open" type is returned, except stated otherwise.

get_class_by_ext($ext)

Return the class name for the given extension.

install_extension(%args)

Install a new extension (class) to the registry. The function may take the following key-value parameters:

-extension

Required. The extension to be installed. The extension should start with a dot. This can also be an array reference to a number of extensions.

-name

Required. The class name of the new extension. May be something like Excel.Application.

-icon

The (full) path to a default icon file (format should be .ico).

-open

The default open command (used if the file is double-clicked in the explorer).

-print

The default print command.

-desc

An optional description.

-mime

The mime type of the extension (something like text/plain).

write_uninstall_information(%args)

-appname => $appname

The application name. This is required.

-uninstallstring => $string

The command for the uninstall process (???). is required.

-regowner => $owner

Current owner of the registry entry (???). If not specified, the current user is used.

-version => $version

Version number of application. This should consist of a major and minor number. The full application name will be created of $appname and $version.

-installdate => "YYYY-MM-DD"

The date of installation. If not specified, the current date is used.

-installlocation => $string
-installsource => $string
-modifypath => $string
-publisher => $string
-urlinfoabout => $string
-urlupdateinfo => $string

USER FUNCTIONS

get_user_name

Get current windows user.

is_administrator

Guess if current user has admin rights.

get_user_folder($foldertype, $public)

Get the folder path for the current user, or, if $public is set to a true value, for the whole system. If $foldertype is not given, the "Personal" subfolder is returned.

get_program_folder

Get the folder path for the program files (usually C:\Program Files).

get_home_dir()

Get home directory (from domain server) or the $HOME variable.

WWW AND NET FUNCTIONS

lwp_auto_proxy($lwp_user_agent)

Set the proxy for a LWP::UserAgent object (similar to the unix-centric env_proxy method). Uses the Internet Explorer proxy setting.

MAIL FUNCTIONS

send_mail(%args)

Send an email through MAPI or other means. Some of the following arguments are recognized:

-sender

Required. The sender who is sending the mail.

-passwd

The MAPI password (?)

-recipient

The recipient of the mail.

-subject

The subject of the message.

-body

The body text of the message.

This is from Win32 FAQ. Not tested, because MAPI is not installed on my system.

EXPLORER FUNCTIONS

create_shortcut(%args)

Create a shortcut (a desktop link). The following arguments are recognized:

-path

Path to program (required).

-args

Additional arguments for the program.

-icon

Path to the .ico icon file.

-name

Title of the program (required).

-file

Specify where to save the .lnk file. If -file is not given, the file will be stored on the current user desktop. The filename will consist of the -name parameter and the .lnk extension.

-desc

Description for the file.

-wd

Working directory of this file.

-public

If true, create a shortcut visible for all users.

-autostart

Create shortlink in Autostart folder.

create_internet_shortcut(%args)

Create an internet shortcut. The following arguments are recognized:

-url

URL for the shortcur (required).

-icon

Path to the .ico icon file.

-name

Title of the program (required).

Specify where to save the .lnk file. If -file is not given, the file will be stored on the current user desktop. The filename will consist of the -url parameter and the .lnk extension.

-desc

Description for the file (not used yet).

add_recent_doc($doc)

Add the specified document to the list of recent documents.

create_program_group(%args)

Create a program group. Following arguments are recognized:

-parent

Required. The name of the new program group.

-files

Required. The files to be included into the new program group. The argument may be either a file name or an array with a number of file names. The file names can be either a string or a hash like {-path => 'path', -name => 'name'}. In the latter case, this hash will be used as an argument for create_shortcut.

-public

If true, create a program group in the public section, not in the user section of the start menu.

FILE SYSTEM FUNCTIONS

get_cdrom_drives

Return a list of CDROM drives on the system.

get_drives([$drive_filter])

Return a list of drives on the system. The optional parameter $drive_filter should be a comma-separated string with the possible values cdrom, fixed (for fixed drives like harddisks), ramdisk, remote (for net drives), and removable (for removable drives like ZIP or floppy disk drives).

path2unc($path)

Expand a normal absolute path to a UNC path.

GUI FUNCTIONS

client_window_region($tk_window)

Return maximum region for a window (without borders, title bar, taskbar area). Format is ($x, $y, $width, $height).

screen_region($tk_window)

Return maximum screen size without taskbar area.

maximize($tk_window)

Maximize the window. If Win32::API is installed, then the taskbar will not be obscured.

get_sys_color($what)

Return ($r,$g,$b) values from 0 to 255 for the requested system color. $what is any of: scrollbar, background, activecaption, inactivecaption, menu, window, windowframe, menutext, windowtext, captiontext, activeborder, inactiveborder, appworkspace, highlight, highlighttext, btnface, btnshadow, graytext, btntext, inactivecaptiontext, btnhighlight, 3ddkshadow, 3dlight, infotext, infobk.

close_dosbox()

Closes the dosbox. Handy if starting a GUI program with the standard perl.exe and not wperl.exe.

disable_dosbox_close_button()

As the function name says :-). Derived from a posting from Jack D.

NOT YET TESTED!

keep_on_top($tk_window [, $flag])

Keep the window $tk_window on top. If Win32::API is not available, attributes(-topmost) is used if Tk 804.027 is available, otherwise a crude hack with a <Visibility> binding is used instead. If the optional variable $flag is false, "keep on top" is disabled.

MISC FUNCTIONS

sort_cmp_hack($a,$b)

"use locale" does not work on Windows. This is a hack to be used in sort for german umlauts.

SEE ALSO

perlwin32, Win32::API, Win32::OLE, Win32::Registry, Win32::Process, Win32::DDE, Win32::Shortcut, Tk, LWP::UserAgent.

AUTHOR

Slaven Rezic <slaven@rezic.de>

COPYRIGHT

Copyright (c) 1999, 2000, 2001, 2002 Slaven Rezic. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.