PDA

View Full Version : [VB.NET 2005] .NET e DLL in C


theCore
02-08-2006, 08:08
Salve a tutti!
Vi spiego il mio problema: ho la necessità di utilizzare una dll scritta in c con una applicazione in VB.net in particolare ho dei problemi con questa funzione:
INT DLLEXPORT PhoneP2KGetFileList( struct p2k_fileInfo ** Files )
{
p2k_fileCount();
return p2k_FSAC_fileList( ( p2k_onFile )Files );
}

la struttura che passo come parametro è questa:
struct p2k_fileInfo
{
long id;
char name[256];
long size;
unsigned char owner;
unsigned char attr;
};

e fino qui non ci piove :D ma, appena cerco di chimare la funzione in vb.net: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Se vi può servire in VB.NET dichiaro così la funzione:
Public Declare Function PhoneP2KGetFileList Lib "MotoInterface.dll" (ByVal Files() As P2KFile) As Integer

e la sturttura:

Structure P2KFile
<MarshalAsAttribute(UnmanagedType.U4)> Dim Id As Int32
<MarshalAsAttribute(UnmanagedType.LPWStr)> Dim Name As String
<MarshalAsAttribute(UnmanagedType.U4)> Dim Size As Int32
<MarshalAsAttribute(UnmanagedType.U1)> Dim Owner As Byte
<MarshalAsAttribute(UnmanagedType.U1)> Dim Attr As Byte
End Structure

Chi mi aiuta ? :D