VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   8595
   ClientLeft      =   165
   ClientTop       =   450
   ClientWidth     =   9120
   LinkTopic       =   "Form1"
   ScaleHeight     =   8595
   ScaleWidth      =   9120
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   3960
      TabIndex        =   0
      Top             =   4560
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Sub vbPackUDT Lib "VBHLP32.DLL" (pUDT As Any, ppResult As Long, ByVal pszFields As String)
Private Declare Function VarPtrAny Lib "msvbvm50.dll" Alias "VarPtr" (lpObject As Any) As Long
Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (lpTo As Any, lpFrom As Any, ByVal lLen As Long)
Private Declare Sub CopyMemByPtr Lib "kernel32" Alias "RtlMoveMemory" (ByVal lpTo As Long, ByVal lpFrom As Long, ByVal lLen As Long)
Private Declare Function VarPtrArray Lib "msvbvm50.dll" Alias "VarPtr" (Var() As Any) As Long


Private Type BITMAPFILEHEADER
        bfType As Integer
        bfSize As Long
        bfReserved1 As Integer
        bfReserved2 As Integer
        bfOffBits As Long
End Type
Private Sub Command1_Click()
    Dim FileHeader As BITMAPFILEHEADER
    Dim kPointer As Long
    Dim jPointer As Long
    Dim lPointer As Long
    
    FileHeader.bfType = &H4D42
    FileHeader.bfOffBits = Len(FileHeader) + 40
    FileHeader.bfSize = Len(FileHeader) + 40 + 1000

    Open "C:\windows.000\desktop\UDT.txt" For Binary As #1
    Put #1, , FileHeader
    Close #1
        
    Dim bArr() As Byte
    ReDim bArr(Len(FileHeader))
    
        
    vbPackUDT FileHeader, kPointer, "iliil"
        
    CopyMem bArr(0), ByVal kPointer, Len(FileHeader)
    
    Open "C:\windows.000\desktop\ByteArray.txt" For Binary As #1
        Put #1, , bArr
    Close #1
End Sub

