下面这段代码中,如果我设置objectName为中文,则代码获取objectName的长度出错。如果改为英文的就没有问题。这是为什么啊。Public Function GetScriptFileName(ByVal ObjectName As String) As String
   Dim objFileDlg As New CFileDialog
   Dim lngParenthWnd As Long
   Dim strResult As String
   
   On Error GoTo ErrRoutine
   
   ' Establish error handling information.
   Dim strRoutineName As String, strRoutineParameters As String
   strRoutineName = "GetScriptFileName"
   strRoutineParameters = "Identifying parameters:" & vbCrLf & _
      "   ObjectName      = " & ObjectName
   
   ' Get the hWnd of the Analysis Manager window.
   lngParenthWnd = GetAnalysisManagerHandle()
   
   ' Get the file name to which we will save the script.
   With objFileDlg
      .hWndOwner = lngParenthWnd
      .FileName = ObjectName
      .DefaultExtension = ".vbs"
      .Filter = "VBScript files (.vbs)|.vbs"
      .DialogTitle = "Save Meta Data Script As"
      .InitialDirectory = App.Path
      .Flags = OFN_EXPLORER Or OFN_HIDEREADONLY Or OFN_OVERWRITEPROMPT Or OFN_PATHMUSTEXIST
      
      ' Show the dialog box. If successful, retrieve the
      ' file name.
      If .ShowSave Then strResult = (.FileName)
   End With
   
   ' Clear the reference to the CFileDialog class.
   Set objFileDlg = Nothing
   
ExitRoutine:
   ' Send back the file name or an empty string.
   GetScriptFileName = strResult
   Exit FunctionErrRoutine:
   MsgBox Err.Number & " - " & Err.Description, vbExclamation, "Error - " & App.ProductName & "." & strRoutineName
   WriteErrorLog strRoutineName, strRoutineParameters, Err.Number, Err.Description
   Resume ExitRoutine
End FunctionPublic Function ShowSave() As Boolean
   ShowSave = Show(False)
End Function
然后,showsave函数会调用 GetSaveFileName(OFN),参数OFN的设置如下,其中filename即为前面的objectname   With OFN
      .nStructSize = Len(OFN)
      .hWndOwner = mlnghWndOwner
      .hInstance = App.hInstance
      .sFilter = mstrFilter
      .sCustomFilter = mstrFilter & String$(512 - Len(mstrFilter), 32)
      .nCustFilterSize = Len(.sCustomFilter)
      .nFilterIndex = mlngFilterIndex
      .sFile = strFileName
      '.sFile = "filename"
      .nFileSize = Len(strFileName)
      .sFileTitle = strFileTitle
      .nTitleSize = Len(strFileTitle)
      .sInitDir = mstrInitDir
      .sDlgTitle = mstrDlgTitle
      .lFlags = mlngFlags
      .nFileOffset = 0
      .nFileExt = 0
      .sDefFileExt = mstrDefExt
      .nCustDataSize = 0
      .fnHook = mlngCallbackHook
      .sTemplateName = ""
      '-- Win2000 support
      .pvReserved = 0
      .dwReserved = 0
      .FlagsEx = mlngExtendedFlags
   End With
Private Declare Function GetSaveFileName Lib "comdlg32.dll" _
   Alias "GetSaveFileNameA" _
   (pOpenfilename As OPENFILENAME) As Long