我用WINSOCK从服务器把"1.JPG"发送到客户端(二进制文件),客户端Getdata后,有什么办法能直接读出缓冲区中的图片信息(不采用向硬盘写文件再打开的方法)? 听说有什么内存流? 希望众高手帮帮我! 有代码更好!
解决方案 »
- 大家给请意见!
- 高手讲解一下VB的Delphi之间有什么差别
- 如何让MSGBOX在规定秒数后自动结束?
- 菜鸟问题,我想在我做的写字板里设置选中文本的字体,怎么办,请高手指点,立即给分
- 送分!急急急!请帮帮我!(在线等待)
- 高分求教:在vb中如何读取WAB(outlook express保存邮件地址的文件)中的邮件地址???
- 如何用PictureBox实现如AutoCad那样放大缩小移动!
- 如何制作按钮菜单,就是单击按钮(就是带有倒三角标志的)弹出一个下拉式的文字菜单。
- 在线等候----VB中怎么动态产生菜单???
- 我是菜鸟,各位老大请帮我一下
- activex 是怎么访问服务器端数据库的?
- 学VB前景怎样?
Private Declare Function CreateStreamOnHGlobal Lib "ole32" (ByVal hGlobal As Long, ByVal fDeleteOnRelease As Long, ppstm As Any) As Long
Private Declare Function OleLoadPicture Lib "olepro32" (pStream As Any, ByVal lSize As Long, ByVal fRunmode As Long, riid As Any, ppvObj As Any) As Long
Private Declare Function CLSIDFromString Lib "ole32" (ByVal lpsz As Any, pclsid As Any) As Long
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal dwBytes 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
Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)Public Function PictureFromByteStream(b() As Byte) As IPicture
Dim hMem As Long
Dim lpMem As Long
Dim LowerBound As Long
Dim ByteCount As Long
Dim IID_IPicture(15)
Dim istm As stdole.IUnknown
LowerBound = LBound(b)
ByteCount = UBound(b) - LowerBound + 1
hMem = GlobalAlloc(&H2, ByteCount)
If hMem <> 0 Then
lpMem = GlobalLock(hMem)
If lpMem <> 0 Then
MoveMemory ByVal lpMem, b(LowerBound), ByteCount
GlobalUnlock hMem
If CreateStreamOnHGlobal(hMem, 1, istm) = 0 Then
If CLSIDFromString(StrPtr("{7BF80980-BF32-101A-8BBB-00AA00300CAB}"), IID_IPicture(0)) = 0 Then
OleLoadPicture ByVal ObjPtr(istm), ByteCount, 0, IID_IPicture(0), PictureFromByteStream
End If
End If
End If
End If
End Function