#201818 - 2011-03-30 04:21 AM
Re: Com Interface to Powershell
[Re: Allen ]
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Hey Allen, Just reading thru your thred, cool stuff, i will have to play with this, i luv the .net stuff.
Top
#204276 - 2012-02-10 07:00 PM
Re: Com Interface to Powershell
[Re: Allen ]
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4572
Loc: USA
How to determine if an EXE is 16bit, 32bit (x86), or 64bit (x64)...
break on
$RC =setoption ("NoVarsInStrings" ,"on" )
$RC =setoption ("NoMacrosInStrings" ,"on" )
$RC =setoption ("WrapATEOL" ,"on" )
? PSGetBinaryType ('%systemroot%\notepad.exe' )
? PSGetBinaryType (@scriptdir + '\kix32.exe' )
function PSGetBinaryType($FQFN , optional $PSObject )
dim $result ,$values [7 ]
$values ="Windows 32bit" ,"MSDOS" ,"Windows 16bit" ,"PIF" ,"POSIX" ,"OS/2 16bit" ,"Windows 64bit"
if $PSobject =""
$PSObject =CreateObject ("SAPIEN.ActiveXPoSH" )
endif
if exist ($FQFN )
if $PSObject.init (not 0 )
$PSGetBinaryType =-1
$PSObject.Execute ("$sig='" + '[DllImport("kernel32.dll")]' + @CRLF +
'public static extern bool GetBinaryType(string lpApplicationName,ref int lpBinaryType);' + "'" )
$PSObject.Execute ('$GetBinaryType=Add-Type -memberDefinition $sig -namespace Win32Functions -name "BinaryType" -passThru' )
$PSObject.Execute ('$ReturnedType = -1' )
$Result =$PSObject.GetValue ('$GetBinaryType::GetBinaryType("' + $FQFN + '",[ref] $ReturnedType)' )
if $result ="True"
$PSGetBinaryType =$values [$PSObject.Getvalue ('$ReturnedType' )]
endif
endif
endif
endfunction
_________________________
(... better days ahead)
Top
Moderator: Shawn , ShaneEP , Ruud van Velsen , Arend_ , Jochen , Radimus , Glenn Barnas , Allen , Mart
0 registered
and 1082 anonymous users online.