Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Again, for all OLE gurus... This should be an easy one for somebody. Using Win32::OLE, once I connect to root\default, I get the StdRegProv object. This object has an EnumKey method, which I am trying to call. The very first input value of this method is hexadecimal... and I can't quite format my variable correctly to get it to accept it. Here's the stuff:
@host = ($server,"root/default",$user,$password); $localWMI = Win32::OLE->new('WbemScripting.SWbemLocator') or die "Cann +ot access WMI on local machine: ", Win32::OLE->LastError; $WMI = $localWMI->ConnectServer(@host) or die "Cannot access WMI on re +mote machine: ", Win32::OLE->LastError; $registry = $WMI->Get("StdRegProv") or print "Failed to get registry." +; my $err = Win32::OLE->LastError(); if ($err == 0) {print "Successful!\n";} else {print $err;} $base = "Software\\"; $registry->EnumKey('H80000002', $base, @result); my $err = Win32::OLE->LastError(); if ($err == 0) {print "Successful!\n";} else {print $err;}
From all the <gag> VBS </gag> code I can gather from other sources, the constants that the first field accepts are:
  • HKEY_CLASSES_ROOT &H80000000
  • HKEY_CURRENT_USER &H80000001
  • HKEY_USERS &H80000003
In CScript, the constant is of course set simply as
Const HKEY_LOCAL_MACHINE = &H80000002

(ref: Microsoft's site...)

No matter how I try to set the variable, I always get: OLE exception from "SWbemObject": Type mismatch Win32::OLE(0.1502) error 0x80041005 in METHOD/PROPERTYGET "EnumKey"

Anybody know the correct format to pass a hexadecimal value to an OLE method call???

In reply to Pass Hexadecimal through OLE method? by jpavel

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?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2022-12-09 13:23 GMT
Find Nodes?
    Voting Booth?

    No recent polls found