vb 释放资源文件问题
4个回答
展开全部
例子:
Dim temp() As Byte
temp = LoadResData(101, "CUSTOM") 'ico
Open "D:\1.ico" For Binary As #1
Put #1, 1, temp()
Close #1
temp= LoadResData(102, "CUSTOM") '图片
Open "D:\2.jpg" For Binary As #1
Put #2, 1, temp()
Close #2
temp = LoadResData(103, "CUSTOM") 'exe
Open "D:\3.exe" For Binary As #1
Put #3, 1, temp()
Close #3
temp = LoadResData(104, "CUSTOM") '光标
Open "D:\4.cur" For Binary As #1
Put #4, 1, temp()
Close #4
Dim temp() As Byte
temp = LoadResData(101, "CUSTOM") 'ico
Open "D:\1.ico" For Binary As #1
Put #1, 1, temp()
Close #1
temp= LoadResData(102, "CUSTOM") '图片
Open "D:\2.jpg" For Binary As #1
Put #2, 1, temp()
Close #2
temp = LoadResData(103, "CUSTOM") 'exe
Open "D:\3.exe" For Binary As #1
Put #3, 1, temp()
Close #3
temp = LoadResData(104, "CUSTOM") '光标
Open "D:\4.cur" For Binary As #1
Put #4, 1, temp()
Close #4
展开全部
参考如下代码:
Dim SysDirectory As String
Dim OcxPath As String
SysDirectory = GetSysDir
OcxPath = CreateOcx("shdocvw.dll", "DLL", 101)
Call FileCopy(OcxPath, "d:\shdocvw.dll")
Private Function CreateOcx(ByVal ocx As String, ByVal typ As String, ByVal ID As Integer) As String
'重新构建控件
Dim ByteArray() As Byte, sEnv$
sEnv = Environ("TEMP")
If OcxExists(ocx) Then Kill sEnv & "\" & ocx
ByteArray = LoadResData(ID, typ)
Open sEnv & "\" & ocx For Binary Access Write As #1
Put #1, , ByteArray()
Close #1
CreateOcx = sEnv & "\" & ocx
End Function
Private Function OcxExists(ByVal ocx As String) As Boolean
Dim sEnv$
sEnv = Environ("TEMP")
OcxExists = (Dir(sEnv & "\" & ocx) <> "")
Debug.Print sEnv
End Function
Dim SysDirectory As String
Dim OcxPath As String
SysDirectory = GetSysDir
OcxPath = CreateOcx("shdocvw.dll", "DLL", 101)
Call FileCopy(OcxPath, "d:\shdocvw.dll")
Private Function CreateOcx(ByVal ocx As String, ByVal typ As String, ByVal ID As Integer) As String
'重新构建控件
Dim ByteArray() As Byte, sEnv$
sEnv = Environ("TEMP")
If OcxExists(ocx) Then Kill sEnv & "\" & ocx
ByteArray = LoadResData(ID, typ)
Open sEnv & "\" & ocx For Binary Access Write As #1
Put #1, , ByteArray()
Close #1
CreateOcx = sEnv & "\" & ocx
End Function
Private Function OcxExists(ByVal ocx As String) As Boolean
Dim sEnv$
sEnv = Environ("TEMP")
OcxExists = (Dir(sEnv & "\" & ocx) <> "")
Debug.Print sEnv
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
On Error Resume Next
Dim v
Dim byt() As Byte
Dim x As Integer
For x = 1 To 4
Select Case x
Case 1
fname = App.Path & "\1.exe" '文件路径
v = LoadResData(101, "CUSTOM")
Case 2
fname = App.Path & "\2.exe"
v = LoadResData(102, "CUSTOM")
Case 3
fname = App.Path & "\3.exe"
v = LoadResData(103, "CUSTOM")
Case 4
fname = App.Path & "\4.exe"
v = LoadResData(104, "CUSTOM")
End Select
If Dir(fname) = "" Then
Kill fname
byt = v
Open fname For Binary As #1
Put #1, 1, byt()
Close #1
End If
Next x
刚找来的
Dim v
Dim byt() As Byte
Dim x As Integer
For x = 1 To 4
Select Case x
Case 1
fname = App.Path & "\1.exe" '文件路径
v = LoadResData(101, "CUSTOM")
Case 2
fname = App.Path & "\2.exe"
v = LoadResData(102, "CUSTOM")
Case 3
fname = App.Path & "\3.exe"
v = LoadResData(103, "CUSTOM")
Case 4
fname = App.Path & "\4.exe"
v = LoadResData(104, "CUSTOM")
End Select
If Dir(fname) = "" Then
Kill fname
byt = v
Open fname For Binary As #1
Put #1, 1, byt()
Close #1
End If
Next x
刚找来的
参考资料: http://wenwen.soso.com/z/q98993255.htm
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
资源文件可能太大了.如果没有必要,你可以用单个的文件代替.
再不你就升级电脑.
再不你就升级电脑.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询