SID Collection

2004-10-28 Thread MJG
 
What extensions are available for collecting SIDs?

Thanks

MJG

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: SID Collection

2004-10-28 Thread Anderson, Mark (Service Delivery)
WMI
http://www.google.co.uk/microsoft?hl=enq=WMI+SID+site%3Amsdn.microsoft.com;
meta=

Kind regards,

Mark Anderson
Service Improvement Project
Ground Floor, 34 Fettes Row
Edinburgh, EH3 6UY
Tel: 07808 826 063


 -Original Message-
 From: MJG [SMTP:[EMAIL PROTECTED]
 Sent: Thursday, October 28, 2004 3:11 PM
 To:   [EMAIL PROTECTED]
 Subject:  SID Collection
 
 *** WARNING : This message originates from the Internet ***
 
  
 What extensions are available for collecting SIDs?
 
 Thanks
 
 MJG
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


The Royal Bank of Scotland plc, Registered in Scotland No. 90312. Registered Office: 
36 St Andrew Square, Edinburgh EH2 2YB

The Royal Bank of Scotland plc is authorised and regulated by the Financial Services 
Authority and represents The Royal Bank of Scotland Marketing Group. The Bank sells 
life policies, collective investment schemes and pension products and advises only on 
the Marketing Group's range of these products and on a With-Profit Bond produced by 
Norwich Union Life (RBS) Limited.

This e-mail message is confidential and for use by the addressee only. If the message 
is received by anyone other than the addressee, please return the message to the 
sender by replying to it and then delete the message from your computer. Internet 
e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept 
responsibility for changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the transmission of viruses, it is 
the responsibility of the recipient to ensure that the onward transmission, opening or 
use of this message and any attachments will not adversely affect its systems or data. 
No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the 
recipient should carry out such virus and other checks as it considers appropriate.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: SID Collection

2004-10-28 Thread MJG
Thanks.  Was kind of hoping to avoid WMI on this one and find a module
already done.

M- 

-Original Message-
From: Anderson, Mark (Service Delivery)
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 28, 2004 9:17 AM
To: MJG; [EMAIL PROTECTED]
Subject: RE: SID Collection

WMI
http://www.google.co.uk/microsoft?hl=enq=WMI+SID+site%3Amsdn.microsoft.
com
meta=

Kind regards,

Mark Anderson
Service Improvement Project
Ground Floor, 34 Fettes Row
Edinburgh, EH3 6UY
Tel: 07808 826 063


 -Original Message-
 From: MJG [SMTP:[EMAIL PROTECTED]
 Sent: Thursday, October 28, 2004 3:11 PM
 To:   [EMAIL PROTECTED]
 Subject:  SID Collection
 
 *** WARNING : This message originates from the Internet ***
 
  
 What extensions are available for collecting SIDs?
 
 Thanks
 
 MJG
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


The Royal Bank of Scotland plc, Registered in Scotland No. 90312.
Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB

The Royal Bank of Scotland plc is authorised and regulated by the
Financial Services Authority and represents The Royal Bank of Scotland
Marketing Group. The Bank sells life policies, collective investment
schemes and pension products and advises only on the Marketing Group's
range of these products and on a With-Profit Bond produced by Norwich
Union Life (RBS) Limited.

This e-mail message is confidential and for use by the addressee only.
If the message is received by anyone other than the addressee, please
return the message to the sender by replying to it and then delete the
message from your computer. Internet e-mails are not necessarily secure.
The Royal Bank of Scotland plc does not accept responsibility for
changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the transmission of
viruses, it is the responsibility of the recipient to ensure that the
onward transmission, opening or use of this message and any attachments
will not adversely affect its systems or data. No responsibility is
accepted by The Royal Bank of Scotland plc in this regard and the
recipient should carry out such virus and other checks as it considers
appropriate.




___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: SID Collection

2004-10-28 Thread MJG
Trying to use a simple setup for TieRegistry.  Although it is readying
the keys, can't get it to write.  

Any ideas?

Thanks

M-

use strict;
use Win32 ();
use Win32::TieRegistry 0.20 ( Delimiter=#, ArrayValues=0 );

my $pound= $Registry-Delimiter(/);

my $UserEnv = $ENV{USERNAME};

my $RegVal1 = *Information;
my $KeyVal1 = PreferredServer;
my $RegVal2 = 0008;
my $KeyVal2 = PrintOption;
my $tempSID = S-1-5-21-842925246-1343024091-839522115-1003;
My %Key;
#--

$Key =
$Registry-{LMachine/System/CurrentControlSet/Services/NWCWorkstation/P
arameters/Option/.$tempSID}
 ||  die Can't read
LMachine/System/CurrentControlSet/Services/NWCWorkstation/Parameters/Opt
ion/ key: $^E\n;

# Add key and value Regardless
$Key-{$KeyVal1 = [ $RegVal1, REG_SZ ] };
$Key-{$KeyVal2 = [ $RegVal2, REG_DWORD ] };  

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: SID Collection

2004-10-28 Thread Adam R. Frielink
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of MJG
 Sent: Thursday, October 28, 2004 10:33 AM
 To: [EMAIL PROTECTED]
 Subject: RE: SID Collection
 
 Trying to use a simple setup for TieRegistry.  Although it is readying
 the keys, can't get it to write.  
 
 Any ideas?
 
 Thanks
 
 M-
 
 use strict;
 use Win32 ();
 use Win32::TieRegistry 0.20 ( Delimiter=#, ArrayValues=0 );
 
 my $pound= $Registry-Delimiter(/);
 
 my $UserEnv = $ENV{USERNAME};
 
 my $RegVal1 = *Information;
 my $KeyVal1 = PreferredServer;
 my $RegVal2 = 0008;
 my $KeyVal2 = PrintOption;
 my $tempSID = S-1-5-21-842925246-1343024091-839522115-1003;
 My %Key;
 #--
 
 $Key =
 $Registry-{LMachine/System/CurrentControlSet/Services/NWCWor
 kstation/Parameters/Option/.$tempSID}
  ||  die Can't read
 LMachine/System/CurrentControlSet/Services/NWCWorkstation/Para
 meters/Opt
 ion/ key: $^E\n;
 
 # Add key and value Regardless
 $Key-{$KeyVal1 = [ $RegVal1, REG_SZ ] };
 $Key-{$KeyVal2 = [ $RegVal2, REG_DWORD ] };  

Try something like this.  It will create the $tempSID if it doesn't
exist, and set the key values.

$Registry-Delimiter(/);  # Set delimiter to /.

 
$Registry-{LMachine/System/CurrentControlSet/Services/NWCWorkstation/P
arameters/Option/} = {
$tempSID/ = {
/$KeyVal1 = [ $RegVal1, REG_SZ ],
/$KeyVal2 = [ $RegVal2, REG_DWORD ],
},
}; 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: LWP help

2004-10-28 Thread Lasher, Brian
Title: Message









Lwp_example.pl is script. STATFILE
is output. I changed the proxy server info to protect TI
proprietary data, and changed the site that is being accessed (although result
is the same).







Brian Lasher

Catalog DSP Product Engineering

Best Practices and Yield Enhancement Team

[EMAIL PROTECTED]

281-274-2913(W)

281-684-4699(C)

713-664-6240(H)

281-274-2279(F)





-Original Message-
From: Gardner, Sam
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday,
 October 26, 2004 1:07 PM
To: Lasher, Brian;
Perl-Win32-Users
Subject: RE: LWP help





Kind of hard to tell, w/o
seeing the script or knowing what page it is. . . 
















 
  
  Sam Gardner
  
 
 
  
  GTO Application Development
  
 
 
  
  Keefe, Bruyette  Woods, Inc.
  
 
 
  
  212-887-6753
  
 






-Original
Message-
From: Lasher, Brian
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday,
 October 26, 2004 1:29 PM
To: Perl-Win32-Users
Subject: LWP help

I wrote a script using the LWP
module. At first I got error 500 (something about server does not
exist). Realized by reading the docs that I had to define my proxy
server. Not getting that error now, so I assume that fix worked.
Now I'm getting error 404 (doc not found) for a site that I know is
correct. Script replies the following:



CODE:
404

STATUS: 404
Not Found

CONTENT:
!DOCTYPE HTML PUBLIC -//IETF//DTD HTML 2.0//EN

htmlhead

title404 Not
Found/title

/headbody

h1Not Found/h1

pThe requested URL
/04-05RD.txt was not found on this server./p

hr /

/body/html





Anyone seen this? Is there
something people can do to prevent LWP from pulling data from their
server? Is there something I'm missing?



-brian







Brian Lasher

Catalog DSP Product Engineering

Best Practices and Yield Enhancement Team

[EMAIL PROTECTED]

281-274-2913(W)

281-684-4699(C)

713-664-6240(H)

281-274-2279(F)












lwp_example.pl
Description: lwp_example.pl
20041028

This is libwww-perl-5.79
BASE:   http://www.yahoo.com/
IS SUCCESS: 
CODE:   403
STATUS: 403 Forbidden
CONTENT:!DOCTYPE HTML PUBLIC -//IETF//DTD HTML 2.0//EN
htmlhead
title403 Forbidden/title
/headbody
h1Forbidden/h1
pYou don't have permission to access /
on this server./p
hr /
addressApache/2.0.46 (Red Hat) Server at www.yahoo.com Port 80/address
/body/html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: SID Collection

2004-10-28 Thread MJG
That did the trick.  Thanks

M- 

-Original Message-
From: Adam R. Frielink [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 28, 2004 10:42 AM
To: MJG; [EMAIL PROTECTED]
Subject: RE: SID Collection

 

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf 
 Of MJG
 Sent: Thursday, October 28, 2004 10:33 AM
 To: [EMAIL PROTECTED]
 Subject: RE: SID Collection
 
 Trying to use a simple setup for TieRegistry.  Although it is readying

 the keys, can't get it to write.
 
 Any ideas?
 
 Thanks
 
 M-
 
 use strict;
 use Win32 ();
 use Win32::TieRegistry 0.20 ( Delimiter=#, ArrayValues=0 );
 
 my $pound= $Registry-Delimiter(/);
 
 my $UserEnv = $ENV{USERNAME};
 
 my $RegVal1 = *Information;
 my $KeyVal1 = PreferredServer;
 my $RegVal2 = 0008;
 my $KeyVal2 = PrintOption;
 my $tempSID = S-1-5-21-842925246-1343024091-839522115-1003;
 My %Key;
 #--
 
 $Key =
 $Registry-{LMachine/System/CurrentControlSet/Services/NWCWor
 kstation/Parameters/Option/.$tempSID}
  ||  die Can't read
 LMachine/System/CurrentControlSet/Services/NWCWorkstation/Para
 meters/Opt
 ion/ key: $^E\n;
 
 # Add key and value Regardless
 $Key-{$KeyVal1 = [ $RegVal1, REG_SZ ] };
 $Key-{$KeyVal2 = [ $RegVal2, REG_DWORD ] };

Try something like this.  It will create the $tempSID if it doesn't
exist, and set the key values.

$Registry-Delimiter(/);  # Set delimiter to /.

 
$Registry-{LMachine/System/CurrentControlSet/Services/NWCWorkstation/P
arameters/Option/} = {
$tempSID/ = {
/$KeyVal1 = [ $RegVal1, REG_SZ ],
/$KeyVal2 = [ $RegVal2, REG_DWORD ],
},
}; 



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: LWP help

2004-10-28 Thread Gardner, Sam
Title: Message



I 
believe this line:

$req-content('query=libwww-perlmode=dist');

is 
your problem. Anyway, it's what apparently kills the script for me, 
particularly against yahoo (if I remove it and the proxy settings (which I don't 
need) it runs successfully for me). Am I correct that you listed this code 
off a tutorial page? It looks like this relates specifically to CPAN 
(since if I run it against CPAN it does work, though I do notice you changed a 
POST to a GET, and it's the POST that works against CPAN).

I also 
noticed that your attached "STATFILE" indicates "forbidden", not "not 
found". . . I'm not sure the significance of this. . . 





  
  

  Sam 
  Gardner
  

  GTO Application Development
  

  Keefe, Bruyette  Woods, Inc.
  

  212-887-6753

  
  -Original Message-From: Lasher, Brian 
  [mailto:[EMAIL PROTECTED] Sent: Thursday, October 28, 2004 11:53 
  AMTo: Gardner, Sam; Perl-Win32-UsersSubject: RE: LWP 
  help
  
  Lwp_example.pl is 
  script. STATFILE is output. I changed the "proxy server" info to 
  protect TI proprietary data, and changed the site that is being accessed 
  (although result is the same).
  
  
  
  Brian Lasher
  Catalog DSP Product 
  Engineering
  Best Practices and Yield Enhancement 
  Team
  [EMAIL PROTECTED]
  281-274-2913(W)
  281-684-4699(C)
  713-664-6240(H)
  281-274-2279(F)
  
  -Original 
  Message-From: Gardner, 
  Sam [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 26, 
  2004 1:07 
  PMTo: Lasher, Brian; 
  Perl-Win32-UsersSubject: RE: 
  LWP help
  
  
  Kind of 
  hard to tell, w/o seeing the script or knowing what page it is. . . 
  
  
  
  
  
  


  
Sam 
Gardner

  
GTO 
Application Development

  
Keefe, 
Bruyette  Woods, Inc.

  
212-887-6753
  
  
-Original 
Message-From: Lasher, 
Brian [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 
26, 2004 1:29 
PMTo: Perl-Win32-UsersSubject: LWP help
I wrote a script using the LWP 
module. At first I got error 500 (something about server does not 
exist). Realized by reading the docs that I had to define my proxy 
server. Not getting that error now, so I assume that fix worked. 
Now I'm getting error 404 (doc not found) for a site that I know is 
correct. Script replies the following:

CODE: 
404
STATUS: 
404 Not Found
CONTENT: 
!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"
htmlhead
title404 Not 
Found/title
/headbody
h1Not 
Found/h1
pThe requested URL 
/04-05RD.txt was not found on this server./p
hr /
/body/html


Anyone seen this? Is there 
something people can do to prevent LWP from pulling data from their 
server? Is there something I'm missing?

-brian



Brian Lasher
Catalog DSP Product 
Engineering
Best Practices and Yield Enhancement 
Team
[EMAIL PROTECTED]
281-274-2913(W)
281-684-4699(C)
713-664-6240(H)
281-274-2279(F)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Win32 API -GetProcessTimes

2004-10-28 Thread Jeremy A
Hi all,
I have a Win32 API problem. I want to get the creation time for a specified 
process.
I must use GetProcessTimes through perl's Win32::API interface.
what will the code be.

This is what I found in the MSDN:

GetProcessTimes
The GetProcessTimes function retrieves timing information for the specified 
process.

BOOL GetProcessTimes(
  HANDLE hProcess,
  LPFILETIME lpCreationTime,
  LPFILETIME lpExitTime,
  LPFILETIME lpKernelTime,
  LPFILETIME lpUserTime
);
Parameters
hProcess
[in] Handle to the process whose timing information is sought. This handle 
must be created with the PROCESS_QUERY_INFORMATION access right. For more 
information, see Process Security and Access Rights.
lpCreationTime
[out] Pointer to a FILETIME structure that receives the creation time of 
the process.
lpExitTime
[out] Pointer to a FILETIME structure that receives the exit time of the 
process. If the process has not exited, the content of this structure is 
undefined.
lpKernelTime
[out] Pointer to a FILETIME structure that receives the amount of time that 
the process has executed in kernel mode. The time that each of the threads 
of the process has executed in kernel mode is determined, and then all of 
those times are summed together to obtain this value.
lpUserTime
[out] Pointer to a FILETIME structure that receives the amount of time that 
the process has executed in user mode. The time that each of the threads of 
the process has executed in user mode is determined, and then all of those 
times are summed together to obtain this value.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error 
information, call GetLastError.

Remarks
All times are expressed using FILETIME data structures. Such a structure 
contains two 32-bit values that combine to form a 64-bit count of 
100-nanosecond time units.

Process creation and exit times are points in time expressed as the amount 
of time that has elapsed since midnight on January 1, 1601 at Greenwich, 
England. There are several functions that an application can use to convert 
such values to more generally useful forms.

Process kernel mode and user mode times are amounts of time. For example, 
if a process has spent one second in kernel mode, this function will fill 
the FILETIME structure specified by lpKernelTime with a 64-bit value of ten 
million. That is the number of 100-nanosecond units in one second.

Requirements
Client: Requires Windows XP, Windows 2000 Professional, or Windows NT 
Workstation 3.5 and later.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT 
Server 3.5 and later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
DLL: kernel32.dll


Thanks in advance for all your help,
regards,
Jeremy A. 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


question of regular expression

2004-10-28 Thread Ella Cai
I have one line like this:

$command = '$ldapsearch -x -LLL -h "cds2.ford.com" -b "ou=People, o=Ford,c=US" "uid=$login" uid fordUNIXid';

If condition
{
$command = '$ldapsearch -LLL -h "cds2.ford.com" -b "ou=People, o=Ford,c=US" "uid=$login" uid fordUNIXid'
# which -x need to remove
}

Could anyone let me know by using regular _expression_, how can I get rid of "-x"?

Thanks in advance!

Lixin
		Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now.___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: question of regular expression

2004-10-28 Thread Ed Chester
 Could anyone let me know by using regular expression, how can I get rid of
-x?

If that's all you really want, and you know that's the only place it can occur,
then its no problem to use just

s/-x/''/;

(substitute '-x' by '')

ed c

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: question of regular expression

2004-10-28 Thread Ed Chester

i wrote, obviously with my eyes closed: 

   s/-x/''/;

which of course should be s/-x//;  - sorry!

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


FileTimeToDosDateTime

2004-10-28 Thread Jeremy A
Hi
Thanks for your response.
I want to get the readable Dos date time from the cryptic CreationTime 
given by GetProcessTimes.
The following is my code...and the output is not readable and is wrong.

Thanks in advance,
Jeremy A.
use Win32::API;
$pid = 3228; #processid - your process id goes here.
my $OpenProcess = new Win32::API( 'kernel32.dll', 'OpenProcess', [N,I,N], N 
) || die Can not link to open proc;
my $GetProcessTimes = new Win32::API('kernel32', 
'GetProcessTimes',[I,P,P,P,P], 'I');
my $FileTimeToDosDateTime = new Win32::API('kernel32', 
'FileTimeToDosDateTime',[P,P,P], 'I');
$PROCESS_QUERY_INFORMATION = 0x0400;
$PROCESS_VM_READ = 0x0010;
my $lpCreationTime = pack 'I2', 0, 0;   # 100ns since 1/1/1601
my $lpExitTime = pack 'I2', 0, 0;
my $lpKernelTime = pack 'I2', 0, 0;
my $lpUserTime = pack 'I2', 0, 0;

my( $hProcess ) = $OpenProcess-Call( $PROCESS_QUERY_INFORMATION | 
$PROCESS_VM_READ, 0, $pid );

my $ret = $GetProcessTimes- Call($hProcess, $lpCreationTime, $lpExitTime,
  $lpKernelTime, $lpUserTime);
my $Date = pack 'I3',0,0,0;
my $Time = pack 'I3',0,0,0;
$FileTimeToDosDateTime-Call($lpCreationTime,$Date,$Time);
my ($dom,$month,$year) = unpack(I3,$Date);
my ($sec,$min,$hour) = unpack(I3,$Time);
print $dom $month $year $sec $min $hour;


At 05:13 PM 10/28/2004, you wrote:
Jeremy A wrote:
 Hi all,

 I have a Win32 API problem. I want to get the creation time for a 
specified
 process.
 I must use GetProcessTimes through perl's Win32::API interface.
 what will the code be.

Here's my hires timer script that you can extract what you need from it.
#!perl -w --
use strict;
use Win32::API;
our $debug = 0;
our $QueryPerformanceCounter;   # API function object once set in init
our $QueryPerformanceFrequency; # API function object once set in init
our $QPC_Freq;  # computed freq of QPC in seconds
our $QPC_Ovhd;  # computed overhead of QPC API call in seconds
our $GetProcessTimes;   # get kernel/user times for process
our $GetCurrentProcess; # get process handle
# test code
init_QPC ();
print \n;
printf QPC_Freq: %9.6f usecs (%u per sec)\n, 100 / $QPC_Freq, $QPC_Freq;
printf QPC_Ovhd: %9.6f usecs\n, $QPC_Ovhd * 100;
# test loop
init_getCPU ();
my @start = getCPU ();  # get CPU usage before
print [EMAIL PROTECTED] = @start\n;
my $tot_start = start_PC_timer ();
# stuff to time goes in here **
for (1 .. 10) {
# start timer
my $start = start_PC_timer ();
# time the get GTC res routine as a test of timer
my $gtc_res = get_GTC_resolution ();
printf GTC res: %.6f msecs\n, $gtc_res;
# stop timer
my $et = stop_PC_timer ($start);
printf ET : %.6f secs\n, $et;
}
# stuff to time goes in here **
my $tot_et = stop_PC_timer ($tot_start);
my @end = getCPU ();# get CPU usage after
print [EMAIL PROTECTED] = @end\n;
my @usage = compute_usage ([EMAIL PROTECTED], [EMAIL PROTECTED], $tot_et);
print \n;
printf Kernel : %.6f%%\n, $usage[0];
printf User   : %.6f%%\n, $usage[1];
print \n;
exit;
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Time GetTickCount resolution - test routine
sub get_GTC_resolution {
my $total = 0;
my $max_loops = 100;
my $tot_loops = 0;
for (1 .. $max_loops) {
my $loops = 0;
my $count1 = Win32::GetTickCount();
my $count2 = $count1;
while ($count1 == $count2) {
$count2 = Win32::GetTickCount();
$loops++;
}
$total += $count2 - $count1;
$tot_loops += $loops;
}
my $res = $total / $max_loops;
printf GetTickCount min res: %u ms, , $res if $debug;
print Took , $tot_loops / $max_loops,  loops on average\n\n if $debug;
return $res;
}
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub init_QPC {  # set 4 global vrbls for using timing routines
$QueryPerformanceCounter = new Win32::API('kernel32',
  'QueryPerformanceCounter', [qw(P)], 'I') or die
  'Failed to get QueryPerformanceCounter: ', Win32::FormatMessage (
  Win32::GetLastError ());  # set global
$QueryPerformanceFrequency = new Win32::API('kernel32',
  'QueryPerformanceFrequency', [qw(P)], 'I') or die
  'Failed to get QueryPerformanceFrequency: ', Win32::FormatMessage (
  Win32::GetLastError ());  # set global
my $freq = pack 'I2', 0;
if (not $QueryPerformanceFrequency-Call($freq)) {
die 'QueryPerformanceFrequency call failed: ',
Win32::FormatMessage (Win32::GetLastError ());
}
my @freq = reverse unpack 'I2', $freq;
$QPC_Freq = $freq[0] * 2**32 + $freq[1];# set global
printf QueryPerformanceCounter freq: 1/%u sec\n\n, $QPC_Freq if $debug;
$QPC_Ovhd = get_QPC_overhead ();# set global
}
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -