Click here to Skip to main content
15,892,839 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak21-Mar-11 14:48
mveDave Kreskowiak21-Mar-11 14:48 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Yance Lawang21-Mar-11 17:03
Yance Lawang21-Mar-11 17:03 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak21-Mar-11 18:06
mveDave Kreskowiak21-Mar-11 18:06 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Yance Lawang21-Mar-11 20:10
Yance Lawang21-Mar-11 20:10 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? [modified] Pin
Yance Lawang23-Mar-11 16:21
Yance Lawang23-Mar-11 16:21 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak23-Mar-11 17:55
mveDave Kreskowiak23-Mar-11 17:55 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Yance Lawang23-Mar-11 20:06
Yance Lawang23-Mar-11 20:06 
QuestionMarshal structure Pin
Sonhospa20-Mar-11 1:44
Sonhospa20-Mar-11 1:44 
Hi everybody,

I'm trying get my byte array into a structure successfully with the following code. Unfortunately I have no idea how to consider endianness of the data - I'd need the bytes swapped!
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
 Public Structure FILEHEADER
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=4)> Dim magic As String
    Dim offset As UInt32
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=8)> Dim version As String
    Dim fileSize As UInt32
    Dim dittoKey As UInt32
    Dim genericSize As UInt32
    Dim industrySize As UInt32
    Dim userSize As UInt32
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=100)> Dim fileName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=24)> Dim timedate As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=100)> Dim creator As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=200)> Dim project As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=200)> Dim copyright As String
    Dim encryptKey As UInt32
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=104)> Dim Reserved As String
End Structure

Sub Main()
    Dim fh As FILEHEADER = New FILEHEADER
    ByteArray = GetBytesFromFile(myFile)
    Dim MyGC As GCHandle = GCHandle.Alloc(ByteArray, GCHandleType.Pinned)
    fh = DirectCast(Marshal.PtrToStructure(MyGC.AddrOfPinnedObject, GetType(FILEHEADER)), FILEHEADER)
    MyGC.Free()

    Console.WriteLine("Magic:" & fh.magic)
    Console.WriteLine("Offset:" & fh.offset)
    Console.WriteLine("Version:" & fh.version)
    Console.WriteLine("File Size:" & fh.fileSize)
    Console.WriteLine("Ditto Key:" & fh.dittoKey)
    Console.WriteLine("Generic Size:" & fh.genericSize)
    Console.WriteLine("Industry Size:" & fh.industrySize)
    Console.WriteLine("User Size:" & fh.userSize)
    Console.WriteLine("File Name:" & fh.fileName)
    Console.WriteLine("Time-Date:" & fh.timedate)
    Console.WriteLine("Creator:" & fh.creator)
    Console.WriteLine("Project:" & fh.project)
    Console.WriteLine("Copyright:" & fh.copyright)
    Console.WriteLine("Encrypt Key:" & fh.encryptKey)
    Console.WriteLine("Reserved:" & fh.Reserved)
    Console.WriteLine(StrDup(30, "-"))
    'Console.WriteLine("actFlatAct:" & String.Concat((From s In fh.ActFlatAct Select s.ToString("f2") & " ").ToArray))
    Console.WriteLine("FILEHEADER size:" & Marshal.SizeOf(fh))
    Console.ReadKey()

End Sub

Does anyone have an idea how to get the bytes in the swapped endian order?
Thanks for your hints!

Mick
AnswerRe: Marshal structure Pin
Dave Kreskowiak20-Mar-11 5:01
mveDave Kreskowiak20-Mar-11 5:01 
GeneralRe: Marshal structure Pin
Sonhospa20-Mar-11 21:49
Sonhospa20-Mar-11 21:49 
GeneralRe: Marshal structure Pin
Dave Kreskowiak21-Mar-11 1:05
mveDave Kreskowiak21-Mar-11 1:05 
QuestionExport to OpenOffice Pin
ivo7518-Mar-11 11:10
ivo7518-Mar-11 11:10 
AnswerRe: Export to OpenOffice Pin
Henry Minute18-Mar-11 11:32
Henry Minute18-Mar-11 11:32 
AnswerRe: Export to OpenOffice Pin
Eddy Vluggen20-Mar-11 2:49
professionalEddy Vluggen20-Mar-11 2:49 
GeneralRe: Export to OpenOffice Pin
ivo7520-Mar-11 3:02
ivo7520-Mar-11 3:02 
GeneralRe: Export to OpenOffice Pin
Eddy Vluggen20-Mar-11 3:45
professionalEddy Vluggen20-Mar-11 3:45 
GeneralRe: Export to OpenOffice Pin
ivo7520-Mar-11 3:58
ivo7520-Mar-11 3:58 
GeneralRe: Export to OpenOffice Pin
Dave Kreskowiak20-Mar-11 4:32
mveDave Kreskowiak20-Mar-11 4:32 
GeneralRe: Export to OpenOffice Pin
Eddy Vluggen20-Mar-11 4:45
professionalEddy Vluggen20-Mar-11 4:45 
GeneralRe: Export to OpenOffice Pin
Eddy Vluggen20-Mar-11 4:44
professionalEddy Vluggen20-Mar-11 4:44 
AnswerRe: Export to OpenOffice Pin
Dalek Dave18-May-11 12:28
professionalDalek Dave18-May-11 12:28 
QuestionIdeas for Matrix operation? Pin
Sonhospa18-Mar-11 2:10
Sonhospa18-Mar-11 2:10 
AnswerRe: Ideas for Matrix operation? Pin
Luc Pattyn18-Mar-11 2:37
sitebuilderLuc Pattyn18-Mar-11 2:37 
GeneralRe: Ideas for Matrix operation? Pin
Sonhospa18-Mar-11 3:31
Sonhospa18-Mar-11 3:31 
AnswerRe: Ideas for Matrix operation? Pin
Luc Pattyn18-Mar-11 3:38
sitebuilderLuc Pattyn18-Mar-11 3:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.