HighTechTalks DotNet Forums  

Marshal array in structure

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Marshal array in structure in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Lucvdv
 
Posts: n/a

Default Marshal array in structure - 11-17-2005 , 03:26 AM






I'm trying to interface to InfoZip's Zip32.dll from VB.Net code.

The DLL expects a structure with all its input parameters:

typedef struct {
int argc; // Count of files to zip
LPSTR lpszZipFN; // Archive file name
char **FNV; // file names to zip up. Think of this an argv
} ZCL, _far *LPZCL;

int WINAPI ZpArchive(LPZCL);


I was trying to implement this as a structure in VB.Net too, but either it
isn't possible or there's something wrong with my approach:

Private Structure ZipFileList
<MarshalAs(UnmanagedType.I4)> Dim nFiles As Integer
<MarshalAs(UnmanagedType.LPStr)> Dim ZipFile As String
<MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.LPStr)> _
Dim FileNames() As String
End Structure

I get an exception, "Can not marshal field FileNames of type ZipFileList:
This type can not be marshaled as a structure field."

Is there a way to make this work?

Reply With Quote
  #2  
Old   
Lucvdv
 
Posts: n/a

Default Re: Marshal array in structure - 11-17-2005 , 08:01 AM






On Thu, 17 Nov 2005 09:26:36 +0100, Lucvdv <replace_name (AT) null (DOT) net> wrote:

Quote:
I'm trying to interface to InfoZip's Zip32.dll from VB.Net code.

The DLL expects a structure with all its input parameters:
Quirky documentation: it doesn't expect a structure, it's just documented
in an awkward way. Apparently the correct declararion is

int WINAPI ZpArchive(int argc, LPSTR lpszZipFN, char **FNV);

So there's no need to store the array in a structure.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.