文件名称:如何制作与使用 .RES 资源文件
文件大小:2KB
文件格式:TXT
更新时间:2014-03-10 03:32:42
如何制作与使用 .RES 资源文件
'这是从资源文件里调用msvbvm60.dll 注册的代码 '本代码是放在模块 Moudule1.bas 里面,不是放在Form1里面的. '要注册.dll .ocx最好是放在.bas里面,并把启动项设为Sub Main '否则有可能在还没进入窗体执行注册的动作前,就产生错误而中断了 '尤其是98系统之下的msvbvm60.dll '先建立一个资源文件, 在 Custom 101 装载 msvbvm60.dll Global winsys$, appdisk$, aa$ Sub Main() On Error Resume Next If App.PrevInstance Then MsgBox "本系统已运行中, 不得重复加载!!", vbOKOnly, "菜鸟多媒体桌面工具": End appdisk = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\") winsys = GetSyspath Call regdllocx Form1.Show End Sub Private Sub regdllocx() On Error Resume Next Dim byt() As Byte aa = winsys & "msvbvm60.dll" If Dir(aa) = "" Then byt = LoadResData(101, "CUSTOM") Open aa For Binary As #1 Put #1, 1, byt() Close #1 End If If Dir(aa) <> "" Then aa = "Regsvr32 /s " & aa Call Shell(aa, vbHide) End If End Sub Public Function GetSyspath() As String '获取system32路径 aa = Trim(Environ("ComSpec")) GetSyspath = Mid(aa, 1, InStrRev(aa, "\")) End Function '直接从资源文件调用 .bmp图片(只允许.bmp),不必释放到硬盘 'Me.Icon = LoadResPicture(101, vbResIcon) '注释:加载图标 'Picture1.Picture = LoadResPicture(101, vbResBitmap) '注释:加载位图 'Command1.MouseIcon = LoadResPicture(101, vbResCursor) '注释:加载光标' '播放 WAVE 声音(只允许.wav) Option Explicit Private Declare Function sndPlaySoundFromMemory Lib "winmm.dll" Alias "sndPlaySoundA" (lpszSoundName As Any, ByVal uFlags As Long) As Long Const SND_ASYNC = &H1 Const SND_MEMORY = &H4 Private Sub Command1_Click() Dim bArr() As Byte bArr = LoadResData(101, "CUSTOM") DoEvents sndPlaySoundFromMemory bArr(0), SND_ASYNC Or SND_MEMORY End Sub 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cbm666/archive/2008/03/08/2158287.aspx