|
-
Dec 27th, 2002, 10:53 AM
#1
Thread Starter
Lively Member
Winsock Screen Capture, PLZ HELP!!!!
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:
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:
' Global Memory Flags
Const GMEM_MOVEABLE = &H2
Const GMEM_ZEROINIT = &H40
Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)
Private Declare Function GlobalAlloc Lib "kernel32" ( _
ByVal wFlags As Long, _
ByVal dwBytes As Long) As Long
Private Declare Function GlobalSize Lib "kernel32" ( _
ByVal hMem As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" ( _
ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" ( _
ByVal hMem As Long) As Long
Const PictureID = &H746C&
Private Type PictureHeader
Magic As Long
Size As Long
End Type
Public Sub Picture2Array(ByVal oObj As StdPicture, aBytes() As Byte)
Dim oIPS As IPersistStream
Dim oStream As IStream
Dim hGlobal As Long
Dim lPtr As Long
Dim lSize As Long
Dim Hdr As PictureHeader
' Get the IPersistStream interface
Set oIPS = oObj
' Create a IStream object
' on global memory
Set oStream = CreateStreamOnHGlobal(0, True)
' Save the picture in the stream
oIPS.Save oStream, True
' Get the global memory handle
' from the stream
hGlobal = GetHGlobalFromStream(oStream)
' Get the memory size
lSize = GlobalSize(hGlobal)
' Get a pointer to the memory
lPtr = GlobalLock(hGlobal)
If lPtr Then
lSize = lSize - Len(Hdr)
' Redim the array
ReDim aBytes(0 To lSize - 1)
' Copy the data to the array
MoveMemory aBytes(0), ByVal lPtr + Len(Hdr), lSize
End If
' Release the pointer
GlobalUnlock hGlobal
' Release the IStream object
Set oStream = Nothing
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
-
Dec 27th, 2002, 02:17 PM
#2
Dependencies: OLELIB.TLB
Go back on this link
http://www.domaindlx.com/e_morcillo/...ts/cod/com.asp
Find:
Converting Picture objects to/from byte arrays in memory
Click on OLELIB.TLB and download it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|