NAME
Win32::Exe::Manifest - MSWin Application and Assembly manifest handling
VERSION
This document describes version 0.15 of Win32::Exe::Manifest, released November 30, 2010.
SYNOPSIS
use Win32::Exe
my $exe = Win32:::Exe->new('somefilepath');
my $manifest = $exe->get_manifest if $exe->has_manifest;
# Get themed controls
$manifest->add_common_controls;
# Change name
$manifest->set_assembly_name('My.App.Name');
# Require Admin permissions
$manifest->set_execution_level('requireAdministrator');
# write it out
$exe->set_manifest($manifest);
$exe->write;
#roll your own
use Win32::Exe::Manifest
my $xml = $handmademanifest;
......
my $manifest = Win32::Exe::Manifest->new($xml, 'application');
$exe->set_manifest($manifest);
$exe->write;
#get formated $xml
my $xml = $manifest->output;
#try merge (experimental)
my $mfest1 = $exe->get_manifest;
my $mfest2 = Win32::Exe::Manifest->new($xml, 'application');
$mfest1->merge_manifest($mfest2);
$exe->set_manifest($mfest1);
$exe->write;
#add a dependency
my $info =
{ type => 'win32',
name => 'Dependency.Prog.Id',
version => 1.0.0.0,
language => '*',
processorArchitecture => '*',
publicKeyToken => 'hjdajhahdsa7sadhaskl',
};
$manifest->add_dependency($info);
$exe->set_manifest($manifest);
$exe->write;
DESCRIPTION
This module parses and manipulates application and assembly manifests used in MS Windows executables and DLLs. It is part of the Win32::Exe distribution.
METHODS
Constructors
new
Win32::Exe::Manifest->new($xml, $type);
Create a new manifest instance from the manifest xml in $xml. The $type param is optional and may contain 'application' (the default), or 'assembly'.
Manifest objects can also be created using Win32::Exe
my $exe = Win32:::Exe->new('somefilepath');
my $manifest = $exe->get_manifest if $exe->has_manifest;
Output
output
my $xml = $manifest->output;
Returns a formated $xml string containing all edits and changes made using Win32::Exe::Manifest
Application Identity
set_assembly_name
$manifest->set_assembly_name('My.Application.Name');
Set the application or assembly name. The name should take the form of a progid and should not include any spaces.
get_assembly_name
my $appname = $manifest->get_assembly_name;
Return the assembly or application name from the manifest.
set_assembly_description
$manifest->set_assembly_description('My Application Description');
Set the application description. The description is an informative string.
get_assembly_decription
my $desc = $manifest->get_assembly_description;
Return the assembly description from the manifest.
set_assembly_version
$manifest->set_assembly_version('1.7.8.34456');
Set the application or assembly version. The version should take the form of 'n.n.n.n' where each n is a number between 0-65535 inclusive.
get_assembly_version
my $version = $manifest->get_assembly_version;
Return the assembly or application version from the manifest.
set_assembly_language
$manifest->set_assembly_language($langid);
Set the application or assembly language. The language id is the DHTML language code. If you want to set 'language neutral' then pass '*' for the value.
see : http://msdn.microsoft.com/en-us/library/ms533052(VS.85).aspx
get_assembly_language
my $langid = $manifest->get_assembly_language;
Return the assembly or application language from the manifest. If there is no language id in the manifest, the method will return '*'
set_assembly_architecture
$manifest->set_assembly_architecture($arch);
Set the application or assembly architecture. Accepted values are : x86 msil ia64 amd64 *. Note the lowercase format. If you want your manifest to be architecture neutral, set architecture to '*'.
get_assembly_architecture
my $arch = $manifest->get_assembly_architecture;
Return the assembly or application architecture from the manifest.
Trust and Security
set_execution_level
$manifest->set_execution_level($level);
Set the application execution level. Accepted values are : asInvoker, highestAvailable, requireAdministrator, none. If you pass the value 'none', any trustInfo section will be removed from the manifest.
See http://msdn.microsoft.com/en-us/library/bb756929.aspx
get_execution_level
my $level = $manifest->get_execution_level;
Return the application execution level.
set_uiaccess
$manifest->set_uiaccess($needed);
Set the application uiAccess requirement in the trustInfo manifest section. Accepted values are 'true', 'false'. If no trustInfo section exists, one is created with the execution level set to 'asInvoker'.
See http://msdn.microsoft.com/en-us/library/bb756929.aspx
get_uiaccess
my $accessneeded = $manifest->get_uiaccess;
Return the uiAccess setting from the trustInfo structure. If no trustInfo structure exists, method returns undef.
Application Dependencies
set_resource_id
$manifest->set_resource_id($id);
Set the resource Id for the manifest. Valid id's are 1, 2 and 3. The default is 1. Don't set this unless you are fully aware of the effects.
See http://msdn.microsoft.com/en-us/library/aa376607(VS.85).aspx
get_resource_id
my $id = $manifest->get_resource_id();
Return the resource Id for the manifest.
add_common_controls
$manifest->add_common_controls();
Add a dependency on minimum version 6.0.0.0 of the Microsoft.Windows.Common-Controls shared library. This is normally done with GUI applications to use themed controls on Windows XP and above.
add_dependency
$manifest->add_dependency($info);
Add a dependency on the assembly detailed in the $info hash reference. The contents of $info should be of the form:
my $info = { type => 'win32',
name => 'Dependency.Prog.Id',
version => 1.0.0.0,
language => '*',
processorArchitecture => '*',
publicKeyToken => 'hjdajhahdsa7sadhaskl',
};
Note that the version should be the least specific that your application requires. For example, a version of '2.0.0.0' would mean the system loads the first matching assembly it finds with a version of at least '2.0.0.0'.
See: http://msdn.microsoft.com/en-us/library/aa374219(v=VS.85).aspx
remove_dependency
$manifest->remove_dependency($progid);
Remove a dependency with the $progid. For example, passing a $progid of 'Microsoft.Windows.Common-Controls' will remove the dependency added via 'add_common_controls' from the manifest.
get_dependency
my $info = $manifest->get_dependency($progid);
Return a dependency info hash for a dependency in the manifest with the 'name' $progid. The info hash is a reference to a hash with the format:
{ type => 'win32',
name => 'Dependency.Prog.Id',
version => 1.0.0.0,
language => '*',
processorArchitecture => '*',
publicKeyToken => 'hjdajhahdsa7sadhaskl',
};
If there is no dependency with the name $progid, returns undef.
get_dependencies
my @deps = $manifest->get_dependencies($progid);
Return an array of hash references, one for each dependency in the manifest. Each member is a reference to a hash with the format:
{ type => 'win32',
name => 'Dependency.Prog.Id',
version => 1.0.0.0,
language => '*',
processorArchitecture => '*',
publicKeyToken => 'hjdajhahdsa7sadhaskl',
};
If there are no dependencies, returns an empty array.
Compatibility Settings
set_compatibility
$manifest->set_compatibility( ('Windows Vista') );
Set the operating system feature compatibility flags. Parameter is a list of operating systems that the application targets. In addition to the opertating system identifier keys, this method also accepts the shorthand strings 'Windows Vista' and 'Windows 7'.
See : http://msdn.microsoft.com/en-us/library/dd371711(VS.85).aspx
get_compatibility
my @osids = $manifest->get_compatibility();
Returns a list of operating system identifier keys that the manifest notes as targetted operating systems. You can convert these os ids to the shorthand strings 'Windows Vista' and 'Windows 7' using the method
my $shortstring = $manifest->get_osname_from_osid($osid);
There is a reverse method
my $osid = $manifest->get_osid_from_osname($shortstring);
NOTE: Don't set this unless you fully understand the effects.
See : http://msdn.microsoft.com/en-us/library/dd371711(VS.85).aspx
set_dpiaware
$manifest->set_dpdaware( 'true' );
Set section in the manifest if the application is dpi aware. Accepts values true, false, and none. If the value 'none' is passed, the application\windowsSettings section is removed from the manifest entirely.
See : http://msdn.microsoft.com/en-us/library/ee308410(VS.85).aspx
get_dpiaware
$manifest->set_dpdaware( 'true' );
Return the dpiAware setting from the manifest, if any. If there is no setting, the method returns undef.
See : http://msdn.microsoft.com/en-us/library/ee308410(VS.85).aspx
Manifest Information
get_manifest_type
my $type = $manifest->get_manifest_type;
Returns the manifest type ( 'application' or 'assembly' );
SEE ALSO
Modules that use Win32::Exe::Manifest
Win32::Exe
AUTHORS
Mark Dootson <mdootson@cpan.org>
COPYRIGHT & LICENSE
Copyright 2010 by Mark Dootson <mdootson@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.