FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Loading raw resources

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
soywiz



Joined: 21 Oct 2005
Posts: 6

PostPosted: Sat Feb 23, 2008 1:01 am    Post subject: Loading raw resources Reply with quote

I usually attach raw files to exe using RCDATA (in .rc):
Code:
ident RCDATA DISCARDABLE "path/to/file.ext"


I noticed that dfl.resources.Resources doesn't allow to use them. Currently I am using this piece of code for that aim:

Code:
version (Windows) {
   pragma(lib, "kernel32.lib");
   import std.c.windows.windows;

   extern (Windows) {
      HGLOBAL LoadResource  (HMODULE hModule, HRSRC hResInfo);
      HRSRC   FindResourceA (HMODULE hModule, LPCTSTR lpName, LPCTSTR lpType);
      DWORD   SizeofResource(HMODULE hModule, HRSRC hResInfo);
   }
   
   ubyte[] LoadResourceRaw(char[] resname) {
      HRSRC hRsrc = FindResourceA(null, toStringz(resname), cast(char *)0x0A);
      return cast(ubyte[])LoadResource(null, hRsrc)[0..SizeofResource(null, hRsrc)];
   }

   Stream LoadStreamResourceRaw(char[] resname) {
      return new MemoryStream(LoadResourceRaw(resname));
   }
}


Something like this:

Code:

final ubyte[] getRaw(int id);
final ubyte[] getRaw(char[] name);


would be wonderful to me.

Sorry about my bad english.

Regards
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group