soywiz
Joined: 21 Oct 2005 Posts: 6
|
Posted: Sat Feb 23, 2008 1:01 am Post subject: Loading raw resources |
|
|
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 |
|