>>要程式不使用 HardDisk.. 這個需求有些奇怪,可以說明一下嗎?
說明:
吳大哥你好
我是想作教學廣播軟體,在教學端將螢幕抓下存成.jpg檔,每秒抓兩張,若使用硬碟,可能要五秒抓一張圖.效率不好.再將該目錄資源共享給受學端,受學端有show圖軟體,如此雖會造成區域網路塞車,但若使用ramdrive的話,或許可改善.
程式碼:(教學端)
Dim intCount As Integer
Dim f As Integer
Dim len1 As Long
Dim len2 As Long
Dim strFileName(0 To 20) As String
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Declare Function NViewLibSaveAsJPG Lib "NViewLib.dll" (ByVal JpegQuality As Integer, ByVal filename As String) As Long
Private Declare Function NViewLibLoad Lib "NViewLib.dll" (ByVal filename As String, ByVal a As Integer) As Long
Const SRCCOPY = &HCC0020
Private Sub Form_Load()
intCount = 1
f = 0
strFileName(0) = "e:\0.jpg"
strFileName(1) = "e:\1.jpg"
strFileName(2) = "e:\2.jpg"
strFileName(3) = "e:\3.jpg"
strFileName(4) = "e:\4.jpg"
strFileName(5) = "e:\5.jpg"
strFileName(6) = "e:\6.jpg"
strFileName(7) = "e:\7.jpg"
strFileName(8) = "e:\8.jpg"
strFileName(9) = "e:\9.jpg"
strFileName(10) = "e:\10.jpg"
strFileName(11) = "e:\11.jpg"
strFileName(12) = "e:\12.jpg"
strFileName(13) = "e:\13.jpg"
strFileName(14) = "e:\14.jpg"
strFileName(15) = "e:\15.jpg"
strFileName(16) = "e:\16.jpg"
strFileName(17) = "e:\17.jpg"
strFileName(18) = "e:\18.jpg"
strFileName(19) = "e:\19.jpg"
strFileName(20) = "e:\20.jpg"
Me.Hide
End Sub
Private Sub Timer1_Timer()
Dim hDC As Long, sx As Integer, sy As Integer
Dim intTmp As Integer
DoEvents
If f = 0 Then
f = 1
picCopy.Width = Screen.Width
picCopy.Height = Screen.Height
picCopy.AutoRedraw = True
hDC = GetDC(0)
sx = Screen.Width \ Screen.TwipsPerPixelX
sy = Screen.Height \ Screen.TwipsPerPixelY
ret = BitBlt(picCopy.hDC, 0, 0, sx, sy, hDC, 0, 0, SRCCOPY)
ret = ReleaseDC(0, hDC)
Set picCopy.Picture = picCopy.Image
picCopy.AutoRedraw = False
DoEvents
On Error Resume Next
SavePicture picCopy.Picture, "e:\~temp.BMP"
intTmp = NViewLibLoad("e:\~temp.BMP", 0)
intTmp = NViewLibSaveAsJPG(80, strFileName(intCount))
len1 = FileLen(strFileName(intCount - 1))
len2 = FileLen(strFileName(intCount))
' If len1 <> len2 Then
' Kill strFileName(intCount)
' End If
' Debug.Print len1, len2
If intCount >= 20 Then
intCount = 0
Else
intCount = intCount + 1
End If
Kill "e:\~temp.bmp"
f = 0
End If
DoEvents
End Sub