日期:2014-05-20  浏览次数:20753 次

关于使用DLL里面的资源问题,在线等!
[DllImport( "Kernel32 ")]
                public   static   extern   int   LoadLibrary(String   funcname);
                [DllImport( "Kernel32 ")]
                public   static   extern   int   FreeLibrary(int   handle);
                [DllImport( "Kernel32 ")]
                public   static   extern   IntPtr   FindResource(int   handle,   string   strname,   int   nType);

                private   void   GetSource(string   strName)
{
                    int   huser32   =   LoadLibrary(strName);
                    IntPtr   abc1   =   FindResource(huser32,   "NEW ",   2);// "NEW "   表示资源名字,2表示Bitmap类型
                    System.IO.FileStream   f   =   new   System.IO.FileStream(abc1,System.IO.FileAccess.Read);
                    Icon   newIcon   =   new   Icon(f);
                    FreeLibrary(huser32);
}

新建f的时候,报abc1是无效的句柄。但abc1是有非零的值阿,请问为什么?谢谢



------解决方案--------------------
.Net里面的资源不像传统exe里面的资源读取 要用Assembly命名空间来读取
------解决方案--------------------
你用的资源是在.net的程序集中还是在普通的dll中啊
------解决方案--------------------
UP