in reply to Re^2: Passing/Returning HANDLE's with Win32::API
in thread Passing/Returning HANDLE's with Win32::API

Treat this opaque cookie as a number, that is, unpack it, and then pass it in again:

$handle = unpack "V", $handle; ....

Replies are listed 'Best First'.
Re^4: Passing/Returning HANDLE's with Win32::API
by John M. Dlugosz (Monsignor) on Feb 08, 2005 at 16:24 UTC
    I see.

    What Win32::API needs is a way to specify a pointer to a DWORD "number", rather than using P which doesn't treat the value the same way as N and I.

      Win32::API treats the "P" prototype as "any" pointer - it is opaque to Win32::API and you need to post-process the value with pack>/tt> and unpack. This is not as nice as it could be, but as you are interfacing with C-level subroutines anyway, some knowledge about the stuff is needed anyway. You might have success by using the C-prototype version of Win32::API, that tries to interpret the C-prototypes of functions, but then you would need to find a way to tell Win32::API what a hFOO is without Win32::API having access to the relevant include and header files. See Convert::Binary::C for a module that does this task, and also for how ugly that way is, as Convert::Binary::C needs to implement its own C preprocessor for tracing the include statements of header files.