首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于使用DLL里面的资源有关问题,

2012-02-21 
关于使用DLL里面的资源问题,在线等![DllImport( Kernel32 )]publicstaticexternintLoadLibrary(Stringfu

关于使用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

热点排行