我可以从 FoxPro 通用字段中提取文件吗?

发布于 2024-07-12 03:13:57 字数 344 浏览 10 评论 0原文

我正在将 VFP 9 应用程序移植到 SQL Server。 VFP 应用程序有一些表,其中包含“常规”字段。 查询字段时我得到一个字节数组,当我将它保存到磁盘时,我可以查看里面并看到它是一个word文档,或者一个Paint BMP等。

通过阅读,我发现通用字段是一个专有格式并包含文档预览的缩略图(除其他外,我确信)。

有人可以向我指出一些代码,该代码首先提取文件类型,然后提取我可以保存为原始文件的实际文件数据。 (获取预览图像也很好。)

显然,在过去,有人在 Foxpro 中编写了一个名为 GENTOFIL.PRG 的程序,听起来它将通用字段转换为文件。 但是,当试图找到它时,谷歌并没有多大帮助!

I'm porting a VFP 9 application to SQL Server. The VFP app has some tables with "general" fields in them. I get a byte array when query the field, and when I save it to disk, I can look inside and see it's a word document, or a Paint BMP, etc.

From reading around, I've found that the general field is a proprietary format and contains a thumbnail image of the preview of the document (amongst other things, I'm sure).

Can somebody point me to some code that would extract firstly the type of file, and then the actual file data that I can save as the original file. (Getting the preview image out would be nice too.)

Apparently back in the day, somebody wrote a program in foxpro called GENTOFIL.PRG which sounds like it converts general fields to a file. But, google doesn't help much when trying to find that!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

毁我热情 2024-07-19 03:13:57

如果您知道“常规”字段的内容是一个 Word 文档,我有一些应提取它的人推荐的 Visual FoxPro 代码。

* First create a form programmatically
loForm = CREATEOBJECT("Form") 

* Open your VFP table with the general field. Change name as needed
USE CustomerDocs.DBF IN 0 ALIAS WordData

loForm.AddObject("oleWordDoc", "oleBoundControl") 
loForm.oleWordDoc.AutoSize = .T. 

* bind general field to oleboundcontrol 
loForm.oleWordDoc.ControlSource = "WordData.gen1" 

lnCounter = 1

SCAN 
   * File names all the same with counter at end
   * You might have file name in another column in the table.
   lcFileName = "docfromgeneralfield" + TRANSFORM(lnCounter)
   lcFileName = FORCEEXT(lcFileName, "doc")

   * save data from general field to .doc file 
   loForm.oleWordDoc.SaveAs("lcFileName") 

   lnCounter = lnCounter + 1 
ENDSCAN 

RELEASE loForm

USE IN (SELECT("WordData"))

RETURN

如果您需要帮助从表中提取图像,您可以查看我过去使用过的 Microsoft 知识库文章。

http://support.microsoft.com/kb/894819

里克·舒默
Visual FoxPro MVP

If you know the content of the General field is a Word Document I have some Visual FoxPro code recommended by someone that should extract it.

* First create a form programmatically
loForm = CREATEOBJECT("Form") 

* Open your VFP table with the general field. Change name as needed
USE CustomerDocs.DBF IN 0 ALIAS WordData

loForm.AddObject("oleWordDoc", "oleBoundControl") 
loForm.oleWordDoc.AutoSize = .T. 

* bind general field to oleboundcontrol 
loForm.oleWordDoc.ControlSource = "WordData.gen1" 

lnCounter = 1

SCAN 
   * File names all the same with counter at end
   * You might have file name in another column in the table.
   lcFileName = "docfromgeneralfield" + TRANSFORM(lnCounter)
   lcFileName = FORCEEXT(lcFileName, "doc")

   * save data from general field to .doc file 
   loForm.oleWordDoc.SaveAs("lcFileName") 

   lnCounter = lnCounter + 1 
ENDSCAN 

RELEASE loForm

USE IN (SELECT("WordData"))

RETURN

If you need help extracting an image out of the table you can check out a Microsoft KB article I have used in the past.

http://support.microsoft.com/kb/894819

Rick Schummer
Visual FoxPro MVP

慈悲佛祖 2024-07-19 03:13:57

VFP 中的“常规”字段类型有点奇怪...

来自 VFP 帮助文档:

通用字段包含一个十字节
参考实际内容
字段:电子表格、单词
处理器文档或图片,
由另一个应用程序创建。 这
实际数据类型和数量,
然而,取决于自动化
创建对象的服务器和
无论您链接还是嵌入 OLE
目的。

如果链接 OLE 对象,您的表
仅包含对
数据和应用程序
创建了它。 如果您嵌入 OLE
对象,该表包含一个副本
数据以及对的参考
创建它的应用程序。 尺寸
General 字段的限制仅在于
可用磁盘空间量。

这里要注意的关键是,VFP 的“常规”字段类型处理 Microsoft OLE 对象,它们可以链接嵌入< /em>。 此外,VFP 直接操作 OLE 对象的能力似乎很小,因为当对包含的 OLE 对象调用操作时,实际上会运行关联的应用程序来打开/编辑 OLE 绑定的“常规”字段的内容。

正如您所说,如果您能够手动提取文件,这可能是提取文件的最佳方法,因为即使 VFP 也提供了与通用类型字段中包含的数据进行交互的最少方法。

The "General" field type in VFP is a bit of an oddity...

From the VFP Help docs:

The General field contains a ten-byte
reference to the actual contents of
the field: a spreadsheet, a word
processor document, or a picture,
created by another application. The
actual type and amount of data,
however, depends on the Automation
server that creates the object and
whether you link or embed the OLE
object.

If you link an OLE object, your table
contains only the reference to the
data and to the application that
created it. If you embed an OLE
object, the table contains a copy of
the data as well as a reference to the
application that created it. The size
of a General field is limited only by
the amount of available disk space.

The key thing to note here is that the "general" field type of VFP deals with Microsoft OLE objects and they can be either linked or embedded. Also, VFP's ability to directly manipulate OLE objects appears to be minimal because when invoking actions on contained OLE objects, the associated application is actually run to open/edit the contents of the OLE-bound "general" field.

If, as you have said, you are able to extract the file by hand, that's probably the best way to go about getting the files out, as even VFP provides minimal ways to interact with the data contained in general type fields.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文