use 5.10.0; use strict; use warnings; use Win32::API; # UINT MsiGetShortcutTarget( # __in LPCTSTR szShortcutTarget, # __out LPTSTR szProductCode, # __out LPTSTR szFeatureId, # __out LPTSTR szComponentCode # ); my $MsiGetShortcutTarget = Win32::API->new( 'msi.dll', 'UINT MsiGetShortcutTarget(LPCTSTR targetFile, LPTSTR productCode, LPTSTR featureID, LPTSTR componentCode)', ); my( $file, $product, $feature, $component ) = ( 'Microsoft Office Word 2007.lnk', "\0" x 39, "\0" x 39, "\0" x 39 ); my $retCode = $MsiGetShortcutTarget->Call( $file, $product, $feature, $component ); say $retCode; $product =~ s/\0.*$//; $component =~ s/\0.*$//; say "$product|\n$feature|\n$component|"; # INSTALLSTATE MsiGetComponentPath( # __in LPCTSTR szProduct, # __in LPCTSTR szComponent, # __out LPTSTR lpPathBuf, # __inout DWORD *pcchBuf # ); my $MsiGetComponentPath = Win32::API->new( 'msi.dll', 'MsiGetComponentPath', 'PPPP', 'I' ); my( $path, $pathLength ) = ( "\0" x 260, "\0" x 8 ); my $installState = $MsiGetComponentPath->Call( $product, $component, $path, $pathLength ); say $installState; $pathLength = unpack( 'L', $pathLength ); say $pathLength; say "{$path}";