Visual Basic 6.0 與 Windows API 講座

錯誤更正


下載更正(更新)後的範例程式


更正日期:98/05/26


p.207, 第一段程式

原書內容:

ret = RegEnumKey(hKey, Index, Name, Len(Name))

更正結果:

ret = RegEnumKey(hKey, Idx, Name, Len(Name))

更正日期:98/12/18


p.51, 中段程式

原書內容:

1. 傳遞「字串常數」
SetComputerName "新的電腦名稱"

2. 傳遞「非固定長度字串變數」
Dim Name As String
Name = "新的電腦名稱"
SetComputerName

更正結果:

1. 傳遞「字串常數」
SetComputerName "新的電腦名稱"

2. 傳遞「非固定長度字串變數」
Dim Name As String
Name = "新的電腦名稱"
SetComputerName Name

p.59

原書內容:

使用DBCS + SBCS:VB 3.0版、VB 4.0 16-bit版(只能使用於Windows 3.1)、Windows 3.1及其API、Windows 95/98及其API。

錯誤說明:VB 4.0 16-bit 版所開發的程式可以於 32-bit 作業系統(95/98、NT) 執行,但使用 VB 4.0 16-bit 版來開發程式無法使用 32-bit 作業系統所特有的功能。

p.80, 程式部分

原書內容:

' 呼叫例一:lpKeyName參數傳入「字串」型別資料 "programs"
Length = GetProfileString("windows", "programs", "", S, 80, "test.ini")

' 呼叫例二: lpKeyName參數傳入「長整數」型別資料 0&
Length = GetProfileString("windows", 0&, "", S, Len(S))

更正結果:

' 呼叫例一:lpKeyName參數傳入「字串」型別資料 "programs"
Length = GetPrivateProfileString("windows", "programs", "", S, 80, "test.ini")

' 呼叫例二: lpKeyName參數傳入「長整數」型別資料 0&
Length = GetPrivateProfileString("windows", 0&, "", S, Len(S), "test.ini")

p.405

本頁中所有的 Capture 屬性,應改成 Caption 屬性。

ch04\PlaySnd.vbp 程式

原程式內容:

Private Sub Command1_Click()

Dim wavFile As String, soundFlag As Long

wavFile = File1.Path
If Right(File1.Path, 1) <> "\" Then wavFile = wavFile & "\"
wavFile = File1.filename

soundFlag = IIf(optASYNC.Value, SND_ASYNC, SND_SYNC)
If chkLOOP Then soundFlag = soundFlag Or SND_LOOP
If chkNOSTOP Then soundFlag = soundFlag Or SND_NOSTOP

txtReturn = sndPlaySound(wavFile, soundFlag)

End Sub

更正結果:

Private Sub Command1_Click()

Dim wavFile As String, soundFlag As Long

wavFile = File1.Path
If Right(File1.Path, 1) <> "\" Then wavFile = wavFile & "\"
wavFile = wavFile & File1.filename

soundFlag = IIf(optASYNC.Value, SND_ASYNC, SND_SYNC)
If chkLOOP Then soundFlag = soundFlag Or SND_LOOP
If chkNOSTOP Then soundFlag = soundFlag Or SND_NOSTOP

txtReturn = sndPlaySound(wavFile, soundFlag)

End Sub

ch08\ScrCap.vbp 程式
ch15\ScrCap.vbp 程式
ch15\ScrCap2.vbp 程式
ch15\ScrCap3.vbp 程式
ch15\ScrCap4.vbp 程式

原程式內容:

Private Sub mSaveFile_Click()
   On Error Resume Next
   With CommonDialog1
      .DialogTitle = "儲存檔案"
      .Filter = "點陣檔(*.bmp)|*.bmp"
      .CancelError = True
      .ShowOpen
      If Err.Number <> cdlCancel Then
         SavePicture picCopy.Picture, .filename
      End If
   End With
End Sub

原程式內容:

Private Sub mSaveFile_Click()
   On Error Resume Next
   With CommonDialog1
      .DialogTitle = "儲存檔案"
      .Filter = "點陣檔(*.bmp)|*.bmp"
      .CancelError = True
      .ShowSave
      If Err.Number <> cdlCancel Then
         SavePicture picCopy.Image, .filename
      End If
   End With
End Sub