Randy,
Thanks for the tip. This works if I run in the same program, but when
I try to access from another app, it tells me that the method failed.
This has the speed that I am looking for, but it won't let me pass the
object over. Any thoughts...maybe I am missing something. Here is
what I have on the server side:
SERVER SIDE *************************
Public Property Get ImageObj() As StdPicture
Set ImageObj = GetRemoteDesktop
End Property
Public Function GetRemoteDesktop() As Picture
Dim Pic As PicBmp
Dim IPic As IPicture
Dim IID_IDispatch As GUID
Dim hWndSrc As Long
Dim hDCSrc As Long
Dim hDCMemory As Long
Dim hBmp As Long
Dim hBmpPrev As Long
Dim WidthSrc As Long
Dim HeightSrc As Long
WidthSrc = Screen.Width \ Screen.TwipsPerPixelX
HeightSrc = Screen.Height \ Screen.TwipsPerPixelY
hWndSrc = GetDesktopWindow()
hDCSrc = GetWindowDC(hWndSrc)
hDCMemory = CreateCompatibleDC(hDCSrc)
hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc)
hBmpPrev = SelectObject(hDCMemory, hBmp)
Ret = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, 0, 0,
vbSrcCopy)
hBmp = SelectObject(hDCMemory, hBmpPrev)
Ret = DeleteDC(hDCMemory)
Ret = ReleaseDC(hWndSrc, hDCSrc)
With IID_IDispatch
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With
With Pic
.Size = Len(Pic)
.Type = vbPicTypeBitmap
.hBmp = hBmp
.hPal = 0&
End With
Ret = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)
Set GetRemoteDesktop = IPic
GetCursorPos MousePos
End Function
CLIENT SIDE CALLING ***************************************
Sub GetWindowImg
Dim objImg as StdPicture
Dim objAdmin as ServerAdmin
Set objAdmin = New ServerAdmin
'FAILS RIGHT HERE!!!! SAYS "METHOD _ImageObj FAILED"
Set objImg = objAdmin.ImageObj
End Sub
************************************************
Any clue as to why this fails?
Thanks!
Quote:
> > Surely there is a way to do this without saving the file to disk. For
> > what I am doing, saving a file to disk would present a huge
> > bottleneck.
> where are you that your network is faster than your harddrive? while
> writing to the harddrive may take some time, it will take less time than
> moving the same amount of data across a network. the network is the bottle
> neck.
> > I've found that part of my problem may be that I am using
> > an ActiveX EXE which obviously runs in a separate process on another
> > machine, and when dealing with DC's you have to remain in-Process to
> > achive this. Is there any way to just pass a bitmap back to the
> > client process without saving to file? - Maybe in a memory DC?
> I don't know how to do it in VB, but I do know how, in other languages, to
> serialize an object in order to send it over a network [1].
> another solution, by the way (though it is actually a variation on the
> serialize and send method) would be to write a web script (.asp perhaps)
> which would take the screen shot and send the data back via http. This
> should be trivial to implement.
> #[1] Python example
> # see http://www.python.org/doc/current/lib/module-cPickle.html
> # server code
> def return_bmp():
> return cPickle.dumps(bitmap_object)
> # client code
> b = cPickle.loads(server_obj.return_bmp)