以下是很早的有关directx的开发例子,代码如下,但是运行出现错误,提示:编译错误,找不到工程或库,大家自己拷贝代码之后运行一下看看,vb6的,请高手指点一下我应该如何处理?
-------------------------------------------
' DirectDraw Starfield Sample, Copyright Patrice Scribe, 1997Option Compare Text
Option ExplicitPrivate Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As LongConst NumberOfStars = 400   ' Number of stars
Const ResolutionX = 320     ' Width for the display mode
Const ResolutionY = 200     ' Height for the display modeDim dd As DirectDraw2               ' DirectDraw object   //////////////////////就这里开始出现错误了!!!
Dim ddsdFront As DDSURFACEDESC      ' Front surface description
Dim ddsFront As DirectDrawSurface2  ' Front buffer
Dim ddsBack As DirectDrawSurface2   ' Back bufferDim ddCaps As DDSCAPS               ' Capabilities for search
Dim lhdc As Long                    ' hDC for back bufferDim i As Long
Dim fx As DDBLTFXDim blnEnd As BooleanPrivate Type TStar
    x As Single     ' x !
    y As Single     ' y !
    Color As Byte   ' Color (intensity)
End TypeDim aStars(1 To NumberOfStars) As TStarPrivate Sub Form_Load()
    ' Initial stars
    Dim i As Long
    For i = 1 To NumberOfStars
        With aStars(i)
            .x = Rnd * ResolutionX \ 2 - ResolutionX \ 4
            .y = Rnd * ResolutionY \ 2 - ResolutionY \ 4
            .Color = Rnd * 20 + 50
        End With
    Next
    ' Create the DirectDraw object
    DirectDrawCreate ByVal 0&, dd, Nothing
    ' This app is full screen and will change the display mode
    dd.SetCooperativeLevel Me.hWnd, DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN
    ' Set the display mode
    dd.SetDisplayMode ResolutionX, ResolutionY, 8, 0, 0
    
    ' Fill front buffer description structure...
    With ddsdFront
        ' Structure size
        .dwSize = Len(ddsdFront)
        ' Use DDSD_CAPS and BackBufferCount
        .dwFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
        ' Primary, flipable surface
        .DDSCAPS.dwCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX Or DDSCAPS_SYSTEMMEMORY
        ' One back buffer (you can try 2)
        .dwBackBufferCount = 1
    End With
    ' Create front buffer
    dd.CreateSurface ddsdFront, ddsFront, Nothing
    
    ' Retrieve the back buffer object
    ddCaps.dwCaps = DDSCAPS_BACKBUFFER
    ddsFront.GetAttachedSurface ddCaps, ddsBack
    
    'Render loop
    While Not blnEnd
        DrawNextFrame
        DoEvents
    Wend
    Unload Me
    
End Sub' Draw next frame
Private Sub DrawNextFrame()
    Dim t As RECT
    On Error Resume Next
    
    ' Clear the back buffer
    With fx
        .dwSize = Len(fx)
        .dwFillColor = RGB(0, 0, 0)
    End With
    t.Top = 0
    t.Left = 0
    t.bottom = ResolutionY
    t.Right = ResolutionX
    ddsBack.Blt t, Nothing, t, DDBLT_COLORFILL, fx
    
    ' Plot the stars (get and release the backbuffer DC)
    ddsBack.GetDC lhdc
    If Err = 0 Then
        For i = 1 To NumberOfStars
            With aStars(i)
                SetPixel lhdc, ResolutionX \ 2 + .x, ResolutionY \ 2 + .y, RGB(.Color, .Color, .Color)
            End With
        Next
        ddsBack.ReleaseDC lhdc
    End If
    
    ' Flip the buffers
    Do
        ddsFront.Flip Nothing, 0
        If Err = DDERR_SURFACELOST Then ddsFront.Restore
    Loop Until Err = 0
    
    ' Prepare the stars for the next frame
    For i = 1 To NumberOfStars
        With aStars(i)
            .x = .x * 1.2
            .y = .y * 1.2
            .Color = .Color * 1.2
            If Abs(.x) > ResolutionX \ 2 Or Abs(.y) > ResolutionY \ 2 Then
                .x = Rnd * ResolutionX \ 2 - ResolutionX \ 4
                .y = Rnd * ResolutionY \ 2 - ResolutionY \ 4
                .Color = Rnd * 20 + 50
            End If
        End With
    Next
    Exit Sub
'DrawNextFrame_Error:
'    ' If surface lost, try to restore it
'    If Err = DDERR_SURFACELOST Then
'        ddsFront.Restore
'        Resume
'    End If
'    ' If still drawing, try again
'    If Err = DDERR_WASSTILLDRAWING Then
'        Resume
'    End If
'    Resume Next
End Sub
' Unload the form
Private Sub Form_KeyPress(KeyAscii As Integer)
    blnEnd = True
End Sub
' Release DirectDraw objects
Private Sub Form_Unload(Cancel As Integer)
    dd.FlipToGDISurface
    dd.RestoreDisplayMode
    dd.SetCooperativeLevel 0, DDSCL_NORMAL
    Set ddsBack = Nothing
    Set ddsFront = Nothing
    Set dd = Nothing
    ShowCursor 1
End Sub
-----------------------------------------------------------------------