似乎无法在自己的DLL中找到资源,我想念的是什么? [英] Can't seem to find resource in own DLL, what am I missing?

查看:72
本文介绍了似乎无法在自己的DLL中找到资源,我想念的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Windows资源管理器编写一个shell扩展.如果将代码放到exe中并运行它,则资源将完美加载.但不在DLL中.
我已验证资源是否存在(在已编译的exe和已编译的dll中).
代码段(使用GoAsm语法)为; {已删除错误检查}

I am writing a shell extension for Windows Explorer. The resource loads perfectly if I drop the code into an exe and run it. But NOT in the DLL.
I have verified the resource is there (in both the copiled exe AND compiled dll).
The code segment (in GoAsm syntax) is; {error checking removed}

// Now find Header resource Block
invoke FindResource,[hInstance], BlankStream,8"STDATA"
cmp eax,NULL
je >>.failure

mov [hResource],eax

// Pull Resource into memory
invoke LoadResource,NULL,[hResource]
cmp eax,NULL
je >>.failure

mov [hHeader],eax

// Get a pointer to Resource
invoke LockResource,[hHeader]
cmp eax,NULL
je >>.failure

mov [pHeader], eax



查找资源失败,并显示在图像文件中找不到..resource类型."
hInstance是在DLLmain loda序列中传递的一个.我也尝试过使用从GetModuleHandleEx获得的伪句柄,甚至尝试通过执行LoadLibrary调用来加载dll本身.

资源文件具有



Find Resource fails with "..resource type cannot be found in the image file."
The hInstance is the one passed in the DLLmain loda sequence. I have also tried using a pseuudo handle gotten from GetModuleHandleEx, and even tried loading the dll itself by doing a LoadLibrary call.

The resource file has

#define BlankStream 300
BlankStream STDATA Res\BlankStream.dat



就像我说的,据我所知,它在编译的dll中,并且是正确的.
资源黑客节目



And like I said, it IS THERE in the compiled dll and is correct, as far as I can tell.
Resource Hacker shows

STDATA
  300
    1033  [correct hex data]



有任何想法吗?是因为代码是COM例程的一部分吗?我又被困住了< against>.



Any ideas? Is it because the code is part of a COM routine? I am stumped <again>.

推荐答案

您是否尝试过使用FindResourceEx并显式设置lang? -ISTR在Chrome和我的NPAPI插件上也有类似的问题
Have you tried using FindResourceEx and explicitly setting the lang? - ISTR having a similar problem with Chrome and my NPAPI plugin


此处是一些其他信息,由于句柄相同,而且我确实混合使用ANSI和unicode(尽管强制带有文本BlankStream的任何一种模式,以及STDATA的结果与以前相同),我认为只是绕过文本.我在资源文件中添加了一行
#define BlankStream 300
#define STDATA 666
并将代码行更改为
Here is some further info, Since the handle is the same, and since I do have a mix of ANSI and unicode (although forcing either mode with either text BlankStream, and STDATA got same results as before) I figured to just bypass text. I added a line to the resource file
#define BlankStream 300
#define STDATA 666
and changed the line in code to
invoke FindResource,[hInstance], 300, 666



我还修复了LoadResource以使用[hInstance]
结果是它不再在FindResource上失败,并且代码按其应有的顺序流动.嗯,也许我现在想睡觉的时候应该用L代替8(UTF-16而不是UTF-8).
谢谢大家的帮助!



I also fixed the LoadResource to use the [hInstance]
Result is that it no longer fails at the FindResource, and code flows as it should. Hmmmm, maybe I should have tried L instead of 8 (UTF-16 not UTF-8) at this point I just want to go to bed.
Thanks for your help everyone!


这篇关于似乎无法在自己的DLL中找到资源,我想念的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆