Rod Butcher wrote:

> It looks like MAX_PATH defines the length of variable length string 
> szExeFile, in C. Hence for C this is a legal field definition.. but it 
> looks to me as if Win32::Api::Struct is not handling it as such. Neither 
> my Perl nor my C is strong enough to figure out a way around this. It 
> seems it's no good hardcoding MAX_PATH to some arbitrary value e.g. 
> TCHAR szExeFile[10] because the underlying C function needs a variable 
> name so it can deposit the length of the string in it - in this case the 
> command name that originated the particular process, which can have any 
> length. So how can I define MAX_PATH so that Struct.pm can use it ?

MAX_PATH is 260 - the first field in the struct has to be set to the
total length of the struct - 296 I believe.

I would try without the struct and see if you can get it to work with
a pack.

EG:

my $PE32 = pack 'LLLLLLLLLZ', 296, 0, 0, 0, 0, 0, 0, 0, 0, ' ' x 259 . "\0";

# BOOL WINAPI Process32First(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);

Win32::API->Import('kernel32', 'Process32First', 'IP', 'I') or
  die "import CreateToolhelp32Snapshot: $!($^E)";

my $ret = Process32First ($hProcessSnap, $PE32) or
  die "Process32First: $! $(^E)";

my @PE32 = unpack 'LLLLLLLLLZ', $PE32;
# print Data::Dumper->Dump([EMAIL PROTECTED], [qw([EMAIL PROTECTED])]);

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to