Hi,

Im trying out the win32::api for a project and started with the old 'new' syntax but found the 'import' to be more intuitive. When I started to recode all api calls in my script with the 'import' syntax I got some problems.

The first code returns a string with 11 domainnames separated by \0 and terminated by \0\0
The second code returns 1 domainname.
What am I doing wrong????

call def in c:

void MD_GetDomainNames(
 char* Buffer                        // buffer to receive domain list
 int BufLen                          // length of buffer
)


Best regards
Patrik K

--this works: ------------------------------------------------------------------------------------
use strict;
use Win32::API;

my $MDAEMONDLL='C:/Mdaemon/App/Mduser.dll';
print &MDapi_GetDomainNames();

sub MDapi_GetDomainNames {
my $F=new Win32::API ($MDAEMONDLL, 'MD_GetDomainNames','PI','');

my $BufferSize=(45 * 11) + 1;
my $B = " " x ($BufferSize-1);
$F->Call($B,$BufferSize);
print "rawbuffer=[ $B ]\n";
$B=~s/\0\0//;
my @Domains=split(/\0/,$B);
return @Domains;
}

--this doesnt: ------------------------------------------------------------------------------------
use strict;
use Win32::API;

my $MDAEMONDLL='C:/Mdaemon/App/Mduser.dll';
print &MDapi_GetDomainNames();

sub MDapi_GetDomainNames {
Win32::API->Import ($MDAEMONDLL, 'VOID MD_GetDomainNames (char* Buffer, int BufLen)');

my $BufferSize=(45 * 11) + 1;
my $B = " " x ($BufferSize-1);
&MD_GetDomainNames($B,$BufferSize);
print "rawbuffer=[ $B ]\n";
$B=~s/\0\0//;
my @Domains=split(/\0/,$B);
return @Domains;
}

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

Reply via email to