想在程序中加入一个功能,可以向桌面添加一个快捷方式,这需要一个组件,需要这个文件Interop.IWshRuntimeLibrary.dll,我的程序要求只能有一个exe文件,别的什么都没有,然后根据用户所需模块再下载相应的东西,所以必须要将这个DLL与主程序打到一块,我在程序中建了一资源文件,将这个文件加了进去,编译后程序是大了一些,可是我怎么才能释放出来,我查了一下以往的帖了,看见有位老大这么回答,可我却怎么都不成功,大家看一下代码.指点一下,麻烦了int Num = Resouce.Resource.Interop_IWshRuntimeLibrary.Length;
Stream strm = new MemoryStream();
strm = this.GetType().Assembly.GetManifestResourceStream("Interop.IWshRuntimeLibrary.dll");
FileStream fs = new FileStream("C:\\zsg\\Interop.IWshRuntimeLibrary.dll", FileMode.OpenOrCreate);
long lenth = strm.Length;//这步提示出错,我查了一下这时流是空的,
byte[] bBuffer = new byte[Num];
int nRealRead;
do
{
    nRealRead = strm.Read(bBuffer, 0, 1024);
    if (nRealRead > 0)
         fs.Write(bBuffer, 0, nRealRead);
    fs.Flush();
}
while (nRealRead == Num);
fs.Close();
strm.Close();

解决方案 »

  1.   

    自己解决了,帖出来,供大家参考:
    int Num = Resouce.Resource.Interop_IWshRuntimeLibrary.Length;
    byte[] Data = new byte[Num];
    Resouce.Resource.Interop_IWshRuntimeLibrary.CopyTo(Data, 0);
    FileStream fs = new FileStream("Interop.IWshRuntimeLibrary.dll", FileMode.OpenOrCreate);
    fs.Write(Data, 0, Data.Length);
    fs.Flush();
    fs.Close();
      

  2.   

    如果只是添加快捷方式,应该不至于用第三方组件吧,Win32API应该就够了
      

  3.   

    , 那楼主在引用释放的dll时候怎么做呢?反射?
      

  4.   

    从CSDN上查资料,说要加一个组件,用到这个DLL,就弄进去了,还有其它方法可以建快捷方式吗?请指点一下.