Bullock, Howard A. wrote:
>>Thanks to both of you for the feedback. Unfortunately, I could get >>neither to work. I did find a two call workaround using Win32::Lanman >>methods. In the long run I really would like to understand how to get >>this and other API calls to works. Thanks again. >> >> > > looking at the msdn docs a bit beeter, it returns a pointer to a memory block, allocated by the api. ... i don't have any domain controlers here to test the DsEnumerateDomainTrusts function, so i use another function that allocates memory for you to show how you could solve this: i use a memcpy with one int param instead of a ptr, to copy the contents of the allocated buffer to a perl string. this example prints the message for error code '0' : 'The operation completed successfully.' willem ------------------------------------------------ use constant { FORMAT_MESSAGE_ALLOCATE_BUFFER=>0x00000100, FORMAT_MESSAGE_IGNORE_INSERTS =>0x00000200, FORMAT_MESSAGE_FROM_STRING =>0x00000400, FORMAT_MESSAGE_FROM_HMODULE =>0x00000800, FORMAT_MESSAGE_FROM_SYSTEM =>0x00001000, FORMAT_MESSAGE_ARGUMENT_ARRAY =>0x00002000, FORMAT_MESSAGE_MAX_WIDTH_MASK =>0x000000FF, }; my $msgptr="\x00" x 4; my $errcode= 0; my $FormatMessage = new Win32::API('kernel32.dll', 'FormatMessage', 'NNNNPNN', 'N') or die "fmtmsg: $!\n"; my $rc= $FormatMessage->Call(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, $errcode, 0, $msgptr, 0, 0); $msgptr= unpack("V", $msgptr); printf("rc=%d msg=%08lx\n", $rc, $msgptr); my $msg= "\x00" x $rc; my $memcpy= new Win32::API('ntdll.dll', 'memcpy', 'PNN', 'V', '_cdecl') or die "memcpy: $!\n"; $memcpy->Call($msg, $msgptr, $rc); printf("msg: %s\n", $msg); my $LocalFree= new Win32::API('kernel32.dll', 'LocalFree', 'N', 'V') or die "fmtmsg: $!\n"; $LocalFree->Call($msgptr); _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs