怎么把dll文件做成资源放在exe工程中,运行exe时释放dll到指定位置?
怎么写函数呀???

解决方案 »

  1.   

    http://blog.csdn.net/tank77/archive/2007/01/11/1479915.aspx
      

  2.   

    这个问题问的人太多了,重新正理测试一下:
    1.先建一文件,如:myrc.rc,内容如下:
    mydll DLL E:\temp\cdll\cdll.dll
    前两个随便起,后面是你要加入的DLL名
    2.将myrc.rc加入工程
    3.释放程序如下:
    var
      h:HRSRC;
      s:integer;
      g:HGLOBAL;
      lp:pointer;
      t:tmemorystream;
    begin
      h := FindResource(0, 'mydll', 'DLL');
      if (h=0) then
      begin
        ShowMessage('error');
        exit;
      end;
      s:=SizeofResource(0, h);
      g:=LoadResource(0,h);
      lp:=LockResource(g);
      t:=tmemorystream.Create;
      t.Position:=0;
      t.Write(lp^,s);
      t.SaveToFile('e:\temp\cdll.dll');
      t.Position:=0;
      t.Free;
      FreeResource(g);
      

  3.   


    这个没有封装进exe里面吧? 我想的是把dll文件封装进exe,只有一个单独的exe环境,运行exe的时候释放出来.
      

  4.   

    将myrc.rc加入工程
    这就是放在Exe中啊。 
      

  5.   

    像这样行不行?
    mydll.rc文件内容 mydll DLL E:\1.dll批处理转换成res内容 Brccc32.exe mydll.rc转成了mydll.res 再把mydll.res放入exe工程中.代码如下:
    var 
      h:HRSRC; 
      s:integer; 
      g:HGLOBAL; 
      lp:pointer; 
      t:tmemorystream; 
    begin 
      h := FindResource(0, 'mydll', 'DLL'); 
      if (h=0) then 
      begin 
        ShowMessage('error'); 
        exit; 
      end; 
      s:=SizeofResource(0, h); 
      g:=LoadResource(0,h); 
      lp:=LockResource(g); 
      t:=tmemorystream.Create; 
      t.Position:=0; 
      t.Write(lp^,s); 
      t.SaveToFile('e:\2.dll'); 
      t.Position:=0; 
      t.Free; 
      FreeResource(g);