使用IMAPI2.dll刻录CD / DVD

时间:2011-04-04 11:59:31

标签: visual-foxpro foxpro

我正在尝试使用IMAPI2.dll添加将CD / DVD刻录到我的应用中的功能。我正在使用 Microsoft Visual FoxPro 9 SP 2开发。当我调用方法Write()时,它是IMAPI2.MsftDiscFormat2Data类的成员(示例代码的最后一行)Visual FoxPro提供以下错误消息。错误消息:“OLE错误代码0x80004002:不支持此类接口。”

操作系统:Windows 7

请帮助。

**--Creating MsftDiscMaster2 object to connect to optical drives.
loDiscMaster = CREATEOBJECT("IMAPI2.MsftDiscMaster2")

**--Creating MsftDiscRecorder2 object for the specified burning device.
loRecorder = CREATEOBJECT("IMAPI2.MsftDiscRecorder2")
lcUniqueId = loDiscMaster.ITEM(0)
loRecorder.InitializeDiscRecorder(lcUniqueId)

**--Create an image stream for the specified directory.
loFileSystem = CREATEOBJECT("IMAPI2FS.MsftFileSystemImage")
loRootDir = loFileSystem.Root

**--Create the new disc format and set the recorder.
loDataWriter = CREATEOBJECT("IMAPI2.MsftDiscFormat2Data")
loDataWriter.Recorder = loRecorder
loDataWriter.ClientName = "IMAPIv2 TEST"

loFileSystem.ChooseImageDefaults(loRecorder)

**--Add the directory and its contents to the file system.
loRootDir.AddTree("F:\VSS",.F.)

**--Create an image from the file system
loResultImage = loFileSystem.CreateResultImage()
loStream = loResultImage.ImageStream

**--Write stream to disc using the specified recorder.
loDataWriter.Write(loStream)

1 个答案:

答案 0 :(得分:1)

我担心你在那里运气不好。 FoxPro以相当高的级别与COM对象进行交互。实际上,它的工作方式与VBScript与COM交互的方式大致相同。通常,如果您的代码在VBScript中工作,它也可以在FoxPro中工作。

这实际上是一些ActiveX / COM库的常见问题。虽然在imapi2.dll和imapi2fs.dll中实现的对象都使用IDispatch - COM接口的最高级别和最具互操作性的形式 - 这些对象的一些方法参数,方法返回和属性不是IDispatch。 / p>

具体来说,ImageStream属性返回一个名为IStream的东西,它继承自IUnknown而不是IDispatch。因此,ImageStream属性返回FoxPro不知道如何处理的内容。 FoxPro知道它是一个COM接口,但它不知道如何在该对象上查找或调用方法。

相关问题