0

我正在尝试学习如何打开文件,并将其内容放入 TextField 中,使用通用对话框,只有 Visual Basic 6 中的命令对话框。

我只需要一个通用对话框,因为我正在尝试在 eVB 中执行相同的应用程序,而 eVB 不支持这样的事情,这使得 VB6 开发更加简单:

Dim objFSO As New Scripting.FileSystemObject
Dim objStream As Scripting.TextStream
4

1 回答 1

1

通过 WinCE API查看eVB 文件访问。文章中的示例代码(假设您已经从通用对话框中获得了文件名 (myFileName)):

Public Const GENERIC_READ As Int32 = &H80000000 
Public Const OPEN_EXISTING As Int32 = 3

' CreateFile will open a file handle (hFile) to the file in the myFileName variable
hFile = CreateFile(myFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)

lFileSize = GetFileSize(hFile, 0)

' String(lFileSize, 0) will prepare the sContents string variable 
' to hold the contents of the file
sContents = String(lFileSize, 0)

' ReadFile actually reads the file we opened earlier and puts the contents
' into the sContents variable
ReadFile hFile, sContents, lFileSize, dwRead, 0

' Put the contents we read into the textbox
myTextBox.Text = sContents
于 2009-07-14T00:21:01.873 回答