ok i am trying to make a screen capture program that takes a screenshot and sends it over winsock to a remote computer

First my program takes the screenshot as a bitmap

VB Code:
  1. SaveScreen ("C:\windows\desktop\1.bmp")


Now i need to change this picture into a byte array to send over winosck

i've tried many different procedures to change this picture into a byte array, but i've had nothing but problems on both the client and recieving end

I had tried using this code:
VB Code:
  1. ' Global Memory Flags
  2. Const GMEM_MOVEABLE = &H2
  3. Const GMEM_ZEROINIT = &H40
  4.  
  5. Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)
  6.  
  7. Private Declare Function GlobalAlloc Lib "kernel32" ( _
  8.   ByVal wFlags As Long, _
  9.   ByVal dwBytes As Long) As Long
  10.  
  11. Private Declare Function GlobalSize Lib "kernel32" ( _
  12.   ByVal hMem As Long) As Long
  13.  
  14. Private Declare Function GlobalLock Lib "kernel32" ( _
  15.   ByVal hMem As Long) As Long
  16.  
  17. Private Declare Function GlobalUnlock Lib "kernel32" ( _
  18.   ByVal hMem As Long) As Long
  19.  
  20. Const PictureID = &H746C&
  21.  
  22. Private Type PictureHeader
  23.    Magic As Long
  24.    Size As Long
  25. End Type
  26.  
  27. Public Sub Picture2Array(ByVal oObj As StdPicture, aBytes() As Byte)
  28. Dim oIPS As IPersistStream
  29. Dim oStream As IStream
  30. Dim hGlobal As Long
  31. Dim lPtr As Long
  32. Dim lSize As Long
  33. Dim Hdr As PictureHeader
  34.  
  35.    ' Get the IPersistStream interface
  36.    Set oIPS = oObj
  37.    
  38.    ' Create a IStream object
  39.    ' on global memory
  40.    Set oStream = CreateStreamOnHGlobal(0, True)
  41.    
  42.    ' Save the picture in the stream
  43.    oIPS.Save oStream, True
  44.      
  45.    ' Get the global memory handle
  46.    ' from the stream
  47.    hGlobal = GetHGlobalFromStream(oStream)
  48.    
  49.    ' Get the memory size
  50.    lSize = GlobalSize(hGlobal)
  51.    
  52.    ' Get a pointer to the memory
  53.    lPtr = GlobalLock(hGlobal)
  54.    
  55.    If lPtr Then
  56.    
  57.       lSize = lSize - Len(Hdr)
  58.      
  59.       ' Redim the array
  60.       ReDim aBytes(0 To lSize - 1)
  61.    
  62.       ' Copy the data to the array
  63.       MoveMemory aBytes(0), ByVal lPtr + Len(Hdr), lSize
  64.    
  65.    End If
  66.    
  67.    ' Release the pointer
  68.    GlobalUnlock hGlobal
  69.    
  70.    ' Release the IStream object
  71.    Set oStream = Nothing
  72.  
  73. End Sub

but i get an Automation error on the recieving end when i convert it back, so thats no good

Can someone plz HELP ME, I've been working on this problem for almost a week now, I need to figure this out!!!

Thank you,
Justin