我想在VB中用UpdateResource等API替换掉外部程序的属性中版本、描述、版权等资源信息,应该怎么做?当然,如果有好方法, 不用这个API也可以,但必须在VB代码中完成。请指教!

解决方案 »

  1.   

    看看我写的例子吧http://econet.zjgsu.edu.cn/cy_filesxxx/vbsrc/ResUpdate.rar
      

  2.   

    参考:
    Dim   hResLoad   As   Long         '   handle   to   loaded   resource   
      Dim   hExe   As   Long                 '   handle   to   existing   .EXE   file   
      Dim   hRes   As   Long                 '   handle/ptr.   to   res.   info.   in   hExe   
      Dim   hUpdateRes   As   Long     '   update   resource   handle   
      Dim   lpResLock   As   Long       '   pointer   to   resource   data   
      Dim   result   As   Boolean   
        
      '   Load   the   .EXE   file   that   contains   the   dialog   box   you   want   to   copy.   
      hExe   =   LoadLibrary("hand.exe")   
      If   hExe   =   0   Then   MsgBox   "Could   not   load   exe."   
          
      '   Locate   the   dialog   box   resource   in   the   .EXE   file.   
      hRes   =   FindResource(hExe,   "AboutBox",   RT_DIALOG)   
      If   hRes   =   0   Then   ErrorHandler   ("Could   not   locate   dialog   box.")   
          
      '   Load   the   dialog   box   into   global   memory.   
      hResLoad   =   LoadResource(hExe,   hRes)   
      If   hResLoad   =   0   Then   MsgBox   "Could   not   load   dialog   box."   
          
      '   Lock   the   dialog   box   into   global   memory.   
      lpResLock   =   LockResource(hResLoad)   
      If   lpResLock   =   0   Then   MsgBox   "Could   not   lock   dialog   box."   
          
      '   Open   the   file   to   which   you   want   to   add   the   dialog   box   resource.   
      hUpdateRes   =   BeginUpdateResource("foot.exe",   False)   
      If   hUpdateRes   =   0   Then   MsgBox   "Could   not   open   file   for   writing."   
          
      '   Add   the   dialog   box   resource   to   the   update   list.   
      result   =   UpdateResource(hUpdateRes,   RT_DIALOG,   "AboutBox",   MAKELANGID(LANG_NEUTRAL,   SUBLANG_NEUTRAL),   lpResLock,   SizeofResource(hExe,   hRes))   
      If   Not   result   Then   MsgBox   "Could   not   add   resource."   
        
          
      '   Write   changes   to   FOOT.EXE   and   then   close   it.   
      If   EndUpdateResource(hUpdateRes,   False)   <>   0   Then   MsgBox   "Could   not   write   changes   to   file."   
          
      '   Clean   up.   
      If   FreeLibrary(hExe)   <>   0   Then   MsgBox   "Could   not   free   executable."