Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / November 2005

Tip: Looking for answers? Try searching our database.

Marshal array in structure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lucvdv - 17 Nov 2005 08:26 GMT
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?
Lucvdv - 17 Nov 2005 13:01 GMT
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.