in reply to Re^3: How to create a File Handle Struct with Win32::API::Struct
in thread How to create a File Handle Struct with Win32::API::Struct

Yes, i know, this's outside of my territory

Leave me explain a bit more

I need open a file through the dll, so i do:

use Win32::API; use Win32::API::Struct; Win32::API::Struct->typedef( 'MYHANDLE', qw( LPCTSTR lpFileName; DWORD dwDesiredAccess; DWORD dwShareMode; LPSECURITY_ATTRIBUTES lpSecurityAttributes; DWORD dwCreationDisposition; DWORD dwFlagsAndAttributes; HANDLE hTemplateFile; )); my $handle = Win32::API::Struct->new( 'MYHANDLE' ); my $filename = './catalog.db'; my $dll = Win32::API->new( 'db.dll', 'OpenBlockFile','PS' ) or die $!; $dll->Call($filename, $handle) or die $!;

But in this's case the dll fill the struct with the associate resource or making this, the struct never would be a handle?

Replies are listed 'Best First'.
Re^5: How to create a File Handle Struct with Win32::API::Struct
by ikegami (Patriarch) on Dec 24, 2009 at 23:37 UTC

    Are you getting a HANDLE or a struct? You keep saying handle, but you keep using a struct.

    What's the signature of the DLL function? Is it

    void __stdcall OpenBlockFile( const char* szFileName, /* Input */ HANDLE* pHandle /* Output */ )
    If so, you need something like
    my $dll = Win32::API->new( 'db.dll', 'OpenBlockFile', 'PP', 'V' ) or die $^E; my $packed_handle = pack('L', 0); $dll->Call($filename, $packed_handle); $handle = unpack('L', $packed_handle);