Saturday, August 28, 2010

Re: How to get Windows registry key value? Perl?

On Sat, Aug 28, 2010 at 8:47 AM, Jakson A. Aquino
<jaksonaquino@gmail.com> wrote:
> Hi,
>
> I'm unsuccessfully trying to retrieve a value ("InstallPath") from
> Windows XP registry. Is it possible to use vimscript for this? The
> code below doesn't work:
>
> perl << EOF
> sub getrpath
> {
>  use Win32::Registry;
>  my ($rkey);
>  my ($var);
>  my ($p) = "HKEY_LOCAL_MACHINE\\SOFTWARE\\R-core\\R";
>  $main::HKEY_LOCAL_MACHINE->Open($p, $rkey) || die "Open $!";
>  $rkey->QueryValue("InstallPath", $var);
>  VIM::DoCommand("let x = '$var' | echo x");
> }
> EOF
>
> Does anyone know how could I get the value of "InstallPath"? The
> solution should be good for Windows XP, Vista and 7.

SOLVED. After some trials and errors, I got the code below:

perl << EOF
sub getrpath
{
use Win32::Registry;
my ($rkey);
my ($var);
my ($type);
my ($p) = 'SOFTWARE\R-core\R';
$HKEY_LOCAL_MACHINE->Open($p, $rkey);
$rkey->QueryValueEx("InstallPath", $type, $var);
VIM::DoCommand("let b:rinstallpath = '$var'");
}
EOF

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: