如何使用嵌入式资源复制文件而不制作本地副本?

发布于 2025-01-07 00:32:53 字数 120 浏览 0 评论 0原文

如果您的 VB6 项目中有一个包含二进制文件的嵌入式资源,那么什么代码会导致该文件复制到另一个位置,而无需在本地系统上创建该文件的副本?

我以前在.NET 中做过类似的事情,但我担心在 VB6 中这是不可能的。

If you have an embedded resource in your VB6 project that contains a binary file, what code would cause this file to be copied to another location, without ever making a copy of the file on the local system?

I have done something like this before in .NET but I fear it is not possible in VB6.

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

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

发布评论

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

评论(1

落日海湾 2025-01-14 00:32:53

来自 http://support.microsoft.com/kb/q194409/

 Public Function SaveResItemToDisk( _
                ByVal iResourceNum As Integer, _
                ByVal sResourceType As String, _
                ByVal sDestFileName As String _
                ) As Long
        '=============================================
        'Saves a resource item to disk

    'Returns 0 on success, error number on failure
    '=============================================

    'Example Call:
    ' iRetVal = SaveResItemToDisk(101, "CUSTOM", "C:\myImage.gif")

    Dim bytResourceData()   As Byte
    Dim iFileNumOut         As Integer

    On Error GoTo SaveResItemToDisk_err

    'Retrieve the resource contents (data) into a byte array
    bytResourceData = LoadResData(iResourceNum, sResourceType)

    'Get Free File Handle
    iFileNumOut = FreeFile

    'Open the output file
    Open sDestFileName For Binary Access Write As #iFileNumOut

        'Write the resource to the file
        Put #iFileNumOut, , bytResourceData

    'Close the file
    Close #iFileNumOut

    'Return 0 for success
    SaveResItemToDisk = 0

    Exit Function
SaveResItemToDisk_err:
    'Return error number
    SaveResItemToDisk = Err.Number
End Function

From http://support.microsoft.com/kb/q194409/ :

 Public Function SaveResItemToDisk( _
                ByVal iResourceNum As Integer, _
                ByVal sResourceType As String, _
                ByVal sDestFileName As String _
                ) As Long
        '=============================================
        'Saves a resource item to disk

    'Returns 0 on success, error number on failure
    '=============================================

    'Example Call:
    ' iRetVal = SaveResItemToDisk(101, "CUSTOM", "C:\myImage.gif")

    Dim bytResourceData()   As Byte
    Dim iFileNumOut         As Integer

    On Error GoTo SaveResItemToDisk_err

    'Retrieve the resource contents (data) into a byte array
    bytResourceData = LoadResData(iResourceNum, sResourceType)

    'Get Free File Handle
    iFileNumOut = FreeFile

    'Open the output file
    Open sDestFileName For Binary Access Write As #iFileNumOut

        'Write the resource to the file
        Put #iFileNumOut, , bytResourceData

    'Close the file
    Close #iFileNumOut

    'Return 0 for success
    SaveResItemToDisk = 0

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