in reply to Re^3: Use Windows wimgapi dll
in thread Use Windows wimgapi dll

One thing I forgot is that you need to add "\0" your string pre-encoding (or "\0" to your post-encoding). Win32::API will add the byte \0 for you, but the char \0 is expected (which is encoded as two \0 bytes).

So what's the error message? I bet it can be fetched via GetLastError (and a quick look at the docs would confirm that).

Replies are listed 'Best First'.
Re^5: Use Windows wimgapi dll
by iea (Beadle) on Aug 04, 2008 at 10:47 UTC
    thanks for your answer ...
    I added "\0" to the string but there is no change.
    I dont get any error message it just returns 0 as filehandle.
    my $hWim = $wimfile->Call(... #returns 0 see code above
    "sry for double post"
      You haven't added
      use strict; use warnings;
        I added GetLastError ... here is my errormsg. it die when trying to call WIMCreateFile. The paramter is incorrect
        use Win32::API; use Data::Dumper; use Win32; use strict; use warnings; use Encode qw( encode ); my $filehandler = encode('UCS-2le', "C:\\test.wim\0"); my $wimfile = new Win32::API("wimgapi", "WIMCreateFile", ['P','C','C', +'C','C','N'], 'C')or die Win32::FormatMessage(Win32::GetLastError); my $LLHandle = $wimfile->Call($filehandler, 'WIM_GENERIC_WRITE', 'WIM_CREATE_NEW', 0, 0, 0)or die Win32::FormatMessage(Win32::GetLas +tError); print $LLHandle;
        any ideas =) THANK YOU
      Here is my code ...
      use Win32::API; use Data::Dumper; use Encode qw( encode ); #API FUNCTION WIMCreateFile # HANDLE # WINAPI # WIMCreateFile( # LPWSTR lpszWimPath, # DWORD dwDesiredAccess, # DWORD dwCreationDisposition, # DWORD dwFlagsAndAttributes, # DWORD dwCompressionType, # LPDWORD lpdwCreationResult # ); my $filehandler = encode('UCS-2le', "C:\\test.wim"); #Code example in C #TCHAR *wimFile = TEXT("C:\\sample_image.wim"); my $wimfile = new Win32::API("wimgapi", "WIMCreateFile", ['P','N','N', +'N','N','N'], 'N'); my $hWim = $wimfile->Call($filehandler, WIM_GENERIC_WRITE, WIM_CREATE_NEW, 0, 0, 0); #Code example in C # hWim = WIMCreateFile ( wimFile, //exis +ting .wim file to append to # WIM_GENERIC_READ | WIM_GENERIC_WRITE, //acce +ss mode # WIM_OPEN_EXISTING, //open + flag # 0, // or +WIM_FLAG_VERIFY flag for file corruption check # 0, # &created ); print $hWim;