Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Below is a more or less literal translation of the VBS code linked to in the OP (identical subroutine structure; similar variable names).

That code does the right thing on 2 WinXP machines with messaging installed. But I learnt during testing that the path to follow to get the PST names was different on both, so I assume there are different versions of Windows Messaging involved here, and probably there are even more variants where the code will fail ;-).

use strict; use warnings; use Win32::TieRegistry (Delimiter => '/'); use Encode; use Data::Dumper; my %r = ( PSTGuidLocation => '01023d00', MasterConfig => '01023d0e', PSTCheckFile => '00033009', PSTFile => '001f6700', PSTFile1 => '001e6700', keyMaster => '9207f3e0a3b11019908b08002b2a56c2', ProfilesRoot => 'CUser/Software/Microsoft/Windows NT/CurrentVersion/ +Windows Messaging Subsystem/Profiles/', DefaultProfileString => '/DefaultProfile', ); my $MessagingRoot = $Registry->{$r{ProfilesRoot}} # points to the Prof +iles reg path of the current user or die "Windows Messaging not installed here!?\n"; my $DefaultProfileName = $MessagingRoot->{$r{DefaultProfileString}} or die "There are no messaging profiles for this user on this machin +e.\n"; my %Out = ("DefaultProfile" => $DefaultProfileName, Profiles => {}); my @Profiles = grep {s/\/$//} keys %{$MessagingRoot}; for my $profileName (@Profiles) { $Out{Profiles}{$profileName} = [ GetPSTsForProfile($profileName) ]; } print Dumper(\%Out); sub GetPSTsForProfile { my $profileName = shift; my $regProfile = $MessagingRoot->{"$profileName/"}; my $strValue = $MessagingRoot->{"$profileName/$r{keyMaster}//$r{Mast +erConfig}"}; my $fmt = '%02x' x 16; my @PSTFileNames; for my $strPSTGuid (map {sprintf $fmt, unpack('C16', $_)} $strValue +=~ /.{16}/g) { my $PSTGuid2 = PSTlocation($regProfile->{"$strPSTGuid/"}) or next; push @PSTFileNames, PSTFileName($regProfile->{$PSTGuid2}) if IsAPST($regProfile->{"$strPSTGuid/"}); } return @PSTFileNames; } sub IsAPST { my $PSTGuid = shift or return; my $PSTGuildValue = $PSTGuid->{"/$r{PSTCheckFile}"} or return; unpack('L', $PSTGuildValue) == 0x20; } sub PSTlocation { my $PSTGuid = shift or return; my $PSTGuildValue = $PSTGuid->{"/$r{PSTGuidLocation}"} or return; my $len = length($PSTGuildValue); my @PSTGuildValue = unpack("C$len",$PSTGuildValue); my $fmt = '%02x' x $len; sprintf($fmt, @PSTGuildValue); } sub PSTFileName { my $PSTGuid = shift or return; my $PSTName = $PSTGuid->{$r{PSTFile}}; defined $PSTName ? decode('UCS2-LE', $PSTName) : $PSTGuid->{$r{PSTFi +le1}}; }

In reply to Re: Easy way to get the location of Outlook PSTs into my perl script? by pKai
in thread Easy way to get the location of Outlook PSTs into my perl script? by rsilvergun

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-19 19:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found