在托管代码中使用非托管 dll 中的资源字符串表
我有一个非托管 MFC 应用程序。我已经为该应用程序编写了一个 CLI 包装器并转换为 DLL。未修改的代码具有字符串表资源,用于在各处显示消息。
现在我可以从 C# 调用非托管代码并使用内部逻辑。但是当代码尝试读取资源字符串时会出错。我希望资源没有加载,所以我尝试包含来自 kernel32.dll 的 P/invoke LoadLibraryEx,但仍然没有用。如何让非托管代码使用其资源文件?可以这样做还是应该修改?
谢谢。
I have an unmanaged MFC application. I have written a CLI wrapper for the application and converted into a DLL. The unamanged code has string table resources that is used to display messages here and there.
Now I can call the unmanaged code from C# and use the internal logic. But the code errors out when it tries to read a resource string. I hope the resources are not loaded so I tried including a P/invoke LoadLibraryEx from kernel32.dll but still no use. How can I let the unmanaged code use its resource file? Can it do that or it should be modifed??
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 UNICODE 字符串重建 MFC,声明导出函数,该函数采用语言 ID、资源字符串 ID,并返回该引用 ID 和区域设置的字符串。
并在托管程序集中使用它,如下所示
,例如:
You can rebuilt MFC using UNICODE strings, declare exported function, whick takes a language id, an ID of the resource string, and return string for that reference ID and locale.
And use it in managed assembly as follows
And, for example: