Can someone help to try out the below code to confirm whether there is a bug??
I am running it with Perl 5.6.0 (Binary build 620) on Windows 2000 and Win32::API 
Version: 0.01 (08 Jul 1997) from 
http://www.activestate.com/PPMPackages/zips/6xx-builds-only/Win32-API.zip

The problem is that join() returns a string with an extra character prefixed. This 
only happens after a success call to LookupAccountName().

regards,
KL Lai


 $anystr = "Test";  $anystr2 = "Test";
 print join("", $anystr, $anystr2), "\n" 
  if (join("", $anystr, $anystr2) ne myjoin("", $anystr, $anystr2));

 &lookupname("Administrator");

 print join("", $anystr, $anystr2), "\n" 
  if (join("", $anystr, $anystr2) ne myjoin("", $anystr, $anystr2));

####

sub myjoin
{
  my ($join,@list) = @_;

  my $result = shift(@list);  
  foreach my $item (@list) {
    $result = $result . $join . $item;
  }
  return $result;
}

sub lookupname
{
  my ($username) = @_;

  use Win32::API;
  my $LookupAccountName = new Win32::API("Advapi32", "LookupAccountName", 
[P,P,P,P,P,P,P], N)
    or die "Failed to import Advapi32:LookupAccountName\n";

  my $server = ""; 
  my $SIDsz = 255;  my $SIDbuf = " " x $SIDsz;  
  my $domainnamesz = 255;  my $domainnamebuf = " " x $domainnamesz;
 
  print "LookupAccountName Failed.\n" 
   if (! $LookupAccountName->Call($server, $username, $SIDbuf, $SIDsz, 
                                    $domainnamebuf, $domainnamesz, $sidtypeinfo) );

  my $domainname = $domainnamebuf; $domainname =~ s/\0.*$//;
  print "--->domainname=$domainname\n";

  return;
}



_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to