Hi

On 28/05/2011 07:37, Gabor Szabo wrote:

Thanks for the code!
One small thing. I think the recommended way to use "new" is to always use
the direct mode ( Win32::API->new ) and not the indirect (new Win32::API )
as the latter will not always do the right thing.

Arguably if all I have is the above code in my script then the problem won't
be triggered but I think most people, if regularly see such code they
will not know
when to avoid it. So I think it would be better not to use it even in places
where it is harmless.

Fair enough. If anyone uses the code you ought to re-write as

my $SendMessageTimeout = Win32::API->new('user32',
 'SendMessageTimeout','NNNPNNP', 'N')
        or die "Get SendMessageTimeout: "  . Win32::FormatMessage
 (Win32::GetLastError ());

I don't think I ever actually write 'new Class::Name', always 'Class::Name->new' so I guess the original code section must have a long history of paste + edit. I don't recall, it was long long ago.

I had to look up perlobj though to remind myself why I don't use indirect syntax

http://perldoc.perl.org/perlobj.html#Indirect-Object-Syntax

Mark



Reply via email to