🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #69

Re: System.Runtime.InteropServices.Marshal.SizeOf(MiaStruttura)

#69
From: F.
Date: Wed, 17 Jan 2007 14:13
66 lines
3082 bytes
Grazie mille!


"Rafunk" <rafunkSPAM@NOTHANKSlibero.it> ha scritto nel messaggio 
news:eoko7p$p27$1@alix.livenet.it...
> F. wrote:
>> Ecco qua:
>>
>> Private Structure Lettu
>>         Public IntPiePri As Int32
>>         Public IntGiaPri As Int32
>>         Public IntFedPri As Int32
>>         Public IntRenPri As Int32
>>         Public IntLinPri As Int32
>>         Public IntPieNow As Int32
>>         Public IntGiaNow As Int32
>>         Public IntFedNow As Int32
>>         Public IntRenNow As Int32
>>         Public IntLinNow As Int32
>>         Public IntImpoPie As Double
>>         Public IntImpoGia As Double
>>         Public IntImpoFed As Double
>>         Public IntImpoRen As Double
>>         Public IntImpoLin As Double
>>         Public IntTot As Int32
>>         Public DatScad As Long
>>  End Structure
>>
>>     Private MiaStruttura As New Lettu
>>
>> ' questa espressione mi ritorna 96 byte ->
>> System.Runtime.InteropServices.Marshal.SizeOf(MiaStruttura)
>>
>> Grazie per l'eventuale risposta
>
> � come pensavo io: per allineare correttamente DatScad (che � Long, quindi 
> 8
> bytes), quando la struttura passa dal Marshaler, esso viene spostato alla
> successiva posizione multipla di 8.
>
> Se il tuo problema � passarla esattamente cos� com'� (senza padding) a 
> codice
> unmanaged, devi utilizzare l'attributo StructLayout esplicitando sia la
> dimensione totale della struttura, che le posizioni dei campi con 
> l'attributo
> FieldOffset:
>
>    <StructLayout(LayoutKind.Explicit, Size:=92)> _
>    Private Structure Lettu
>        <FieldOffset(0)> _
>        Public IntPiePri As Int32
>        <FieldOffset(4)> _
>        Public IntGiaPri As Int32
>        ...
>        <FieldOffset(80)> _
>        Public IntTot As Int32
>        <FieldOffset(84)> _
>        Public DatScad As Long
>    End Structure
>
> A questo punto SizeOf ritorna 92.
>
> Bye
>
> Raf
> 
Technical Details
Message-ID: <45ae2f0e$0$31645$4fafbaef@reader4.news.tin.it>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.volia.net!feeder.news.tin.it!spool.news.tin.it!not-for-mail
References: <45ac1594$0$8385$4fafbaef@reader5.news.tin.it> <45ac97fe$0$13253$4fafbaef@reader5.news.tin.it> <45acd996$0$4252$4fafbaef@reader1.news.tin.it> <eoko7p$p27$1@alix.livenet.it>

Show Full Headers
Complete Article Headers
X-Google-Thread: f94ee,bc28f55628632a1f
X-Google-Attributes: gidf94ee,public
X-Google-Language: ITALIAN,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.volia.net!feeder.news.tin.it!spool.news.tin.it!not-for-mail
From: "F." <f@f.it>
Newsgroups: free.it.visual-basic
References: <45ac1594$0$8385$4fafbaef@reader5.news.tin.it> <45ac97fe$0$13253$4fafbaef@reader5.news.tin.it> <45acd996$0$4252$4fafbaef@reader1.news.tin.it> <eoko7p$p27$1@alix.livenet.it>
Subject: Re: System.Runtime.InteropServices.Marshal.SizeOf(MiaStruttura)
Date: Wed, 17 Jan 2007 15:13:29 +0100
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Original
Lines: 68
Message-ID: <45ae2f0e$0$31645$4fafbaef@reader4.news.tin.it>
Organization: TIN.IT (http://www.tin.it)
X-Comments: Please send technical notifications to newsmaster@tin.it
NNTP-Posting-Host: 82.61.59.16
X-Trace: 1169043214 reader4.news.tin.it 31645 82.61.59.16:50574
X-Complaints-To: Please send abuse reports to abuse@tin.it